shnitsel.plot

Classes

Datasheet

Functions

biplot_kde(frames[, at1, at2, at3, at4, geo_filter, ...])

Generates a biplot that visualizes PCA projections and kernel density estimates (KDE)

plot_cdf_for_kde(z, level[, ax])

show_atom_numbers(atXYZ[, charge, covFactor, to2D])

ski_plots(spectra)

Plot spectra for different times on top of each other,

pcm_plots(spectra)

Represent fosc as colour in a plot of fosc against time and energy.

Package Contents

class Datasheet(frames=None, *, path=None, copy_data=None, spectra_times=None, col_state=None, col_inter=None)
Parameters:
frames = None
can
spectra_times: list[int | float] | numpy.ndarray | None
charge: int = 0
structure_skeletal: bool = False
name: str = ''
_copy_data(old)
Parameters:

old (Self)

property per_state
property inter_state
property pops
property delta_E
property fosc_time
property spectra
property spectra_groups
property spectra_ground
property spectra_excited
property noodle
property hops
property structure_atXYZ
property mol
property mol_skeletal
property smiles
property inchi
calc_all()
plot_per_state_histograms(fig=None)
Parameters:

fig (matplotlib.figure.Figure | None)

plot_timeplots(fig=None)
Parameters:

fig (matplotlib.figure.Figure | None)

plot_separated_spectra_and_hists(fig=None)
Parameters:

fig (matplotlib.figure.Figure | None)

plot_separated_spectra_and_hists_groundstate(fig=None, scmap=plt.get_cmap('turbo'))
Parameters:

fig (matplotlib.figure.Figure | None)

plot_nacs_histograms(fig=None)
Parameters:

fig (matplotlib.figure.Figure | None)

plot_noodle(fig=None)
Parameters:

fig (matplotlib.figure.Figure | None)

plot_structure(fig=None)
Parameters:

fig (matplotlib.figure.Figure | None)

static get_subfigures(include_per_state_hist=False, borders=False)
Parameters:
  • include_per_state_hist (bool)

  • borders (bool)

plot(include_per_state_hist=False, borders=False, consitent_lettering=True)
Parameters:
  • include_per_state_hist (bool)

  • borders (bool)

  • consitent_lettering (bool)

_test_subfigures(include_per_state_hist=False, borders=False)
Parameters:
  • include_per_state_hist (bool)

  • borders (bool)

biplot_kde(frames, at1=0, at2=1, at3=None, at4=None, geo_filter=None, levels=None, scatter_color='time', fill=True)

Generates a biplot that visualizes PCA projections and kernel density estimates (KDE) of a property (distance, angle, dihedral angle) describing the geometry of specified atoms. The property is chosen based on the number of atoms specified:

  • 2 atoms => distance

  • 3 atoms => angle

  • 4 atoms => dihedral angle

Parameters:
  • frames – A dataset containing trajectory frames with atomic coordinates.

  • at1 (int) – Indices of the first, second, third and fourth atoms for geometric property calculation.

  • at2 (int) – Indices of the first, second, third and fourth atoms for geometric property calculation.

  • at3 (int | None) – Indices of the first, second, third and fourth atoms for geometric property calculation.

  • at4 (int | None) – Indices of the first, second, third and fourth atoms for geometric property calculation.

  • geo_filter (list[tuple[float, float]] | None) – A list of tuples representing ranges. A KDE is plotted for each range, indicating the distribution of points for which the value of the geometry feature falls in that range.

  • levels (int | list[float] | None) – Contour levels for the KDE plot. Defaults to [0.08, 1]. This parameter is passed to matplotlib.axes.Axes.contour.

  • scatter_color (Literal['time', 'geo']) – Must be one of ‘time’ or ‘geo’. If ‘time’, the scatter-points will be colored based on the time coordinate; if ‘geo’, the scatter-points will be colored based on the relevant geometry feature (see above).

  • fill (bool) – Whether to plot filled contours (fill=True, uses ax.contourf) or just contour lines (fill=False, uses ax.contour).

Returns:

The computed KDE data for the atom-atom distance distribution.

Return type:

kde_dat

Notes

  • Computes a geometric property of the specified atoms across all frames.

  • Uses kernel density estimation (KDE) to analyze the distance distributions.

  • Performs PCA on trajectory pairwise distances and visualizes clustering of structural changes.

  • Produces a figure with PCA projection, cluster analysis, and KDE plots.

plot_cdf_for_kde(z, level, ax=None)
show_atom_numbers(atXYZ, charge=None, covFactor=1.5, to2D=True)
ski_plots(spectra)

Plot spectra for different times on top of each other, along with a dashed line that tracks the maximum. One plot per statecomb; plots stacked vertically. Expected to be used on data produced by spectra3d.spectra_all_times.

Parameters:

spectra (xarray.DataArray) – DataArray containing fosc values organized along ‘energy’, ‘time’ and ‘statecomb’ dimensions.

Return type:

Figure object corresponding to plot.

Examples

>>> from shnitsel.core import xrhelpers as xh, postprocess as P
>>> from shnitsel.core.plot import spectra3d
>>> spectra_data = (
        xh.open_frames(path)
        .pipe(P.get_inter_state)
        .pipe(P.assign_fosc)
        .pipe(spectra3d.spectra_all_times))
>>> spectra3d.ski_plots(spectra_data)
pcm_plots(spectra)

Represent fosc as colour in a plot of fosc against time and energy. The colour scale is logarithmic. One plot per statecomb; plots stacked horizontally. Expected to be used on data produced by spectra3d.spectra_all_times.

Parameters:

spectra (xarray.DataArray) – DataArray containing fosc values organized along ‘energy’, ‘time’ and ‘statecomb’ dimensions.

Return type:

Figure object corresponding to plot.

Examples

>>> from shnitsel.core import xrhelpers as xh, postprocess as P
>>> from shnitsel.core.plot import spectra3d
>>> spectra_data = (
        xh.open_frames(path)
        .pipe(P.get_inter_state)
        .pipe(P.assign_fosc)
        .pipe(spectra3d.spectra_all_times))
>>> spectra3d.pcm_plots(spectra_data)