shnitsel

Submodules

Functions

open_frames(path)

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

read_trajs(path, kind[, pattern, format, parallel, errors])

Read all trajectories from a folder of trajectory folders

read_ase(db_path, kind)

Reads an ASE DB containing data in the SPaiNN or SchNet format

Package Contents

open_frames(path)

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

Parameters:

path – The path of the file to open.

Return type:

An xarray.Dataset with any MultiIndex restored.

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.

read_trajs(path, kind, pattern='TRAJ*', format='frames', parallel=True, errors='log')

Read all trajectories from a folder of trajectory folders

Parameters:
  • path (str) – The path to the folder of folders

  • kind (Literal['sharc', 'nx', 'pyrai2md']) – The kind of trajectory, i.e. whether it was produced by SHARC, Newton-X or PyRAI2MD

  • pattern (str) – The search pattern to append to the path (the whole thing will be read by glob.glob()), by default ‘TRAJ*’

  • format (Literal['frames', 'layers']) – Whether to return the trajectories concatenated along the time axis (‘frames’) using a xarray.indexes.PandasMultiIndex or along a new axis (‘layers’), by default ‘frames’

  • parallel (bool) – Whether to read multiple trajectories at the same time (which, in the current implementation, is only faster on storage that allows non-sequential reads), by default False

  • errors (Literal['log', 'raise'])

Return type:

An xarray.Dataset containing the data of the trajectories

Raises:
read_ase(db_path, kind)

Reads an ASE DB containing data in the SPaiNN or SchNet format

Parameters:
  • db_path (str) – Path to the database

  • kind (str) – Must be one of ‘spainn’ or ‘schnet’; determines interpretation of array shapes

Return type:

An xr.Dataset of frames

Raises: