Set Binary Flag for Continuous Grouping of Data
Hi Folks,
I have some snow data and I want to be able to determine the starting and ending dates of the presence of snow by various time intervals (month, water year, year) using Tables | Summary.
I want to set col(x) value to 1 when the current row plus the next 5 rows for snow contain snow data (> 0). I can get this to work well when I have more than 10 continuous rows of snow. When the number of continuous rows of snow is < 10 then I get the following results using the following code:
Flag Snow
0 0.0
0 0.0
1 1.0
1 2.0
0 3.0
0 4.0
1 5.0
1 6.0
0 0.0
0 0.0
0 0.0
0 0.0
If(
:Name( "snow" ) > 0 & Lag( :Name( "snow" ) > 0, -1 ) &
Lag( :Name( "snow" ) > 0, -2 ) & Lag(
:Name( "snow" ) > 0,
-3
) & Lag( :Name( "snow" ) > 0, -4 ) | :Name( "snow" ) >
0 & Lag( :Name( "snow" ) > 0, 1 ) &
Lag( :Name( "snow" ) > 0, 2 ) & Lag(
:Name( "snow" ) > 0,
3
) & Lag( :Name( "snow" ) > 0, 4 ),
1,
0
)
Any ideas on how to do this the correct, or a better, way? I need to create different threshold levels for this calculation so having something that would work for 7, 10, 21 continuous days of data is essential