shnitsel.io.shnitsel#
Submodules#
Functions#
|
Opens a NetCDF4 file saved by shnitsel-tools, specially interpreting certain attributes. |
|
Function to write a trajectory in Shnitsel format (xr.) to a ntcdf hdf5 file format. |
Package Contents#
- read_shnitsel_file(path, loading_parameters=None)#
Opens a NetCDF4 file saved by shnitsel-tools, specially interpreting certain attributes.
- Parameters:
path (PathOptionsType) – The path of the file to open.
loading_parameters (LoadingParameters, optional) – Parameter settings for e.g. standard units or state names.
- Returns:
An
xarray.Datasetwith any MultiIndex restored. AShnitselDBwith any MultiIndex restored and attributes decoded.- Return type:
xr.Dataset | xr.DataTree | None
- Raises:
FileNotFoundError – If there is is nothing at
path, orpathis not a file.ValueError (or other exception) – Raised by the underlying h5netcdf engine if the file is corrupted.
- write_shnitsel_file(dataset, savepath, complevel=9)#
Function to write a trajectory in Shnitsel format (xr.) to a ntcdf hdf5 file format.
Strips all internal attributes first to avoid errors during writing. When writing directly with to_netcdf, errors might occur due to internally set attributes with problematic types.
- Parameters:
dataset (xr.Dataset | xr.DataArray | ShnitselDataset | SupportsToXrConversion | TreeNode[Any, xr.Dataset | xr.DataArray | SupportsToXrConversion]) – The dataset or trajectory to write (omit if using accessor).
savepath (PathOptionsType) – The path at which to save the trajectory file.
complevel (int, optional) – The compression level to apply during saving, by default 9
- Returns:
Returns the result of the final call to xr.Dataset.to_netcdf() or xr.DataTree.to_netcdf()
- Return type:
Unknown