-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chunked pint arrays break on rolling()
#186
Comments
Another side note that came up here -- I'm curious if there's any roadmap plan for recognizing integration of units for methods like E.g., data = xr.DataArray(range(3), dims='time').pint.quantify('mm/day')
data.pint.units
>>> mm/day
data = data.rolling(time=2).sum()
data.pint.units
>>> mm |
thanks for the report, @riley-brady. It seems that np.pad(magnitude, pad_width, mode="constant", constant_values=np.array(0))
@jrbourbeau, what do you think? Would it make sense to extend |
I'm not sure I follow. Why would data = xr.DataArray(
range(3), dims="time", coords={"time2": ("time", [1, 2, 3])}
).pint.quantify("mm/day", time="day")
dt = data.time2.pad(time=(1, 0)).diff(dim="time")
data.rolling(time=2).sum() * dt and then you would have the correct units (with the same numerical result, because I chose the time coordinate to have increments of |
Thanks for the quick feedback on this issue @keewis. Also thanks for the demo with |
this should be fixed in |
Hi folks,
I noticed that when running
.rolling(...)
on a chunkedpint
array, there is an exception raised that breaks the process:I outline three different cases below for running
.rolling()
on apint
-awareDataArray
.pint
array.xr.set_options(use_bottleneck=False)
preserves units(Rolling mean on dask array does not preserve dtype pydata/xarray#7062 (comment)).
pint
array, usingxarray
chunking.bottleneck
. However, this isn't an optimal solution for me, since one cannot queryds.pint.units
on anxarray
-chunkedpint
array. I like being able to do that for various QOL checks in a data pipeline.pint
array chunked withds.pint.chunk(...)
.bottleneck
.My solution in the interim is to do something like:
The text was updated successfully, but these errors were encountered: