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: str | NestedSequence[str | os.PathLike], chunks: T_Chunks = None, *, concat_dim: str | DataArray | Index | Sequence[str] | Sequence[DataArray] | Sequence[Index] | None = 'time', compat: CompatOptions = 'no_conflicts', preprocess: Callable[[Dataset], Dataset] | None = None, engine: T_Engine = 'pymech', data_vars: Literal['all', 'minimal', 'different'] | list[str] = 'all', coords='different', combine: Literal['by_coords', 'nested'] = 'nested', parallel: bool = False, join: JoinOptions = 'outer', attrs_file: str | os.PathLike | None = None, combine_attrs: CombineAttrsOptions = 'override', **kwargs) Dataset#

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


See usage for more details.