shnitsel.io.newtonx.format_reader#
Attributes#
Classes#
Information to keep track of relevant information for |
|
Class for providing the NewtonX format reading functionality in the standardized FormatReader interface |
Module Contents#
- class NewtonXFormatInformation#
Bases:
shnitsel.io.format_reader_base.FormatInformationInformation to keep track of relevant information for
- nx_log_path: pathlib.Path | None = None#
- positions_file_path: pathlib.Path | None = None#
- DataType#
- _newtonx_default_pattern_regex#
- _newtonx_default_pattern_glob = 'TRAJ*'#
- class NewtonXFormatReader#
Bases:
shnitsel.io.format_reader_base.FormatReaderClass for providing the NewtonX 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. :param path: The path to a directory to check for potential candidate files or subdirectories :type path: PathOptionsType
- 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 NewtonX-style output directory.
Designed for a single input trajectory.
- Parameters:
path (PathOptionsType) – The path to check for NewtonX data
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 matches the NewtonX format
- Return type:
- Raises:
FileNotFoundError – If the path is not a directory.
FileNotFoundError – If path is a directory but does not contain the required NewtonX output files
- read_from_path(path, *, format_info, loading_parameters=None, expect_dtype=None)#
Read a NewtonX-style trajcetory from path at path. Implements FormatReader.read_from_path()
- Parameters:
path (pathlib.Path) – Path to a NewtonX-format directory.
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] | TypeForm[DataType] | None, optional) – An optional parameter to specify the return type. For this class, it should be xr.Dataset, Trajectory or Frames, by default None
- Returns:
The loaded Shnitsel-conforming trajectory.
- Return type:
xr.Dataset | Trajectory | Frames | None
- 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 NewtonX format
- get_units_with_defaults(unit_overrides=None)#
Apply units to the default unit dictionary of the format NewtonX