I think you also need to consider the case when the first entry of your time series is 1 (i.e. coincides with the start of a spell). In that case your solution (2) would not catch the first event and even numbers would correspond to wet spells rather than dry.
You could either pad the series at the start with a dry day or maybe add one if necessary using the first value in your range of interest.
def sym first_day 183 ! this is a wet day in your series below
let ID_GOOD = VAR1[L=@EVNT:0.999] + `VAR1[l=(first_day)]`
To get the number of days in a spell you could spread the results along a new axis and then count the number of good values.
def axis/x=1:`id_good[l=@max]`:1 xax
let id_good_2d = if id_good eq i then id_good + 0*i[gx=xax] ! Put spell "i" on its own axis.
shade id_good_2d ! we can see each spell wet or dry. This can be masked using mod(var,2) eq 0 or 1
let length_of_spell = id_good_2d[l=@ngd]
plot/title="Spell length" length_of_spell
plot/title="Wet spell length"/sym if mod(id_good,2) eq 1 then length_of_spell
The stats should be easy after this.
On 15/05/14 05:22, 'jagadish karmacharya' via _OAR PMEL Ferret Users wrote: