shnitsel.io.shnitsel

Submodules

Functions

read_shnitsel_file(path[, loading_parameters])

Opens a NetCDF4 file saved by shnitsel-tools, specially interpreting certain attributes.

write_shnitsel_file(dataset, savepath[, complevel])

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.Dataset with any MultiIndex restored.

  • A ShnitselDB with any MultiIndex restored and attributes decoded.

Raises:
  • FileNotFoundError – If there is is nothing at path, or path is not a file.

  • ValueError (or other exception) – Raised by the underlying h5netcdf engine if the file is corrupted.

Return type:

xarray.Dataset | xarray.DataTree

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