shnitsel.io.ase.parse

Attributes

dummy_leading_dim

multi_level_prefix

Functions

shapes_from_metadata(db_meta[, db_format])

Function to assign shapes based on the chosen db_format and potential information in the metadata of a database.

_json_deserialize_ndarray(value)

apply_dataset_meta_from_db_metadata(dataset, db_meta, ...)

Apply attributes from db metadata and perform some validation checks on the result.

read_ase(db_path[, db_format, loading_parameters])

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

Module Contents

dummy_leading_dim: str = 'leading_dim_unknown'
multi_level_prefix: str = '_MultiIndex_levels_for_'
shapes_from_metadata(db_meta, db_format=None)

Function to assign shapes based on the chosen db_format and potential information in the metadata of a database.

If conflicting information on the db_format is provided and present in the database, en error will be raised.

Parameters:
  • db_meta (dict) – The metadata dict of an ASE database.

  • db_format (Literal['spainn', 'schnet'] | None, optional) – The requested format of the database. Defaults to None.

Returns:

Dict of data_var shapes dict[str, list[str]]: Dict of coordinate shapes str: The name of the leading dimension. Should be frame or time, but can be leading_dim_unknown if unknown

Return type:

dict[str, list[str]]

Raises:

ValueError – If a db_format of database was requested that conflicts with the format of the database.

_json_deserialize_ndarray(value)
Parameters:

value (str)

Return type:

Any

apply_dataset_meta_from_db_metadata(dataset, db_meta, default_attrs)

Apply attributes from db metadata and perform some validation checks on the result.

Loads remaining missing coordinate variables from db metadata if available. Checks size of resulting dimensions if specified in db metadata. Further initializes the multi indices if specified in the metadata.

Parameters:
  • dataset (Trajectory) – Trajectory dataset parsed from ASE db

  • db_meta (dict) – Metadata from the trajectory db file

  • default_attrs (dict) – Attributes to apply to variables by default

Returns:

Dataset with attributes set from from db metadata and dimension sizes asserted

Return type:

Trajectory

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

Return type:

An xr.Dataset of frames

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