Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

utils.spectra

utils.spectra

Functions

NameDescription
calculate_hz_axisCalculate the frequency (Hz) axis for a spectrum.
calculate_ppm_axisCalculate the chemical shift (ppm) axis for a spectrum.

calculate_hz_axis

utils.spectra.calculate_hz_axis(spectral_width=None, npts=None, header=None)

Calculate the frequency (Hz) axis for a spectrum.

Parameters

NameTypeDescriptionDefault
spectral_widthfloatSpectral width in Hz. Read from header if not given.None
nptsintNumber of spectral points. Read from header if not given.None
headerdictRaw header dict to fall back on for spectral_width/npts.None

Returns

NameTypeDescription
npt.NDArray[np.float64]Frequency axis in Hz, centered on zero.

calculate_ppm_axis

utils.spectra.calculate_ppm_axis(
    spectral_width=None,
    frequency=None,
    carrier_ppm=None,
    nucleus=None,
    npts=None,
    header=None,
)

Calculate the chemical shift (ppm) axis for a spectrum.

Parameters

NameTypeDescriptionDefault
spectral_widthfloatSpectral width in Hz. Read from header if not given.None
frequencyfloatSpectrometer frequency in MHz. Read from header if not given.None
carrier_ppmfloatCarrier frequency offset in ppm. Derived from nucleus if not given.None
nucleusint or strNucleus identifier (e.g. "1H" or 1) used to derive carrier_ppm when it is not provided directly.None
nptsintNumber of spectral points. Read from header if not given.None
headerdictRaw header dict to fall back on for the other parameters.None

Returns

NameTypeDescription
npt.NDArray[np.float64]Chemical shift axis in ppm.