shnitsel.core.postprocess¶
Attributes¶
Classes¶
Functions¶
|
Calculate the 2-norm of a DataArray, reducing the dimension with dame dim |
|
Calculate all possible pairwise differences over a given dimension |
|
PCA-reduced pairwise interatomic distances |
|
Take successive differences along the 'frame' dimension |
|
Find in which frames the active state changes |
|
Get PCA points and info on which of them represent hops |
|
|
|
Performs several frequent setup tasks. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Fast way to calculate populations |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Calculate all dihedral angles between the atoms specified. |
|
|
|
|
|
Example usage: trajs_with_hops(frames['astate']) |
|
Example usage: |
|
|
|
|
|
|
|
|
|
|
|
|
|
Module Contents¶
- type Astates = xr.DataArray¶
- type AtXYZ = xr.DataArray¶
- type DimName = Hashable¶
- type Frames = xr.Dataset¶
- type PerState = xr.Dataset¶
- type InterState = xr.Dataset¶
- _var_delta_t_msg = '`delta_t` varies between the trajectories. Please separate the trajectories into groups'¶
- norm(da, dim='direction', keep_attrs=None)¶
Calculate the 2-norm of a DataArray, reducing the dimension with dame dim
- Parameters:
da (xarray.DataArray) – Array to calculate the norm of
dim (DimName) – Dimension to calculate norm along (and therby reduce), by default ‘direction’
optional – Dimension to calculate norm along (and therby reduce), by default ‘direction’
keep_attrs (bool | str | None) – How to deal with attributes; passed to xr.apply_ufunc, by default None
optional – How to deal with attributes; passed to xr.apply_ufunc, by default None
- Return type:
A DataArray with dimension dim reduced
- subtract_combinations(da, dim, labels=False)¶
Calculate all possible pairwise differences over a given dimension
- Parameters:
da (xarray.DataArray) – Input DataArray; must contain dimension dim
dim (DimName) – Dimension (of size $n$) to take pairwise differences over
labels (bool) – If True, label the pairwise differences based on the index of dim, by default False
optional – If True, label the pairwise differences based on the index of dim, by default False
- Return type:
A DataArray with the dimension dim replaced by a dimension ‘`dim`comb’ of size $n(n-1)/2$
- pairwise_dists_pca(atXYZ, **kwargs)¶
PCA-reduced pairwise interatomic distances
- Parameters:
atXYZ (AtXYZ) – A DataArray containing the atomic positions; must have a dimension called ‘atom’
- Returns:
A DataArray with the same dimensions as atXYZ, except for the ‘atom’
dimension, which is replaced by a dimension ‘PC’ containing the principal
components (by default 2)
- Return type:
- sudi(da)¶
Take successive differences along the ‘frame’ dimension
- Parameters:
da (xarray.DataArray) – An
xarray.DataArray
with a ‘frame’ dimension corresponding to apandas.MultiIndex
of which the innermost level is ‘time’.- Returns:
An
xarray.DataArray
with the same shape, dimension names etc.,but with the data of the (i)th frame replaced by the difference between
the original (i+1)th and (i)th frames, with zeros filling in for both the
initial frame and any frame for which time = 0, to avoid taking differences
between the last and first frames of successive trajectories.
- Return type:
- hop_indices(astates)¶
Find in which frames the active state changes
- Parameters:
astates (xarray.DataArray) – A DataArray of state indicators
- Return type:
A boolean DataArray indicating whether a hop took place
- pca_and_hops(frames)¶
Get PCA points and info on which of them represent hops
- Parameters:
frames (xarray.Dataset) – A Dataset containing ‘atXYZ’ and ‘astate’ variables
- Returns:
pca_res – The PCA-reduced pairwise interatomic distances
hops_pca_coords – pca_res filtered by hops, to facilitate marking hops when plotting
- Return type:
- relativize(da, **sel)¶
- Parameters:
da (xarray.DataArray)
- Return type:
- setup_frames(ds, *, to_time=None, convert_to_eV=None, convert_e_kin_to_eV=None, relativize_energy=None, relativize_selector=None)¶
Performs several frequent setup tasks. Each task can be skipped (by setting the corresponding parameter to False), carried out if appropriate (None), or forced in the sense that an error is thrown if the task is redundant (True).
- Parameters:
ds (xarray.Dataset) – The frames-like xr.Dataset to setup.
to_time (bool | None) – Whether to convert a ‘ts’ (timestep) coordinate to a ‘time’ coordinate, by default None
optional – Whether to convert a ‘ts’ (timestep) coordinate to a ‘time’ coordinate, by default None
convert_to_eV (bool | None) – Whether to convert the ‘energy’ variable to eV, by default None
optional – Whether to convert the ‘energy’ variable to eV, by default None
convert_e_kin_to_eV (bool | None) – Whether to convert the ‘e_kin’ (kinetic energy) variable to eV, by default None
optional – Whether to convert the ‘e_kin’ (kinetic energy) variable to eV, by default None
relativize_energy (bool | None) – Whether to relativize energies, by default None
optional – Whether to relativize energies, by default None
relativize_selector – This argument is passed to relativize, by default None
optional – This argument is passed to relativize, by default None
- Return type:
A modified frames-like xr.Dataset
- Raises:
ValueError – If a task should be forced (i.e. the corresponding parameter is set to True) but cannot be carried out (e.g. because the dataset was already processed previously)
- class Converter(quantity, conversions)¶
- __name__ = 'convert_Uninferable'¶
- quantity¶
- conversions¶
- targets¶
- __call__(da, to)¶
- Parameters:
da (xarray.DataArray)
to (str)
- Return type:
- convert_energy¶
- convert_forces¶
- convert_dipoles¶
- convert_length¶
- validate(frames)¶
- Parameters:
frames (Frames)
- Return type:
- ts_to_time(data, delta_t=None, old='drop')¶
- Parameters:
data (xarray.Dataset | xarray.DataArray)
delta_t (float | None)
old (Literal['drop', 'to_var', 'keep'])
- Return type:
- keep_norming(da, exclude=None)¶
- Parameters:
da (xarray.DataArray)
exclude (Collection[DimName] | None)
- Return type:
- _get_fosc(energy, dip_trans)¶
- get_fosc(energy, dip_trans)¶
- assign_fosc(ds)¶
- Parameters:
ds (xarray.Dataset)
- Return type:
- broaden_gauss(E, fosc, agg_dim='frame', *, width=0.5, nsamples=1000, xmax=None)¶
- Parameters:
E (xarray.DataArray) – values used for the x-axis, presumably $E_i$
fosc (xarray.DataArray) – values used for the y-axis, presumably $f_mathrm{osc}$
agg_dim (DimName) – dimension along which to aggregate the many Gaussian distributions, by default ‘frame’
optional – dimension along which to aggregate the many Gaussian distributions, by default ‘frame’
width (float) – the width (i.e. 2 standard deviations) of the Gaussian distributions used, by default 0.001
optional – the width (i.e. 2 standard deviations) of the Gaussian distributions used, by default 0.001
nsamples (int) – number of evenly spaced x-values over which to sample the distribution, by default 1000
optional – number of evenly spaced x-values over which to sample the distribution, by default 1000
xmax (float | None) – the maximum x-value, by default 3 standard deviations beyond the pre-broadened maximum
optional – the maximum x-value, by default 3 standard deviations beyond the pre-broadened maximum
- Return type:
- ds_broaden_gauss(ds, width=0.5, nsamples=1000, xmax=None)¶
- Parameters:
ds (xarray.Dataset)
width (float)
nsamples (int)
xmax (float | None)
- Return type:
- get_per_state(frames)¶
- Parameters:
frames (Frames)
- Return type:
PerState
- get_inter_state(frames)¶
- Parameters:
frames (Frames)
- Return type:
InterState
- calc_pops(frames)¶
Fast way to calculate populations Requires states ids to be small integers
- Parameters:
frames (Frames)
- Return type:
- calc_ci(a, confidence=0.95)¶
- Parameters:
a (numpy.typing.NDArray)
confidence (float)
- Return type:
numpy.typing.NDArray
- ci_agg_last_dim(a, confidence=0.95)¶
- xr_calc_ci(a, dim, confidence=0.95)¶
- Parameters:
a (xarray.DataArray)
dim (DimName)
confidence (float)
- Return type:
- time_grouped_ci(x, confidence=0.9)¶
- Parameters:
x (xarray.DataArray)
confidence (float)
- Return type:
- dnorm(a)¶
- dcross(a, b)¶
- ddot(a, b)¶
- angle_(a, b)¶
- normal(a, b, c)¶
- dihedral_(a, b, c, d)¶
- full_dihedral_(a, b, c, d)¶
- dihedral(atXYZ, i, j, k, l, *, deg=False, full=False)¶
Calculate all dihedral angles between the atoms specified. The atoms specified needed be bonded.
- Parameters:
atXYZ (AtXYZ) – A
DataArray
of coordinates, withatom
anddirection
dimensionsi (int) – The four atom indices
j (int) – The four atom indices
k (int) – The four atom indices
l (int) – The four atom indices
deg (bool) – Whether to return angles in degrees (True) or radians (False), by default False
full (bool) – Whether to return signed angles between -180° and 180° (True) or unsigned angles between 0 and 180° (False), by default False
- Return type:
A
DataArray
containing dihedral angles
- angle(atXYZ, i, j, k, *, deg=False)¶
- Parameters:
- Return type:
- distance(atXYZ, i, j)¶
- Parameters:
- Return type:
- trajs_with_hops(astates)¶
Example usage: trajs_with_hops(frames[‘astate’])
- Parameters:
astates (Astates)
- Return type:
list[Hashable]
- get_hop_types(astates)¶
Example usage:
- pick_statecombs(da, statecombs, frames, framedim='frame')¶
- Parameters:
da (xarray.DataArray)
statecombs (xarray.DataArray)
frames (Frames)
framedim (DimName)
- Return type:
- find_traj_hops(traj)¶
- Parameters:
traj (xarray.Dataset)
- Return type:
- find_hops(frames)¶
- Parameters:
frames (Frames)
- Return type:
Frames
- set_atom_props(mol, **kws)¶
- to_mol(atXYZ_frame, charge=None, covFactor=1.2, to2D=True, molAtomMapNumber=None, atomNote=None, atomLabel=None)¶
- Return type:
rdkit.Chem.Mol
- default_mol(obj)¶
- Return type:
rdkit.Chem.Mol