api

API functions for spectrum broadening.

Summary

Functions:

build_spectrum

Broaden a two-column stick spectrum file and write the result.

Reference

build_spectrum(
input_file: str,
output: str | None = None,
alpha: PositiveReal | None = None,
fwhm: PositiveReal | None = None,
wavenumber_min: Real = 10.0,
wavenumber_max: Real = 4000.0,
wavenumber_step: PositiveReal = 0.25,
kernel: str = 'gaussian',
mode: str | FileWritingMode = 'w',
) tuple[Np1DNumberArray, Np1DNumberArray][source]

Broaden a two-column stick spectrum file and write the result.

Reads a stick spectrum (wavenumber in cm^-1, intensity), broadens it on a regular wavenumber grid using the peak-height convention and writes one '%8.4f    %16.12e' row per grid point. This is a port of the legacy build_spectrum.sh awk implementation.

Parameters:
  • input_file (str) – The two-column stick spectrum file to read.

  • output (str | None, optional) – The output file. If None, the output is printed to stdout, by default None.

  • alpha (PositiveReal | None, optional) – The Gaussian exponent alpha in cm^-2. Mutually exclusive with fwhm, by default None, which corresponds to 0.0025 cm^-2 if fwhm is not given either.

  • fwhm (PositiveReal | None, optional) – The full width at half maximum in cm^-1 as an alternative way to specify the broadening width. Mutually exclusive with alpha, by default None.

  • wavenumber_min (Real, optional) – The first grid point in cm^-1, by default 10.0.

  • wavenumber_max (Real, optional) – The exclusive upper bound of the grid in cm^-1, by default 4000.0.

  • wavenumber_step (PositiveReal, optional) – The grid spacing in cm^-1, by default 0.25.

  • kernel (str, optional) – The broadening kernel, either gaussian or lorentzian, by default gaussian.

  • mode (str | FileWritingMode, optional) – The writing mode of the output file, by default “w”.

Returns:

The wavenumber grid and the broadened intensities.

Return type:

Tuple[Np1DNumberArray, Np1DNumberArray]

Raises:

SpectrumBroadeningError – If both alpha and fwhm are specified.