uxarray.open_grid

Contents

uxarray.open_grid#

uxarray.open_grid(grid_filename_or_obj, chunks=None, use_dual=False, **kwargs)#

Constructs and returns a Grid from 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. Simiarly, a dictionary containing UGRID variables can be used to create a ux.Grid

  • chunks (int, dict, 'auto' or None, default: None) –

    If provided, used to load the grid into dask arrays. - chunks="auto" will use dask auto chunking taking into account the

    engine preferred chunks.

    • chunks=None skips using dask, which is generally faster for small arrays.

    • chunks=-1 loads 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 – Specify whether to use the primal (use_dual=False) or dual (use_dual=True) mesh if the file type is MPAS

  • **kwargs (Dict[str, Any]) – Additional arguments passed on to xarray.open_dataset. Refer to the [xarray docs](https://xarray.pydata.org/en/stable/generated/xarray.open_dataset.html) for accepted keyword arguments.

Returns:

uxgrid – Initialized ux.Grid object from the provided grid_filename_or_obj

Return type:

uxarray.Grid

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)