-
Notifications
You must be signed in to change notification settings - Fork 8
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
UgridDataArray.weighted
does not preserve grid
#181
Comments
This means the wrapping code is failing: https://github.com/Deltares/xugrid/blob/main/xugrid/core/wrap.py#L59 To explain, any access of a method or attribute on a UgridDataArray or UgridDataset is called within a wrapped context, which checks the result type and reattaches the topology if needed (depends on the resulting dims). It's failing here because the return type of weighted is not a DataArray or Dataset, but rather a DataArrayWeighted object: https://docs.xarray.dev/en/stable/generated/xarray.DataArray.weighted.html Now that you report this: I'm guessing the same problem occurs with
(and probably simlarly so for Dataset.) These are all quite similar in setup. Since they all have the reduction methods defined on them, it may be best to write more wrapping code for them as well, including the grid topologies along the way in a composite object (just like UgridDataArray). This would also be fixed by xarray's explicit indexes, since if we can store the UGRID state in an ordinary index, it will be propagated to the GroupBy and Weighted objects as well. |
Pragmatically: it might be easiest to just overload the methods for now. |
I can confirm that |
When using
UgridDataArray.weighted
, the grid property is lost. It has to be manually re-added. Same forUgridDataset.weighted
.The text was updated successfully, but these errors were encountered: