pymech.dataset¶
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 dataset.py¶
- pymech.dataset.open_dataset(path, **kwargs)[source]¶
Helper function for opening a file as an
xarray.Dataset.
- pymech.dataset.open_mfdataset(paths: str | NestedSequence[str | os.PathLike], chunks: T_Chunks | None = 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 | None = '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. Seexarray.open_mfdataset()for documentation on parameters.
Note
See usage for more details.