Interface for reading files as xarray datasets.

Installing pymech also registers as a xarray backend. This means in addition to pymech.dataset.open_dataset(), a file can be directly opened via xarray.open_dataset() as follows:

>>> import xarray as xr
>>> xr.open_dataset("case0.f00001")  # let xarray choose the backend / engine
>>> xr.open_dataset("case0.f00001", engine="pymech")  # or explicitly mention the *engine*

See also

The backend API of xarray and the implementation PymechXarrayBackend (Internals)

The module also provides pymech.dataset.open_mfdataset() to open multiple files and merge into a single dataset. This is a wrapper around xarray.open_mfdataset(), with sane defaults such as merge along time dimension and combine using xarray.combine_nested().

Contents of

pymech.dataset.open_dataset(path, **kwargs)[source]#

Helper function for opening a file as an xarray.Dataset.

  • path (str) – Path to a field file (only Nek files are supported at the moment.)

  • kwargs (dict) – Keyword arguments passed on to the compatible open function.

pymech.dataset.open_mfdataset(paths, chunks=None, *, concat_dim='time', compat='no_conflicts', preprocess=None, engine='pymech', data_vars='all', coords='different', combine='nested', parallel=False, join='outer', attrs_file=None, combine_attrs='override', **kwargs)#

Helper function for opening multiple files as an xarray.Dataset. See xarray.open_mfdataset() for documentation on parameters.


See usage for more details.