-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Slow performance of rolling.reduce #1831
Comments
@fujiisoup - I think this is a great idea. As you've noted, the |
I'm thinking to use the fancy indexing to speed up E.g. for the following In [2]: da
Out [2]:
<xarray.DataArray (x: 4)>
array([0, 1, 2, 3])
Dimensions without coordinates: x a larger array with additional dimension ( <xarray.DataArray (x: 4, x_rolling: 3)>
array([[ nan, 0., 1.],
[ 0., 1., 2.],
[ 1., 2., 3.],
[ 2., 3., nan]])
Dimensions without coordinates: x, x_rolling then reduce along The advantages would be
The disadvantages would be
I think this disadvantage would be solved if we could use |
Yes, I think the stride tricks version would be a significant improvement. See this numpy PR for discussion/examples: numpy/numpy#31 |
Thanks for the information. I think the sliding-and-stack method itself would be also handy. |
Code Sample, a copy-pastable example if possible
Problem description
In
DataArray.rolling
, we index by.isel
method for every window, constructing huge number ofxr.DataArray
instances. This is very inefficient.Of course, we can use bottleneck methods if available, but this provides only a limited functions.
(This also limits possible extensions of rolling, such as ND-rolling (#819), window type (#1142), strides (#819).)
I am wondering if we could skip any sanity checks in our
DataArray.isel -> Variable.isel
path in indexing.Or can we directly construct a single large
DataArray
instead of a lot of smallDataArray
s?The text was updated successfully, but these errors were encountered: