shnitsel.io.ase.format_reader#

Attributes#

Classes#

ASEFormatInformation

Information to keep track of relevant information for

ASEFormatReader

Class for providing the ASE format reading functionality in the standardized FormatReader interface

Module Contents#

class ASEFormatInformation#

Bases: shnitsel.io.format_reader_base.FormatInformation

Information to keep track of relevant information for

_ase_default_pattern_regex = '*.db'#
_ase_default_pattern_glob = '*.db'#
DataType#
class ASEFormatReader#

Bases: shnitsel.io.format_reader_base.FormatReader

Class for providing the ASE format reading functionality in the standardized FormatReader interface

find_candidates_in_directory(path)#

Function to return a all potential matches for the current file format within a provided directory at path. Parameters

Returns:

  • list[pathlib.Path] – A list of paths that should be checked in detail for whether they represent the format of this FormatReader.

  • None – If no potential candidates were found

Parameters:

path (shnitsel.io.shared.helpers.PathOptionsType)

Return type:

list[pathlib.Path] | None

check_path_for_format_info(path, hints_or_settings=None)#

Check if the path is a ASE-style .db file

Designed for a single input file

Parameters:
  • path (PathOptionsType) – The path to check for being a ASE-style .db file

  • hints_or_settings (dict | None, optional) – Configuration options provided to the reader by the user, by default None

Returns:

The object holding all relevant format information for the path contents if it represents a ASE-style NetCDF file

Return type:

FormatInformation

Raises:
read_from_path(path, *, format_info, loading_parameters=None, expect_dtype=None)#

Read an ASE-style file from path.

Implements FormatReader.read_from_path(). Designed for a single input file.

Parameters:
  • path (pathlib.Path) – Path to an ASE-format .db file.

  • format_info (FormatInformation) – Format information on the provided path that has been previously parsed.

  • loading_parameters (LoadingParameters | None, optional) – Loading parameters to e.g. override default state names, units or configure the error reporting behavior, by default None

  • expect_dtype (type[DataType] | UnionType | None, optional) – An optional parameter to specify the return type. For ASE-style db files, the return type can be either a single frameset (Frames), a trajectory (Trajectory) a collection/list of such sets or a blank xr.Dataset if conversion did not succeed. If for some reason a datatype that is convertible to a Shnitsel-type from arbitrary xr.Dataset containers (SupportsFromXrConversion) is contained within the database, it will be deserialized. This type should specify either the type of the full result or the type of data entries in a hierarchical Shnitsel tree structure.

Returns:

  • xr.Dataset

  • | ShnitselDataset

  • | SupportsFromXrConversion

  • | TreeNode[Any, ShnitselDataset | SupportsFromXrConversion | xr.Dataset]

  • | TreeNode[Any, DataType]

  • | DataType

  • | None – The data stored in the ASE-style file. Can be either a single frameset (Frames), a trajectory (Trajectory) a collection/list of such sets or a blank xr.Dataset if conversion did not succeed. If for some reason a datatype that is convertible to a Shnitsel-type from arbitrary xr.Dataset containers (SupportsFromXrConversion) is contained within the database, it will be deserialized.

Raises:
  • ValueError – Not enough loading information was provided via path and format_info, e.g. if both are None.

  • FileNotFoundError – Path was not found or was not of appropriate ASE-style .db format

Return type:

xarray.Dataset | xarray.DataArray | shnitsel.data.dataset_containers.shared.ShnitselDataset | shnitsel.data.xr_io_compatibility.SupportsFromXrConversion | shnitsel.data.tree.node.TreeNode[Any, shnitsel.data.dataset_containers.shared.ShnitselDataset | shnitsel.data.xr_io_compatibility.SupportsFromXrConversion | xarray.Dataset | xarray.DataArray] | shnitsel.data.tree.node.TreeNode[Any, DataType] | Sequence[xarray.Dataset | shnitsel.data.dataset_containers.shared.ShnitselDataset | shnitsel.data.xr_io_compatibility.SupportsFromXrConversion] | DataType | None

get_units_with_defaults(unit_overrides=None)#

Apply units to the default unit dictionary of the format ASE

Parameters:

unit_overrides (dict[str, str] | None, optional) – Units denoted by the user to override format default settings. Defaults to None.

Raises:

NotImplementedError – The class does not provide this functionality yet

Returns:

The resulting, overridden default units

Return type:

dict[str, str]