vibesketch.document.spectra

Calculated IR, Raman and UV-Vis spectra of a run’s result (#87).

A verified result keeps the vibrations and excited states its output lists (ResultVibrations, ResultExcitedStates). This module reads them from an ORCA 6 output or a vibe-qc QVF result, and exports a spectrum’s line list (CSV or plain text) and its broadened curve (plain text) with the units, source and grid in the file’s header.

Broadening follows vibe-view’s vibeview.spectrum.broaden_lines so the two programs draw the same curve: unit-area Gaussian and Cauchy (Lorentzian) densities with scale FWHM / sqrt(8 ln 2) and FWHM / 2, https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.norm.html https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.cauchy.html Lines are broadened in energy (cm⁻¹ for vibrations, eV for excited states) and the curve is then sampled on the chosen axis, so a wavelength axis is never broadened in nm. A finite range truncates the tails; the curve is not renormalised to hide that.

ORCA’s table vocabulary: ORCA 6.1 manual, Frequencies and Excited states, https://www.faccts.de/docs/orca/6.1/manual/contents/spectroscopyproperties/ir.html https://www.faccts.de/docs/orca/6.1/manual/contents/spectroscopyproperties/uvvis.html

Module Attributes

DEFAULT_FWHM

10 cm⁻¹ for vibrations, 0.2 eV for excited states.

MAX_POINTS

The most points a broadened curve may have, as in vibe-view.

MEDIA_TYPES

The media type of each export format.

Functions

broadened_spectrum(document, run_id, spectrum, *)

A spectrum broadened with a Gaussian or Lorentzian line shape, as plain text.

export_spectrum(document, request)

The export request asks for: a CSV or text line list, or a broadened curve.

orca_excited_states(text)

The absorption lines ORCA 6 prints from the transition electric dipoles.

orca_vibrations(text, atoms)

The vibrations of an ORCA 6 frequency output, with its IR and Raman lines.

qvf_excited_states(payload, section)

The states of a QVF excited_states section, energies converted to eV.

qvf_vibrations(metadata, spectra, section)

The vibrations of a QVF vibrations section, or of its IR/Raman spectra alone.

spectrum_lines(document, run_id, spectrum, *)

A spectrum's line list, with explicit units; an intensity not given is left blank.

Classes

SpectrumExport(*, run, spectrum[, format, ...])

What to export from a run's spectrum: its line list, or its broadened curve.

Exceptions

SpectrumRefused

A spectrum the result does not contain, or an export that cannot be made as asked.

vibesketch.document.spectra.DEFAULT_FWHM = {'ir': 10.0, 'raman': 10.0, 'uvvis': 0.2}

10 cm⁻¹ for vibrations, 0.2 eV for excited states.

Type:

vibe-view’s default widths

vibesketch.document.spectra.MAX_POINTS = 1000000

The most points a broadened curve may have, as in vibe-view.

vibesketch.document.spectra.MEDIA_TYPES = {'broadened': 'text/plain; charset=utf-8', 'csv': 'text/csv; charset=utf-8', 'text': 'text/plain; charset=utf-8'}

The media type of each export format.

class vibesketch.document.spectra.SpectrumExport(*, run, spectrum, format='csv', lineshape='lorentzian', fwhm=None, fwhm_unit=None, axis=None, start=None, stop=None, step=None)[source]

Bases: BaseModel

What to export from a run’s spectrum: its line list, or its broadened curve.

Parameters:
  • run (str)

  • spectrum (Literal['ir', 'raman', 'uvvis'])

  • format (Literal['csv', 'text', 'broadened'])

  • lineshape (Literal['gaussian', 'lorentzian'])

  • fwhm (float | None)

  • fwhm_unit (Literal['cm-1', 'eV'] | None)

  • axis (Literal['cm-1', 'eV', 'nm'] | None)

  • start (float | None)

  • stop (float | None)

  • step (float | None)

model_config = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

run: str
spectrum: Spectrum
format: Literal['csv', 'text', 'broadened']
lineshape: Lineshape
fwhm: float | None
fwhm_unit: Literal['cm-1', 'eV'] | None
axis: Axis | None
start: float | None
stop: float | None
step: float | None
exception vibesketch.document.spectra.SpectrumRefused[source]

Bases: ValueError

A spectrum the result does not contain, or an export that cannot be made as asked.

vibesketch.document.spectra.broadened_spectrum(document, run_id, spectrum, *, lineshape='lorentzian', fwhm=None, fwhm_unit=None, axis=None, start=None, stop=None, step=None)[source]

A spectrum broadened with a Gaussian or Lorentzian line shape, as plain text.

fwhm is in fwhm_unit (cm-1 or eV; the spectrum’s own by default), axis is cm-1 for vibrations and eV, nm or cm-1 for excited states, and start, stop and step give the grid in the axis unit. The curve is the sum of unit-area lines scaled by their intensities: its unit is the intensity’s per native unit. Lines without an intensity are left out and counted in the header.

Parameters:
Return type:

str

vibesketch.document.spectra.export_spectrum(document, request)[source]

The export request asks for: a CSV or text line list, or a broadened curve.

Parameters:
Return type:

str

vibesketch.document.spectra.spectrum_lines(document, run_id, spectrum, *, format='csv')[source]

A spectrum’s line list, with explicit units; an intensity not given is left blank.

csv has one header row; text has # comment lines and whitespace-separated columns, a missing value written as -.

Parameters:
Return type:

str