Skip to content

ux.open_dataset() should crash when grid and data are not aligned #1853

Open

Description

@Sevans711

Version

v2026.10.0

How did you install UXarray?

Source

What happened?

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.

Can you provide a MCVE to repoduce the bug?

import uxarray as ux
gridfile = ux.tutorial.file_path("quad-hexagon", "grid")
datafile = ux.tutorial.file_path("outCSne30-vortex", "data")
ds = ux.open_dataset(gridfile, datafile)
# expected crash; got UxDataset with ds.sizes == {'ncol': 5400},
# ds.uxgrid.sizes == {'n_max_face_nodes': 6, 'n_node': 16, 'n_face': 4}

Activity

  1. added
    bug
    on Oct 27, 2026
  2. moved this from 📚 Backlog to 📝 To-Do in UXarray Developmenton Oct 27, 2026
  3. Sevans711 commented on Nov 9, 2026

    @Sevans711
    CollaboratorAuthor

    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:

    ux.UxDataset({'B': arrB.isel(n_face=range(arrA.sizes['n_face']))}, uxgrid=arrA.uxgrid)
  4. moved this from 📝 To-Do to 🏗 In progress in UXarray Developmenton Nov 16, 2026
  5. self-assigned this
    on Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Fields

Priority

Medium

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions