fix precip calculation in fw13_createTimeseriesObject()
Closed this issue · 0 comments
We need to handle the case where the is precipitation on the first hour of the LST (Local Standard Time) day.
Right now, we reset any negative values to zero. This means that the start of a new LST day will always have zero precip.
Instead, we need to be more careful and compare the negative value of the first hour of the day with the positive value of the last hour of the day. If they are the same except for the negative sign, then we can safely set the first hour to zero. But if they differ, we need to add them together to find out how much rain fell in the first hour of the new day.
I suspect this will be straightforward if you create another vector of values by using lag()
to create a 1-hour offset of precipHourly
and then adding the two time series together to create a newValue
which can help with masking . When precipHourly < 0 & newValue == 0
then we can reset the precipitation value to zero, otherwise when precipHourly < 0
we need to figure out how much it rained in the first hour of the day.