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:
(PathOptionsType) (path) – The path of the file to open.
(LoadingParameters (loading_parameters)
optional) (Parameter settings for e.g. standard units or state names.)
path (shnitsel.io.helpers.PathOptionsType)
loading_parameters (shnitsel.io.helpers.LoadingParameters | None)
- Returns:
An
xarray.Datasetwith any MultiIndex restored.A
ShnitselDBwith any MultiIndex restored and attributes decoded.
- 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.
- Return type:
- 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 | Trajectory | ShnitselDB) – 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.
- Returns:
Returns the result of the final call to xr.Dataset.to_netcdf() or xr.DataTree.to_netcdf()
- Return type:
Unknown