-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
rolling.construct alignment #3671
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
Comments
Small update: I was currently using:
but this was performing quite badly for larger arrays. However after having a look at
I saw that However, if you want to add strides to the 'Strided rolling' (#3607) it would be nice to still be able to create rolling windows that start at index 0. By the way: feel free to close this issue, if you do not see a need for an alignment option. |
Hi @mark-boer for raising an issue. In [81]: arr = xr.DataArray(np.arange(4), dims=("x",))
...: arr.rolling(x=2).construct("roll_x").isel(x=slice(1, None, 2))
Out[81]:
<xarray.DataArray (x: 2, roll_x: 2)>
array([[0., 1.],
[2., 3.]])
Dimensions without coordinates: x, roll_x |
Hi @fujiisoup, thx for your response. That is exactly what I needed and what I used to do. But I mistakenly thought that there was a performance penalty to doing this. But the performance decrease turned out to be the result of the order in which I rolled and sliced. |
Yes, Line 242 in ff75081
|
Uh oh!
There was an error while loading. Please reload this page.
Hello xarray team
I was trying to implement functionality similar to Scikit Image's view_as_windows, but I was having a hard time with the boundary conditions. I understand this request is very similar to rolling with periodic boundary conditions #2007.
MCVE Code Sample
Expected Output
It would be nice to be able to easily get an output of:
Possible workarounds
With the upcoming features of pad (#3596) and rolling: periodic (#2011) it is actually not that hard to work around with:
Idea
Would it be possible to add a keyword argument to either
rolling()
orconstruct()
that expects an alignment of "left", "right" or "center". I understand that this could break interface copied from Pandas, but I hope it could be useful to others as well.The text was updated successfully, but these errors were encountered: