[Thread Prev][Thread Next][Index]

RE: [ferret_users] running sum with restart after a missing value



Dear Ryo,

thanks for your suggestions. However, I would like to calculate a running sum that starts from zero when a missing value is found. Here is a very simple example:

Data (.. is missing values):
.. 4 2 6 3 5 .. .. .. 5 9 2 4 .. 6 7 3 5 8 .. ..

I would like to have:
.. 4 6 12 15 20 .. .. .. 5 14 16 20 .. 6 13 16 21 29 .. ..

Any suggestions would be very appreciated.

Thomas

 


From: Ryo Furue [furue@xxxxxxxxxx]
Sent: Monday, September 04, 2017 8:27 AM
To: Frölicher Thomas
Cc: ferret users
Subject: Re: [ferret_users] running sum with restart after a missing value

Hi Thomas,

I would like to calculate a running sum over multiple time step, which however restarts after a missing value.

That behavior seems to me to be inconsistent; that is, @SUM skips missing values and gives a sum of valid values, whereas @RSUM stops when it finds a missing value.
 
Is there a simple solutions in ferret?

If you just want to skip the missing values in your running sum, you want to assign zeros to them. This is a contrived, simple example:

    let var = TSEQUENCE({1,2,-1.0e34,4,5,6})
    let var2 = ifv var then var else 0
    plot/line/symbol var2[t=@RSUM], var[t=@RSUM]

Hope this helps.

Ryo

[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement