I noticed that RMevents_sample does not correctly include rain for the period immediately preceding the start times. The bug appears if the first row of the precipitation dataframe beginRow has a calculated time difference greater than ieSec. If so, the code will not allow for rain preceding the start time to contribute to the rain totals. I updated the function and the code below should fix the issue.
I also changed the df argument so the initial data.frame is not overwritten on the first line. This makes it easier to diagnose issues.
I noticed that
RMevents_sample
does not correctly include rain for the period immediately preceding the start times. The bug appears if the first row of the precipitation dataframebeginRow
has a calculated time difference greater than ieSec. If so, the code will not allow for rain preceding the start time to contribute to the rain totals. I updated the function and the code below should fix the issue.I also changed the
df
argument so the initial data.frame is not overwritten on the first line. This makes it easier to diagnose issues.https://github.com/USGS-R/Rainmaker/blob/0b5509d79fc8db459c469bb55feefce91707de82/R/RMevents_sample.R#L75