ramannoodle.spectrum

Classes and functions for calculating and manipulating spectra.

class ramannoodle.spectrum.MDRamanSpectrum(polarizability_ts, timestep)

Bases: RamanSpectrum

Molecular-dynamics-based Raman spectrum.

The spectrum is specified by a polarizability time series (polarizability_ts) and a timestep.

Parameters:
  • polarizability_ts (ndarray[Any, dtype[float64]]) – Array with shape (S,3,3) where S is the number of configurations.

  • timestep (float) – (fs)

measure(orientation='polycrystalline', laser_correction=False, laser_wavelength=522, bose_einstein_correction=False, temperature=300)

Calculate and return a raw Raman spectrum.

Note

Raw MD-derived Raman spectra will typically need to be smoothed to be visualized effectively. See spectrum_utils.convolve_spectrum().

Parameters:
  • orientation (str | ndarray[Any, dtype[float64]]) – Supports "polycrystalline". Future versions will support arbitrary orientations.

  • laser_correction (bool) – If True, applies laser-wavelength-dependent intensity correction.

  • laser_wavelength (float) – (nm) Ignored if laser_correction == False.

  • bose_einstein_correction (bool) – If True, applies temperature-dependent Bose Einstein correction.

  • temperature (float) –

    1. Ignored if bose_einstein_correction == False.

Return type:

tuple[ndarray[Any, dtype[float64]], ndarray[Any, dtype[float64]]]

Returns:

  1. wavenumbers – (cm-1) Array with shape (ceiling(S / 2),) where S is the number of configurations.

  2. intensities – (arbitrary units) Array with shape (ceiling(S / 2),).

property polarizability_ts: ndarray[Any, dtype[float64]]

Get (a copy) of polarizability time series.

Returns:

Array with shape (S,3,3) where S is the number of configurations.

property timestep: float

Get timestep.

Returns:

(fs)

class ramannoodle.spectrum.PhononRamanSpectrum(phonon_wavenumbers, raman_tensors)

Bases: RamanSpectrum

Phonon-based first-order Raman spectrum.

The spectrum is specified by a list of phonon wavenumbers and corresponding Raman tensors.

Parameters:
  • phonon_wavenumbers (ndarray[Any, dtype[float64]]) – (cm-1) Array with shape (M,) where M is the number of phonons.

  • raman_tensors (ndarray[Any, dtype[float64]]) – Array with shape (M,3,3).

measure(orientation='polycrystalline', laser_correction=False, laser_wavelength=522, bose_einstein_correction=False, temperature=300)

Calculate and return a raw Raman spectrum.

Parameters:
  • orientation (str | ndarray[Any, dtype[float64]]) – Supports "polycrystalline". Future versions will support arbitrary orientations.

  • laser_correction (bool) – If True, applies laser-wavelength-dependent intensity correction.

  • laser_wavelength (float) – (nm) Ignored if laser_correction == False.

  • bose_einstein_correction (bool) – If True, applies temperature-dependent Bose Einstein correction.

  • temperature (float) –

    1. Ignored if bose_einstein_correction == False.

Return type:

tuple[ndarray[Any, dtype[float64]], ndarray[Any, dtype[float64]]]

Returns:

  1. wavenumbers – (cm-1) Array with shape (M,).

  2. intensities – (arbitrary units) Array with shape (M,).

Raises:

NotImplementedError – Raised when any orientation besides "polycrystalline" is supplied.

property phonon_wavenumbers: ndarray[Any, dtype[float64]]

Get (a copy of) phonon wavenumbers.

Returns:

(cm-1) Array with shape (M,) where M is the number of phonons.

property raman_tensors: ndarray[Any, dtype[float64]]

Get (a copy of) Raman tensors.

Returns:

Array with shape (M,3,3) where M is the number of phonons.

Submodules

ramannoodle.spectrum.utils module

Utility functions for spectra.

ramannoodle.spectrum.utils.calc_signal_spectrum(signal, sampling_rate)

Calculate a signal’s spectrum.

The spectrum is defined as the positive-frequency Fourier transform of the signal’s autocorrelation.

Parameters:
  • signal (ndarray[Any, dtype[float64]]) – Array with shape (S,) where S is the number of samples.

  • sampling_rate (float) – (fs)

Return type:

tuple[ndarray[Any, dtype[float64]], ndarray[Any, dtype[float64]]]

Returns:

  1. wavenumbers – (cm-1) Array with shape (ceiling(S / 2),).

  2. intensities – (arbitrary units) Array with shape (ceiling(S / 2),).

ramannoodle.spectrum.utils.convolve_spectrum(wavenumbers, intensities, function='gaussian', width=5, out_wavenumbers=None)

Convolve a spectrum, producing a smoothing effect.

Parameters:
  • wavenumbers (ndarray[Any, dtype[float64]]) – (cm-1) Array with shape (M,).

  • intensities (ndarray[Any, dtype[float64]]) – (arbitrary units) Array with shape (M,).

  • function (str) – Supports "gaussian" or "lorentzian".

  • width (float) – (cm-1)

  • out_wavenumbers (ndarray[Any, dtype[float64]] | None) – (cm-1) Array with shape (L,) where L is arbitrary. If None, out_wavenumbers is determined automatically.

Return type:

tuple[ndarray[Any, dtype[float64]], ndarray[Any, dtype[float64]]]

Returns:

  1. wavenumbers (out_wavenumbers) – (cm-1) Array with shape (L,).

  2. intensities – (arbitrary units) Array with shape (L,).