Rezwan Posted February 16, 2022 Share Posted February 16, 2022 Hello, I am trying to create a cumulative sum of Sig 1 using runningSum() within the condition "Cond". The following code was used. $Sig1.runningSum($Cond.merge(10s,true).removeLongerThan(3d)) merge() was used to get rid of all the capsules in $Cond and not it to reset before end of the condition. The reported number in the Sig 2 is not matching up the number of Sig1 if it is added manually such as data started at 3731, the next data point is 644 in Sig1. So. the second step in Sig 2 should be 4375, but runningSum() is calculating it as 8107. Any suggestion what can be done to correct it. Link to comment Share on other sites More sharing options...
Seeq Team Joe Reckamp Posted February 16, 2022 Seeq Team Share Posted February 16, 2022 Hi Rezwan, When you have a signal that is step interpolated, it may count twice (when the first sample is dropped and when the last sample is dropped). I'd suggest doing $signal.todiscrete() prior to the summation and verify that there is only one sample point per value shown on your screen. If so, then complete the running sum equation. 1 Link to comment Share on other sites More sharing options...
Rezwan Posted February 16, 2022 Author Share Posted February 16, 2022 (edited) Thanks Joe for the quick response. It worked, but I needed to convert the signal back to step and I did it as: $series.aggregate(sum(), $capsules.setMaximumDuration(40h), durationKey()) Any simpler ways to convert this to step again. For Sig1, you can see that there is no line in the first drop or I would say missing data point. tried to use setmaxinterpolate(), but it is not filling the gaps. Any suggestions on this would be much appreciated. Thanks. Edited February 16, 2022 by Rezwan clarification of statements. Link to comment Share on other sites More sharing options...
Seeq Team Joe Reckamp Posted February 16, 2022 Seeq Team Share Posted February 16, 2022 (edited) There is a .tostep(<max interpolation>) that is the easiest method. However, if it does not interpolate even though the data is within the max interpolation, that means that you likely have invalid values somewhere in the signal. You can remove those with .validvalues() Edited February 16, 2022 by Joe Reckamp Link to comment Share on other sites More sharing options...
Rezwan Posted February 17, 2022 Author Share Posted February 17, 2022 Do I have any options other than runningSum() for cumulative sum? Link to comment Share on other sites More sharing options...
Seeq Team Joe Reckamp Posted February 18, 2022 Seeq Team Share Posted February 18, 2022 Hi Rezwan, You could do an aggregation to get just the final sum value instead. $signal.aggregate(sum(), $condition, startkey()) 1 Link to comment Share on other sites More sharing options...
Rezwan Posted February 18, 2022 Author Share Posted February 18, 2022 Hi Joe, Thank you for you reply. Yes, in that case runningSum() is my best option. I am running into tow different situations with runningSum(). 1. runningSum() is working with the signal as is and providing me the right cumulative values 2. In the other cases, I needed to convert them to discreet signal as you suggested to get the right values. Do you know why I am having these two different scenarios with runningSum(). Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now