uxarray.open_mfdataset

Contents

uxarray.open_mfdataset#

uxarray.open_mfdataset(grid_filename_or_obj, paths, chunks=None, chunk_grid=True, use_dual=False, grid_kwargs=None, **kwargs)#

Wraps xarray.open_dataset() to support reading in a grid and multiple data files together.

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

  • paths (string, required) – Either a string glob in the form “path/to/my/files/*.nc” or an explicit list of files to open. It is the same paths in xarray.open_mfdataset.

  • 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.

  • chunk_grid (bool, default: True) – If valid chunks are passed in, determines whether to also apply the same chunks to the attached Grid

  • 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

  • grid_kwargs (dict, optional) – Additional arguments passed on to ux.open_grid when opening up a Grid File.

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

Returns:

object – Dataset with the unstructured grid.

Return type:

uxarray.UxDataset

Examples

Open grid file along with multiple data files (two or more)

>>> import uxarray as ux
  1. Open from an explicit list of dataset files

>>> ux_ds = ux.open_mfdataset(
...     "grid_filename.g", "grid_filename_vortex_1.nc", "grid_filename_vortex_2.nc"
... )
  1. Open from a string glob

>>> ux_ds = ux.open_mfdataset("grid_filename.g", "grid_filename_vortex_*.nc")