You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We already have statistics and thresholded_statistics, but a rolling_statistics would be very useful for anything related to hydrology and probably other domains too.
Use cases include for example computing the maximum 14-day mean flow (q14max), or the minimum 7-day mean flow (q7min).
Potential Solution
Possible code to be used:
def roll_stats(da: xr.DataArray, window: int, window_reducer: str, reducer: str, freq: str, **indexer) -> xr.DataArray:
"""Calculate a stat on a rolling stat."""
rolled = getattr(da.rolling(time=window, center=True), window_reducer)()
rolled_indexed = select_time(rolled, **indexer)
out = getattr(rolled_indexed.resample(time=freq), reducer)()
out.attrs["units"] = da.attrs["units"] # on peut faire mieux
return out
Additional context
No response
Contribution
I would be willing/able to open a Pull Request to contribute this feature.
Code of Conduct
I agree to follow this project's Code of Conduct
The text was updated successfully, but these errors were encountered:
<!--Please ensure the PR fulfills the following requirements! -->
<!-- If this is your first PR, make sure to add your details to the
AUTHORS.rst! -->
### Pull Request Checklist:
- [x] This PR addresses an already opened issue (for bug fixes /
features)
- This PR fixes#1480
- [x] Tests for the changes have been added (for bug fixes / features)
- [x] (If applicable) Documentation has been added / updated (for bug
fixes / features)
- [x] CHANGES.rst has been updated (with summary of main changes)
- [x] Link to issue (:issue:`number`) and pull request (:pull:`number`)
has been added
### What kind of change does this PR introduce?
* Adds `xclim.indices.select_rolling_resample_op` that acts in a way
similar to `select_resample_op`, but with a rolling window beforehand.
### Does this PR introduce a breaking change?
### Other information:
Addressing a Problem?
We already have
statistics
andthresholded_statistics
, but arolling_statistics
would be very useful for anything related to hydrology and probably other domains too.Use cases include for example computing the
maximum 14-day mean flow (q14max)
, or theminimum 7-day mean flow (q7min)
.Potential Solution
Possible code to be used:
Additional context
No response
Contribution
Code of Conduct
The text was updated successfully, but these errors were encountered: