<div dir="ltr">Dear all<div><br></div><div>I have a temporal database of daily gridded rainfall for the last 40 years.</div><div><br></div><div>I want to find:</div><div>1. Number of times (count) the rainfall was 0 for 'atleast' <b>continuous </b>10 days in each year, in 5 years etc.</div><div>2. Max number of continuous (> 10days) dry days (rainfall=0) per year, per 5 years etc. In this I want to exclude continuous dry spells less than 10 days.</div><div><br></div><div>I am trying to use the `t.rast.algebra` following the example given <a href="https://grasswiki.osgeo.org/wiki/Temporal_data_processing#How_to_count_consecutive_days_that_meet_a_certain_condition.3F">here</a>.</div><div><pre style="line-height:1.3;font-family:monospace,monospace;background-color:rgb(248,249,250);color:rgb(0,0,0);border:1px solid rgb(234,236,240);padding:1em;overflow-x:hidden;font-size:14px"><span class="gmail-c1" style="color:rgb(64,128,128);font-style:italic"># Create weekly mask to which we will add 1 or 0 according to temperature in the days within it (each map in this week mask will have a value of 7)</span>
t.rast.aggregate <span class="gmail-nv" style="color:rgb(25,23,124)">input</span><span class="gmail-o" style="color:rgb(102,102,102)">=</span>temperature_daily <span class="gmail-nv" style="color:rgb(25,23,124)">output</span><span class="gmail-o" style="color:rgb(102,102,102)">=</span>weekly_mask <span class="gmail-nv" style="color:rgb(25,23,124)">basename</span><span class="gmail-o" style="color:rgb(102,102,102)">=</span>mask_week <span class="gmail-nv" style="color:rgb(25,23,124)">granularity</span><span class="gmail-o" style="color:rgb(102,102,102)">=</span><span class="gmail-s2" style="color:rgb(186,33,33)">"1 weeks"</span> <span class="gmail-nv" style="color:rgb(25,23,124)">method</span><span class="gmail-o" style="color:rgb(102,102,102)">=</span>count

<span class="gmail-c1" style="color:rgb(64,128,128);font-style:italic"># Calculate consecutive days with negative temperatures</span>
t.rast.algebra <span class="gmail-nv" style="color:rgb(25,23,124)">base</span><span class="gmail-o" style="color:rgb(102,102,102)">=</span>neg_temp_days <span class="gmail-nv" style="color:rgb(25,23,124)">expression</span><span class="gmail-o" style="color:rgb(102,102,102)">=</span><span class="gmail-s2" style="color:rgb(186,33,33)">"consecutive_days = weekly_mask {+,contains,l} if(temperature_daily < 0 && temperature_daily[-1] < 0 || temperature_daily[1] < 0 && temperature_daily < 0, 1, 0)"</span></pre></div><div><br></div><div>The example works, but the above code counts every consecutive day in a week even if there is a break in between.</div><div>I also didn't understand why the consecutive days are added to the total number of days (+7) in the week in 'mask_week' strds. </div><div><br></div><div>I tried modifying the aggregate expression, but could not make it work to my requirement as stated above.</div><div><br></div><div>Could anyone give a hint on how to go about this.</div><div><br></div><div>Many thanks in advance,</div><div><br></div><div>Best Regards</div><div><br></div><div>Sajid</div><div><br></div></div>