Skip to content

ux.open_grid() crashes on files supported by Grid.from_file() #1754

Description

@Sevans711

Version

v2026.09.0

How did you install UXarray?

Source

What happened?

Trying to open a .shp grid file using uxarray.open_grid() fails unexpectedly, with an error stack like:

OSError: [Errno -51] NetCDF: Unknown file format: '~/Code/uxarray/test/meshfiles/shp/cb_2018_us_nation_20m/cb_2018_us_nation_20m.shp' raised from ValueError: did not find a match in any of xarray's currently installed IO backends ['netcdf4', 'scipy'].

Using Grid.from_file() successfully opens the file and returns a Grid object. (I'm a bit suspicious that Grid.from_file() might separately have bug(s) in it, because the resulting object has n_face=82 and n_max_face_nodes = 2999, and plotting it doesn't give results which look like the US…)

What did you expect to happen?

I expected uxarray.open_grid() to default to Grid.from_file() when it gets passed a shapefile or any other file which wouldn't otherwise be supported by is actually supported by Grid.from_file(). That would be the ideal solution. Though, it would also be acceptable to just improve the error message and uxarray.open_grid docstring to clarify, if there's some reason that dispatching to Grid.from_file() automatically it not desirable.

Related: #808

Can you provide a MCVE to repoduce the bug?

import uxarray as ux
import os
UXDIR = ...   # path to uxarray on your machine
GRIFILE = os.path.join(UXDIR, 'test/meshfiles/shp/cb_2018_us_nation_20m/cb_2018_us_nation_20m.shp')
ux.open_grid(GRIDFILE)  # crashes

# this does not crash though:
ux.Grid.from_file(GRIDFILE)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions