Steady-State Spectra API (pymorgan.steadyState)#

Spectrum & SpectrumSeries (pymorgan.steadyState.dataset)#

Steady-state spectra: Spectrum and SpectrumSeries.

These mirror the design of pymorgan.oneD.Dataset1D: a thin object over the raw arrays, formats resolved through a loader registry, and presentation driven by the shared pymorgan.settings.Settings. A Spectrum can be plotted on its own, overlaid as part of a SpectrumSeries, or fed into pymorgan.oneD.Dataset1D.plot_spectra() as a steady-state overlay.

class pymorgan.steadyState.dataset.SpectrumKind(*values)[source]#

Bases: StrEnum

Kind of steady-state measurement: absorption, emission or excitation.

ABSORPTION = 'absorption'#
EMISSION = 'emission'#
EXCITATION = 'excitation'#
class pymorgan.steadyState.dataset.Spectrum(x, y, kind=SpectrumKind.ABSORPTION, *, x_units='nm', label=None, source=None)[source]#

Bases: object

A single steady-state spectrum (one X-Y trace plus metadata).

Parameters:
classmethod from_file(path, kind=SpectrumKind.ABSORPTION, *, data_type='csv', x_units=None, label=None)[source]#

Load a spectrum from path using the loader for data_type.

Parameters:
Return type:

Spectrum

normalised()[source]#

Return a copy scaled so that max(|y|) == 1.

Return type:

Spectrum

normalized()[source]#

Alias for normalised().

Return type:

Spectrum

to_stimulated_emission()[source]#

Return the stimulated-emission spectrum F_stim = F_spont * x^4.

Defined for emission spectra on a wavelength axis. The x^4 factor converts a spontaneous-emission line shape to the stimulated-emission cross-section used when overlaying on transient spectra.

Return type:

Spectrum

as_overlay_dict()[source]#

Return {"X": x, "Y": y} for Dataset1D.plot_spectra().

The raw (uncorrected) data is returned: plot_spectra applies its own smoothing, x^4 emission correction and normalisation to the overlay.

Return type:

dict

plot(ax=None, *, settings=None, label_style=None, normalise=False, normalize=None, **kwargs)[source]#

Plot the spectrum on its own. Extra kwargs go to Axes.plot.

Parameters:
class pymorgan.steadyState.dataset.SpectrumSeries(spectra=None)[source]#

Bases: object

An ordered collection of Spectrum objects, plotted as an overlay.

Parameters:

spectra (Iterable[Spectrum] | None)

spectra: list[Spectrum]#
classmethod from_files(paths, kind=SpectrumKind.ABSORPTION, *, data_type='csv', x_units=None, labels=None)[source]#

Load several spectra into a series.

Parameters:
Return type:

SpectrumSeries

add(spectrum)[source]#

Append a spectrum and return self (chainable).

Parameters:

spectrum (Spectrum)

Return type:

SpectrumSeries

normalised()[source]#

Return a copy in which every spectrum is normalised.

Return type:

SpectrumSeries

normalized()[source]#

Alias for normalised().

Return type:

SpectrumSeries

plot(ax=None, *, settings=None, label_style=None, normalise=False, normalize=None, cmap='rainbow', **kwargs)[source]#

Overlay every spectrum, coloured along cmap with a legend.

Parameters:
pymorgan.steadyState.dataset.load_spectrum(path, kind=SpectrumKind.ABSORPTION, *, data_type='csv', x_units=None, label=None)[source]#

Convenience wrapper for Spectrum.from_file().

Parameters:
Return type:

Spectrum

pymorgan.steadyState.dataset.plot_steady_state(abs_spectrum=None, em_spectrum=None, ax=None, *, settings=None, label_style=None, plot_mode=None, normalise=False, normalize=None, **kwargs)[source]#

Plot steady-state absorption and/or emission spectra.

When both absorption and emission are provided, plot_mode determines the layout: - SteadyStatePlotMode.DOUBLE_Y (default): Absorption on the primary (left) Y-axis,

Emission on a twin (right) Y-axis (via ax.twinx()) sharing the same X-axis.

  • SteadyStatePlotMode.NORMALISED: Both spectra normalised to their maximum (1.0) on a single shared Y-axis.

If only one spectrum is provided, it is drawn on a single axis.

Returns:

The axis (or tuple of (primary_ax, twin_ax)) the spectra were drawn into.

Return type:

matplotlib.axes.Axes or tuple[matplotlib.axes.Axes, matplotlib.axes.Axes]

Parameters:

Steady-State Loader Registry (pymorgan.steadyState.registry)#

Loader registry for steady-state spectra (absorption / emission).

A loader maps a file path to (x, y, x_units) where x and y are 1-D arrays (spectral axis and signal) and x_units is a best-guess unit string for the spectral axis ("nm", "cm^{-1}", "eV") or None. New formats are added with register_spectrum_loader().

pymorgan.steadyState.registry.register_spectrum_loader(*names)[source]#

Register a steady-state loader under one or more data-type names.

Parameters:

names (str)

Return type:

Callable[[Callable[[str], tuple]], Callable[[str], tuple]]

pymorgan.steadyState.registry.get_spectrum_loader(name)[source]#

Return the loader registered for name or raise KeyError.

Parameters:

name (str)

Return type:

Callable[[str], tuple]

pymorgan.steadyState.registry.available_spectrum_loaders()[source]#

Return the sorted list of registered data-type names.

Return type:

list[str]

pymorgan.steadyState.registry.read_xy(path)[source]#

Read a two-column X-Y text file with an auto-detected delimiter.

The delimiter is detected per line among whitespace, tab, comma and semicolon, so space-, tab- and comma-separated files all parse. Lines that are blank, start with # or do not parse as numbers (e.g. a header) are skipped; the last such header line is used to guess the spectral-axis unit.

Parameters:

path (str)

Return type:

tuple

pymorgan.steadyState.registry.read_opus_absorbance(path)[source]#

Read absorbance from a Bruker OPUS file via the brukeropus package.

Parameters:

path (str)

Return type:

tuple