shnitsel#

Submodules#

Functions#

write_shnitsel_file(dataset, savepath[, complevel])

Function to write a trajectory in Shnitsel format (xr.) to a ntcdf hdf5 file format.

write_ase_db(traj, db_path[, db_format, ...])

Function to write a Dataset into a ASE db in either SchNet or SPaiNN format.

Package Contents#

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

write_ase_db(traj, db_path, db_format=None, keys_to_write=None, preprocess=True, force=False)#

Function to write a Dataset into a ASE db in either SchNet or SPaiNN format.

Parameters:
  • traj (xr.Dataset | DataSeries | TreeNode[Any, DataSeries | xr.Dataset]) – The Dataset to be written to an ASE db style database. Can also be in tree format. If provided as a tree, the data must be consistent with each other, i.e. all coordinates except for the leading dimension must match. Inconsistencies

  • db_path (str) – Path to write the database to

  • db_format (Literal["schnet", "spainn";] | None, optional) – Format of the target database. Used to control order of dimensions in data arrays. Can be either “schnet” or “spainn”.

  • keys_to_write (Collection | None, optional) – Optional parameter to restrict which data variables to . Defaults to None.

  • preprocess (bool, optional) – Whether to apply preprocessing of the data. Defaults to True.

  • force (bool, optional) – A flag to force overwriting of an existing database at the position denoted by db_path.

Raises:
  • ValueError – If neither frame nor time dimension is present on the dataset.

  • ValueError – If an unsupported data type was provided as an input.

  • ValueError – If the db_format is neither schnet, spainn nor None

  • ValueError – If the data in a provided tree is inconsistent.

Notes

See https://spainn-md.readthedocs.io/en/latest/userguide/data_pipeline.html#generate-a-spainn-database for details on SPaiNN format.