You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ux.open_dataset() should crash when grid and data are not aligned #1853
Calling ux.open_dataset(grid_indicator, data_indicator) silently succeeds when the data in data_indicator is not aligned with the grid in grid_indicator, e.g. if the data and grid have different shapes. The indicators could be file paths or they could be xarray Datasets.
What did you expect to happen?
I expected ux.open_dataset to crash (probably with a GridsMismatchError?) when the data is not aligned with the grid.
A fix to this issue should also consider the case of opening a UxDataset with arrays on different grids:
arrA=ux.tutorial.open_dataset('quad-hexagon')['t2m']
arrB=ux.tutorial.open_dataset('outCSne30-vortex')['psi']
ux.UxDataset({'A': arrA, 'B': arrB}, uxgrid=arrA.uxgrid)
This currently raises an xr.AlignmentError, but it would probably be more instructive to raise a ux.GridsMismatchError instead.
Additionally, leaning on xarray here without comparing grids directly fails to account for the case of same-sized grids with different contents. The following silently succeeds, but it should almost certainly crash with a ux.GridsMismatchError instead.
arrB_iseled=arrB.isel(n_face=range(arrA.sizes['n_face']))
ux.UxDataset({'A': arrA, 'B': arrB_iseled}, uxgrid=arrA.uxgrid)
Similarly, this also silently succeeds but it should almost certainly fail with ux.GridsMismatchError instead:
Activity
Sevans711 commentedon Nov 9, 2026
A fix to this issue should also consider the case of opening a UxDataset with arrays on different grids:
This currently raises an xr.AlignmentError, but it would probably be more instructive to raise a ux.GridsMismatchError instead.
Additionally, leaning on xarray here without comparing grids directly fails to account for the case of same-sized grids with different contents. The following silently succeeds, but it should almost certainly crash with a ux.GridsMismatchError instead.
Similarly, this also silently succeeds but it should almost certainly fail with ux.GridsMismatchError instead: