shnitsel.io.sharc.parse_trajectory

Functions

read_traj(traj_path[, loading_parameters])

Function to read a single SHARC trajectory directory

parse_output_settings(f)

Function to parse settings from the output.dat file as far as they are available.

parse_output_listings(path)

Function to parse settings from the output.lis file as far as they are available.

parse_output_log(f)

Function to parse settings from the output.log file as far as they are available.

parse_trajout_dat(f, trajectory_in[, loading_parameters])

Function to parse the contents of an 'output.dat' in a sharc trajectory output directory into a Dataset.

parse_trajout_xyz(nsteps, f)

Read atom names, atom numbers and positions for each time step up until a maximum of nsteps from an output.xyz file and returm them.

parse_input_settings(input_lines)

Function to parse settings from the input file.

Module Contents

read_traj(traj_path, loading_parameters=None)

Function to read a single SHARC trajectory directory

Parameters:
  • traj_path (PathOptionsType) – The path to load the trajectory form

  • loading_parameters (LoadingParameters | None, optional) – Parameter settings for e.g. standard units or state names.

Returns:

The parsed SHARC directory as a Dataset

Return type:

xr.Dataset

parse_output_settings(f)

Function to parse settings from the output.dat file as far as they are available.

Read settings and other info from the file.

Parameters:

f (TextIOWrapper) – File wrapper providing the output.dat file contents

Returns:

A key-value dictionary, where the keys are the names of the settings

Return type:

Dict[str, Any]

parse_output_listings(path)

Function to parse settings from the output.lis file as far as they are available.

This is used to read the delta_t variable if it hasn’t been set otherwise.

Parameters:

path (pathlib.Path) – Path to the output.lis file.

Returns:

First, a key-value dictionary, where the keys are the names of the settings like delta_t, nsteps and t_max. Then a key_value dictionary with names of variables and their values extracted from the file.

Return type:

Tuple[Dict[str, Any], Dict[str, Any]]

parse_output_log(f)

Function to parse settings from the output.log file as far as they are available.

This is used to read the version of sharc and input settings if unavailable elsewhere.

Parameters:

f (TextIOWrapper) – The file input stream from output.log

Returns:

A key-value dictionary, where the keys are the names of the settings like delta_t, t_max, or version.

Return type:

Dict[str, Any]

parse_trajout_dat(f, trajectory_in, loading_parameters=None)

Function to parse the contents of an ‘output.dat’ in a sharc trajectory output directory into a Dataset.

Parameters:
Raises:

ValueError – Raised if not enough steps are found in the output.dat file

Returns:

A flag to indicate if the full trajectory has been read, the number of steps that acutally were read and the full dataset with unit attributes and further helpful attributes applied.

Return type:

xr.Dataset

parse_trajout_xyz(nsteps, f)

Read atom names, atom numbers and positions for each time step up until a maximum of nsteps from an output.xyz file and returm them.

Parameters:
  • nsteps (int) – The maximum number of steps to be read

  • f (TextIOWrapper) – The input file wrapper providing the contents of an output.xyz file.

Returns:

Tuple of (atom_names, atom_numbers, atom_positions) as numpy arrays. Only atom_positions has the first index indicate the time step, the second the atom and the third the direction. Other entries are 1d arrays.

Return type:

Tuple[np.ndarray, np.ndarray, np.ndarray]

parse_input_settings(input_lines)

Function to parse settings from the input file.

Can be provided the contents of the file as found in the output.log file.

Parameters:

input_lines (List[str]) – The lines of the input file.

Returns:

A key-value dictionary, where the keys are the first words in each line

Return type:

Dict[str, Any]