helpers#
Attributes#
Classes#
Class to hold certain parameters required at loading time at various points in the reading/ |
|
Class to keep track of a value that may only be assigned once and not overwritten afterwards. |
Functions#
|
Unify the path options to alyways yield a pathlib.Path object |
|
get_triangular - get the upper triangle of a (nstat1 x nstat2 x natoms x 3) matrix |
|
Separates a complete matrix of dipoles into permanent |
|
Function to generate a random id for a path. |
Module Contents#
- PathOptionsType#
- class LoadingParameters#
Class to hold certain parameters required at loading time at various points in the reading/ import pipeline
- error_reporting: Literal['log', 'raise'] = 'log'#
- state_types: shnitsel.core.typedefs.StateTypeSpecifier | List[shnitsel.core.typedefs.StateTypeSpecifier] | Callable[[xarray.Dataset], xarray.Dataset] | None = None#
- state_names: List[str] | Callable[[xarray.Dataset], xarray.Dataset] | None = None#
- logger: logging.Logger | None = None#
- make_uniform_path(path)#
Unify the path options to alyways yield a pathlib.Path object
- Parameters:
path (str | os.PathLike | pathlib.Path | None) – path input of arbitrary type
- Returns:
The converted path
- Return type:
pathlib.Path|None
- Raises:
ValueError – If path was None or could not be converted
- T#
- class ConsistentValue(name='ConsistentValue', weak=False, ignore_none=False)#
Bases:
Generic[T]Class to keep track of a value that may only be assigned once and not overwritten afterwards.
Can be used to check consistency of a value across multiple datasets. The value is written to and read from the property v of the object.
- Raises:
AttributeError – Will be raised if the value is read before first assignment if the object has not been created with
weak=true.ValueError – If an inconsistent value is assigned to this instance, i.e. two different values have been assigned.
- get_triangular(original_array)#
get_triangular - get the upper triangle of a (nstat1 x nstat2 x natoms x 3) matrix
This function takes in a 4-dimensional numpy array (original_array) and returns a 3-dimensional numpy array (upper_tril) which is the upper triangle of the input matrix, obtained by excluding the diagonal elements. The number of steps (k) to move the diagonal above the leading diagonal is 1. The returned matrix has shape (len(cols), natoms, 3)
- Parameters:
original_array (np.ndarray) – 4D numpy array of shape (nstat1, nstat2, natoms, 3) representing the input matrix
- Returns:
upper_tril – 3D numpy array of shape (len(cols), natoms, 3) representing the upper triangle of the input matrix
- Return type:
np.ndarray
- dip_sep(dipoles)#
Separates a complete matrix of dipoles into permanent and transitional dipoles, removing redundancy in the process.
- Parameters:
dipoles (np.ndarray) – 3D numpy array of shape (nstates, nstates, 3) where the first axis represents state before transition, the second axis represents state after transition and the third axis contains x, y and z coordinates.
- Returns:
dip_perm (np.ndarray) – 2D numpy array of shape (nstates, 3)
dip_trans (np.ndarray) – 2D numpy array of shape (math.comb(nstates, 2), 3) in the order e.g. (for nstates = 4) 0->1, 0->2, 0->3, 1->2, 1->3, 2->3 where 0->1 is the transitional dipole between state 0 and state 1.
- Return type:
Tuple[numpy.ndarray, numpy.ndarray]
- random_trajid_assigner(path)#
Function to generate a random id for a path.
- Parameters:
path (pathlib.Path) – Unused: the path we are generating for
- Returns:
the chosen trajectory id
- Return type: