[GRASS-user] Computing continuous dry spell from strds
Veronica Andreo
veroandreo at gmail.com
Tue Oct 24 15:52:47 PDT 2023
Hi Sajid,
The example uses a weekly mask because I was interested in consecutive
freezing days per week. The idea, as explained to me by Thomas was to use
this weekly mask (a strds with zero value all over the region) as a
placeholder to add 1 only if the day after or before the current one also
met the condition being evaluated. So, this resulting consecutive-days time
series had 0, 2, 3, etc per pixel per week and that made sense to me for
mosquitoes.
For your problem, perhaps you could either create a zeroes strds with
monthly granularity and using the same command you would get consecutive
days of no rain per month, then add that into years and such... or create a
daily zeroes strds and add one every time the condition is met, i.e.,
current day without rain and previous or posterior day without rain. But
then again, you will need some granularity to count how many times you have
10+ days without rain. You could iterate the counts with increasing
granularities, i.e., do the counting for granularities of 10, 15, 20 days
and so on. But that seems a bit too much. Maybe, you can either try lower
level functions in the temporal framework combined with pygrass and python
or create your own function (?) and contribute it :)
There was a question about consecutive days last year:
https://lists.osgeo.org/pipermail/grass-user/2022-August/083037.html.
Perhaps others can share their insight and ideas
I wish I could be of more help!
Cheers,
Vero
El vie, 13 oct 2023 a las 6:37, Sajid Pareeth via grass-user (<
grass-user at lists.osgeo.org>) escribió:
> Dear all
>
> I have a temporal database of daily gridded rainfall for the last 40 years.
>
> I want to find:
> 1. Number of times (count) the rainfall was 0 for 'atleast' *continuous *10
> days in each year, in 5 years etc.
> 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.
>
> I am trying to use the `t.rast.algebra` following the example given here
> <https://grasswiki.osgeo.org/wiki/Temporal_data_processing#How_to_count_consecutive_days_that_meet_a_certain_condition.3F>
> .
>
> # 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)
> t.rast.aggregate input=temperature_daily output=weekly_mask basename=mask_week granularity="1 weeks" method=count
> # Calculate consecutive days with negative temperatures
> t.rast.algebra base=neg_temp_days expression="consecutive_days = weekly_mask {+,contains,l} if(temperature_daily < 0 && temperature_daily[-1] < 0 || temperature_daily[1] < 0 && temperature_daily < 0, 1, 0)"
>
>
> The example works, but the above code counts every consecutive day in a
> week even if there is a break in between.
> 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.
>
> I tried modifying the aggregate expression, but could not make it work to
> my requirement as stated above.
>
> Could anyone give a hint on how to go about this.
>
> Many thanks in advance,
>
> Best Regards
>
> Sajid
>
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/grass-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20231024/16a564cc/attachment.htm>
More information about the grass-user
mailing list