Skip to content

excitations

plot_spectra(energies, osc, bounds=(1, 1500), bins=1000, std=12398.4, kind='gaussian', gamma=12.5, label=None, **kwargs)

Plot the (UV-Vis) spectra.

Parameters:

Name Type Description Default
energies ndarray

excitation energies/bands in nm.

required
osc ndarray

oscillator strengths (dimensionless).

required
Source code in chmpy/ext/excitations.py
def plot_spectra(
    energies,
    osc,
    bounds=(1, 1500),
    bins=1000,
    std=12398.4,
    kind="gaussian",
    gamma=12.5,
    label=None,
    **kwargs
):
    """Plot the (UV-Vis) spectra.

    Args:
        energies (np.ndarray): excitation energies/bands in nm.
        osc (np.ndarray): oscillator strengths (dimensionless).

    """
    import matplotlib.pyplot as plt

    x = np.linspace(bounds[0], bounds[1], bins)
    total = 0
    for e, f in zip(energies, osc):
        if kind == "gaussian":
            peak = add_gaussian_curve_contribution(x, e, f, std)
        else:
            peak = add_lorentz_curve_contribution(x, e, f, std, gamma)
        total += peak

    ax = plt.gca()
    total = total / np.max(total)
    ax.plot(x, total, label=label, **kwargs)
    ax.set_xlabel(r"$\lambda$ (nm)")
    ax.set_ylim(0, 1.1)
    ax.set_ylabel(r"Intensity")
    return ax