uxarray.open_grid#
- uxarray.open_grid(grid_filename_or_obj, chunks=None, use_dual=False, **kwargs)#
Constructs and returns a
Gridfrom a grid file.- Parameters:
grid_filename_or_obj (str | os.PathLike[Any] | dict | xr.dataset) – Strings and Path objects are interpreted as a path to a grid file. Xarray Datasets assume that each member variable is in the UGRID conventions and will be used to create a
ux.Grid. Similarly, a dictionary containing UGRID variables can be used to create aux.Gridchunks (int, dict, 'auto' or None, default: None) –
If provided, used to load the grid into dask arrays.
chunks="auto"will use daskautochunking taking into account the engine preferred chunks.chunks=Noneskips using dask, which is generally faster for small arrays.chunks=-1loads the data with dask using a single chunk for all arrays.chunks={}loads the data with dask using the engine’s preferred chunk size, generally identical to the format’s chunk size. If not available, a single chunk for all arrays.
See dask chunking for more details.
use_dual (bool, optional) – Specify whether to use the primal (use_dual=False) or dual (use_dual=True) mesh if the file type is MPAS
**kwargs – Additional arguments passed on to
xarray.open_dataset. Refer to thexarray docsfor accepted keyword arguments.
- Returns:
uxgrid – Initialized
ux.Gridobject from the providedgrid_filename_or_obj- Return type:
Examples
>>> import uxarray as ux
Open a grid from a file path
>>> uxgrid = ux.open_grid("grid_filename.nc")
Lazily load grid variables using Dask
>>> uxgrid = ux.open_grid("grid_filename.nc", chunks=-1)