Skip to content
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

improved RollingFunctions.jl integration #851

Closed
simeonschaub opened this issue Nov 7, 2024 · 7 comments
Closed

improved RollingFunctions.jl integration #851

simeonschaub opened this issue Nov 7, 2024 · 7 comments

Comments

@simeonschaub
Copy link
Contributor

RollingFunctions.jl already works with AbstractDimArrays, but unfortunately the dimension is lost in the process. Python's xarray has a method rolling which keeps the original dimensions of the array and even has a particularly useful center argument to specify that the labels should be set at the center of the window.
It also supports a dim argument which RollingFunctions.jl doesn't have AFAIK, but I'm thinking that this might not be necessary and with #850, one could just use eachslice for this.
Would it be reasonable to add an extension here supporting such a use case?

@lazarusA
Copy link
Collaborator

lazarusA commented Nov 7, 2024

mmm... I thought this was covered by https://rafaqz.github.io/DimensionalData.jl/stable/groupby#binning and https://rafaqz.github.io/DimensionalData.jl/stable/groupby#Select-by-Dimension, maybe we could show it more, if indeed is the same.

@simeonschaub
Copy link
Contributor Author

IIUC binning is not the same as applying a rolling function though, since bins are disjoint whereas the point of rolling functions is that there are sliding windows that overlap.

@lazarusA
Copy link
Collaborator

lazarusA commented Nov 8, 2024

well, for moving windows (xarray-like) we have this in yaxarrays, but is not documented yet.

JuliaDataCubes/YAXArrays.jl#459

@rafaqz
Copy link
Owner

rafaqz commented Nov 8, 2024

I was thinking we needed an extension, but actually Stencils.jl doesn't and still returns a DimArray;

https://github.com/rafaqz/Stencils.jl/blob/main/test%2Farray.jl#L170-L172

So this is a RollingFunctions.jl problem. To fix it generically for all input array types, they probably need to use similar to generate the output array from the input, and then write into it.

@rafaqz
Copy link
Owner

rafaqz commented Nov 8, 2024

This is what Stencils does:

https://github.com/rafaqz/Stencils.jl/blob/main/src%2Fmapstencil.jl#L28-L31

They can just copy that and the tests

@simeonschaub
Copy link
Contributor Author

well, for moving windows (xarray-like) we have this in yaxarrays, but is JuliaDataCubes/YAXArrays.jl#459 yet.

JuliaDataCubes/YAXArrays.jl#459

I looked into this, but the mapCubes API seems very complex for simply calculating a rolling mean

@simeonschaub
Copy link
Contributor Author

I ended up creating my own package in https://github.com/simeonschaub/RollingWindowArrays.jl for rolling window operations since I wasn't really satisfied with RollingFunctions.jl because its implementation is quite complex and hard to extend. I think this issue can probably be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants