shnitsel.io.ase#

Submodules#

Functions#

read_ase(db_path[, db_format, loading_parameters])

Reads an ASE DB containing data in the SPaiNN or SchNet 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#

read_ase(db_path, db_format=None, loading_parameters=None)#

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

Parameters:
  • db_path (pathlib.Path) – Path to the database

  • db_format (Literal['spainn', 'schnet'] | None, optional) – Must be one of ‘spainn’ or ‘schnet’ or None; determines interpretation of array shapes If None is provided, no shape will be assumed

  • loading_parameters (LoadingParameters) – Potentially configured parameters to overwrite loading behavior

Returns:

An xr.Dataset of frames. Potentially with a time coordinate.

Return type:

xr.Dataset

Raises:
  • ValueError – If db_format is not one of ‘spainn’ or ‘schnet’

  • FileNotFoundError – If db_path is not a file

  • ValueError – If db_path does not contain data corresponding to the format db_format

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.