-
Notifications
You must be signed in to change notification settings - Fork 71
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Addressing a Problem?
Currently filter_events resamples the data (if freq is provided) before looking for events by default.
If using yearly frequency this can cut a valid event in half.
For other rle there is the resampel_before_rl option to account for this - although this only covers the cases in which the actual data is not required.
It would be nice to have this consistent so that windowed_run_count functionality matches the find_event.mean(dim="event").event_length even when windowed_run_count is using:
cond = xarray.DataArray(
np.array(
[
[False, False, True, True, False, True, True, True, False, False],
[True, True, True, True, True, False, False, False, False, False],
]
).T,
dims=["time", "lat"],
coords={
"time": xarray.date_range("1999-12-30", periods=10, freq="D"),
"lat": [40.0, 41.0],
},
)
data = xarray.DataArray(
np.array(
[
[26, 26, 31, 31, 20, 26, 31, 31, 20, 20],
[26, 26, 26, 26, 26, 20, 20, 20, 20, 20],
]
).T,
dims=["time", "lat"],
coords={
"time": xarray.date_range("1999-12-30", periods=10, freq="D"),
"lat": [40.0, 41.0],
},
attrs={"units": "degC"},
)
window = 3
freq = "YS"
events = rl.find_events(
cond,
window=window,
freq=freq,
data=data,
)
event_mean = events.mean(dim="event")
out = rl.resample_and_rl(
cond,
resample_before_rl=False,
compute=rl.windowed_run_count,
window=window,
freq=freq,
)
print(event_mean.event_length.values)
print(out.values)These values are not equal and to my knowledge can currently not be aligned.
They are equal when resampe_before_rl=True (as expected).
Potential Solution
Adding a resample_before_rl option does not seem to easily work currently.
Any ideas on how to integrate this?
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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request