uxarray icon indicating copy to clipboard operation
uxarray copied to clipboard

Subsetting fails when a variable has coordinates associated

Open kjnam opened this issue 1 year ago • 0 comments
trafficstars

Version

v2024.06.0

How did you install UXarray?

Conda

What happened?

Subsetting creates a new UxDataArray with a subset data at https://github.com/UXARRAY/uxarray/blob/170e0359b0015c39a5983c24c26255ec99536f91/uxarray/core/dataarray.py#L1085-L1092

When an DataArray has spatially associated coordinates, subsetting fails in xarray's _check_coords_dims because the un-sliced original coordinates, self.coords are given in the DataArray constructor. In the other case, when the original UxDataArray does not have spatially associated coordinates, it passes the check function.

I think this can be fixed by using coordinates from the sliced grid, but this becomes a bit tricky when non-standard topology names are used.

I do not have a small MCVE example to provide. I think one of the test dataset ugrid/geoflow-small can be used after adding coordinates for x and y to a variable.

What did you expect to happen?

A variable with spatial coordinates should be subset successfully by subsetting the corresponding coordinates information before creating a subset dataarray.

Can you provide a MCVE to repoduce the bug?

No response

kjnam avatar Jul 23 '24 18:07 kjnam