SIM Module

This package contains function for the simulation of various features of NMR spectra, being them monodimensional or bidimensional. Functions for the simulation of whole spectra are also provided.

klassez.sim.calc_splitting(u0, I0, m=1, J=0)[source]

Calculate the frequency and the intensities of a NMR signal splitted by scalar coupling.

Parameters:
u0float

Frequency of the non-splitted signal (Hz)

I0float

Total intensity of the non-splitted signal.

mint

Multiplicity, i.e. number of expected signals after the splitting

Jfloat

Scalar coupling constant (Hz)

Returns:
u_s1darray

Frequencies of the splitted signal (Hz)

I_s1darray

Intensities of the splitted signal

klassez.sim.f_gaussian(x, u, s, A=1)[source]

Gaussian function in the frequency domain:

\[s(x) = \frac{A}{\sqrt{2\pi} \sigma} \exp\biggl\{-\frac{1}{2} \biggl(\frac{x - \mu}{\sigma}\biggr)^2\biggr\}\]
Parameters:
x1darray

Independent variable

ufloat

Peak position

sfloat

Standard deviation

Afloat

Intensity

Returns:
f1darray

Gaussian function.

klassez.sim.f_lorentzian(x, u, fwhm, A=1)[source]

Lorentzian function in the time domain:

\[s(x) = \frac{A}{\pi} \frac{\gamma}{(x-\mu)^2 + \gamma^2}\]

where \(\gamma = \Gamma /2\)

Parameters:
x1darray

Independent variable

ufloat

Peak position

fwhmfloat

Full-width at half-maximum

Afloat

Intensity

Returns:
f1darray

Lorentzian function.

klassez.sim.f_pvoigt(x, u, fwhm, A=1, b=0)[source]

Pseudo-Voigt function in the frequency domain:

Parameters:
x1darray

Independent variable

ufloat

Peak position

fwhmfloat

Full-width at half-maximum

Afloat

Intensity

bfloat

Fraction of gaussianity

Returns:
S1darray

Pseudo-Voigt function.

klassez.sim.f_skgaussian(x, u, s, A=1, a=0)[source]

Skewed-Gaussian function in the frequency domain:

\[s(x) = \frac{A}{\sqrt{2\pi} \sigma} \exp\biggl\{-\frac{z^2}{2} \biggr\} \biggl[1 + \operatorname{erf} \biggl\{ \alpha \frac{z}{\sqrt{2}} \biggr\} \biggr]\]

with \(z = (x - \mu) / \sigma\) and asymmetry parameter \(\alpha\).

Parameters:
x1darray

Independent variable

ufloat

Peak position

sfloat

Standard deviation

Afloat

Intensity

afloat

Asymmetry. a = 0 gives the standard gaussian.

Returns:
f1darray

Gaussian function.

klassez.sim.gaussian_filter(ppm, u, s)[source]

Compute a gaussian filter to be used in order to suppress signals in the spectrum.

Parameters:
ppm1darray

Scale on which to build the filter

ufloat

Position of the filter

sfloat

Width of the filter (standard deviation)

Returns:
G1darray

Computed gaussian filter

klassez.sim.load_sim_1D(File)[source]

Creates a dictionary from the spectral parameters listed in the input file.

Parameters:
Filestr

Path to the input file location

Returns:
dicdict

Dictionary of the parameters, ready to be read from the simulation functions.

klassez.sim.load_sim_2D(File, states=True)[source]

Creates a dictionary from the spectral parameters listed in the input file.

Parameters:
Filestr

Path to the input file location

statesbool

If FnMODE is States or States-TPPI, set it to True to get the correct timescale.

Returns:
dicdict

Dictionary of the parameters, ready to be read from the simulation functions.

klassez.sim.mult_noise(data_size, mean=0, s_n=0.1)[source]

Multiplicative noise model.

Parameters:
data_sizetuple

Dimension of the FID array

meanfloat

Mean of the random array distribution

s_nfloat

Standard deviation of the random array distribution

Returns:
noisemat2darray

Multiplicative noise array matrix

klassez.sim.multiplet(u, Int, m='s', J=[])[source]

Split a given signal according to a scalar coupling pattern.

Parameters:
ufloat

Frequency of the non-splitted signal (Hz)

Ifloat

Intensity of the non-splitted signal

mstr

Organic chemistry-like multiplet, i.e. s, d, dqt, etc.

Jfloat or list

Scalar coupling constants. The number of constants should match the number of coupling branches

Returns:
u_inlist

List of the splitted frequencies (Hz)

I_inlist

Intensities of the splitted signal

klassez.sim.noisegen(size, o2, t2, s_n=1)[source]

Simulates additive noise in the time domain, modelled as Grage and Akke.

Parameters:
sizeint or tuple

Dimension of the noise matrix

o2float

Carrier frequency, in Hz.

t21darray

Time scale of the last temporal dimension.

s_nfloat

Standard deviation of the noise.

Returns:
noise2darray

Noise matrix, of dimensions size.

klassez.sim.sim_1D(File, pv=False)[source]

Simulates a 1D NMR spectrum from the instructions written in File.

Parameters:
Filestr

Path to the input file location

pvbool

True for pseudo-Voigt model, False for Voigt model.

Returns:
fid1darray

FID of the simulated spectrum.

klassez.sim.sim_2D(File, states=True, alt=True, pv=False)[source]

Simulates a 2D NMR spectrum from the instructions written in File. The indirect dimension is sampled with States-TPPI as default.

Parameters:
Filestr

Path to the input file location

statesbool

Set it to True to allow for correct spectral arrangement in the indirect dimension.

altbool

Set it to True to allow for correct spectral arrangement in the indirect dimension.

pvbool

True for pseudo-Voigt model, False for Voigt model.

Returns:
fid2darray

FID of the simulated spectrum.

klassez.sim.t_2Dgaussian(t1, t2, v1, v2, s1, s2, A=1, states=True, alt=True)[source]

Bidimensional gaussian function.

\[s(t_1, t_2) = A\, \exp\{ i \omega_2 t_2 - \sigma_2^2 t_2^2 /2 \}\, \cos\{ \omega_1 t_{1s} - \frac{\pi}{2} (k \% 4) \}\, \exp\{ -\sigma_1^2 t_{1s}^2 /2\}\]

where:

  • \(\omega = 2\pi \nu\) –> resonance frequency

  • \(\sigma = \Gamma / (2\sqrt{2\ln 2})\) –> linewidth

  • \(t_{1s}\) is t1 with double entries (States)

Parameters:
t11darray

Indirect evolution timescale

t21darray

Timescale of the direct dimension

v1float

Peak position in the indirect dimension, in Hz

v2float

Peak position in the direct dimension, in Hz

s1float

Standard deviation in the indirect dimension, in rad/s

s2float

Standard deviation in the direct dimension, in rad/s

Afloat

Intensity

statesbool

Set to True for “FnMODE”:”States-TPPI

altbool

Set to True for “FnMODE”:”States-TPPI

Returns:
S2darray

Gaussian function.

klassez.sim.t_2Dlorentzian(t1, t2, v1, v2, fwhm1, fwhm2, A=1, states=True, alt=True)[source]

Bidimensional lorentzian function.

\[s(t_1, t_2) = A\, \exp\{ i \omega_2 t_2 - \Gamma_2 t_2 /2 \}\, \cos\{ \omega_1 t_{1s} - \frac{\pi}{2} (k \% 4) \}\, \exp\{ -\Gamma_1 t_{1s} /2\}\]

where:

  • \(\omega = 2\pi \nu\) –> resonance frequency

  • \(\Gamma\) –> linewidth

  • \(t_{1s}\) is t1 with double entries (States)

Parameters:
t11darray

Indirect evolution timescale

t21darray

Timescale of the direct dimension

v1float

Peak position in the indirect dimension, in Hz

v2float

Peak position in the direct dimension, in Hz

fwhm1float

Full-width at half maximum in the indirect dimension, in rad/s

fwhm2float

Full-width at half maximum in the direct dimension, in rad/s

Afloat

Intensity

statesbool

Set to True for “FnMODE”:”States-TPPI

altbool

Set to True for “FnMODE”:”States-TPPI

Returns:
S2darray

Lorentzian function.

klassez.sim.t_2Dpvoigt(t1, t2, v1, v2, fwhm1, fwhm2, A=1, b=0, states=True, alt=True)[source]

Generates a 2D pseudo-voigt signal in the time domain. b states for the fraction of gaussianity, whereas A defines the overall amplitude of the total peak. Indexes ‘1’ and ‘2’ on the variables stand for ‘F1’ and ‘F2’, respectively.

\[s(t_1, t_2) = A\, \exp\{ i \omega_2 t_2 \} [(1-\beta)\exp\{ - \Gamma_2 t_2 /2 \} + \beta\exp\{- \sigma_2^2 t_2^2 /2 \}] \, \cos\{\omega_1 t_{1s} - \frac{\pi}{2} (k \% 4) \}\,\]

where:

  • \(\omega = 2\pi \nu\) –> resonance frequency

  • \(\sigma = \Gamma / (2\sqrt{2\ln 2})\) –> linewidth

  • \(t_{1s}\) is t1 with double entries (States)

Parameters:
t11darray

Indirect evolution timescale

t21darray

Timescale of the direct dimension

v1float

Peak position in the indirect dimension, in Hz

v2float

Peak position in the direct dimension, in Hz

fwhm1float

Full-width at half maximum in the indirect dimension, in rad/s

fwhm2float

Full-width at half maximum in the direct dimension, in rad/s

Afloat

Intensity

bfloat

Fraction of gaussianity

statesbool

Set to True for “FnMODE”:”States-TPPI

altbool

Set to True for “FnMODE”:”States-TPPI46

Returns:
fid2darray

Pseudo-Voigt function.

klassez.sim.t_2Dvoigt(t1, t2, v1, v2, fwhm1, fwhm2, A=1, b=0, states=True, alt=True)[source]

Generates a 2D Voigt signal in the time domain. b states for the fraction of gaussianity, whereas A defines the overall amplitude of the total peak. Indexes ‘1’ and ‘2’ on the variables stand for ‘F1’ and ‘F2’, respectively.

\[s(t_1, t_2) = A\, \exp\{i \omega_2 t_2 - (1 - \beta) \Gamma_2 t_2 / 2 - \beta\sigma_2^2 t_2^2 /2\}\, \cos\{\omega_1 t_{1s} - \frac{\pi}{2} (k \% 4) \}\, \exp\{ - (1 - \beta) \Gamma_1 t_{1s} / 2 - \beta \sigma_1^2 t_{1s}^2 /2\}\]

where:

  • \(\omega = 2\pi \nu\) –> resonance frequency

  • \(\sigma = \Gamma / (2\sqrt{2\ln 2})\) linewidth

  • \(t_{1s}\) is t1 with double entries (States)

Parameters:
t11darray

Indirect evolution timescale

t21darray

Timescale of the direct dimension

v1float

Peak position in the indirect dimension, in Hz

v2float

Peak position in the direct dimension, in Hz

fwhm1float

Full-width at half maximum in the indirect dimension, in rad/s

fwhm2float

Full-width at half maximum in the direct dimension, in rad/s

Afloat

Intensity

bfloat

Fraction of gaussianity

statesbool

Set to True for “FnMODE”:”States-TPPI

altbool

Set to True for “FnMODE”:”States-TPPI

Returns:
S2darray

Voigt function.

klassez.sim.t_gaussian(t, u, s, A=1, phi=0)[source]

Gaussian function in the time domain.

\[s(t) = A\, \exp\{i \omega t \}\, \exp\{-\sigma^2 t^2/2 \}\]
Parameters:
t1darray

Independent variable

ufloat

Peak position, in Hz

sfloat

Standard deviation, in rad/s

Afloat

Intensity

phifloat

Phase, in radians

Returns:
S1darray

Gaussian function.

klassez.sim.t_lorentzian(t, u, fwhm, A=1, phi=0)[source]

Lorentzian function in the time domain.

\[s(t) = A\, \exp\{i \omega t \}\, \exp\{-\Gamma t/2 \}\]
Parameters:
t1darray

Independent variable

ufloat

Peak position, in Hz

fwhmfloat

Full-width at half-maximum, in rad/s

Afloat

Intensity

phifloat

Phase, in radians

Returns:
S1darray

Lorentzian function.

klassez.sim.t_pvoigt(t, u, fwhm, A=1, b=0, phi=0)[source]

Pseudo-Voigt function in the time domain:

\[s(t) = A\, \exp\{i \omega t \}\, [(1-\beta) \exp\{-\Gamma t/2\} + \beta\exp\{-\sigma^2 t^2/2 \}]\]
Parameters:
t1darray

Independent variable

ufloat

Peak position, in Hz

fwhmfloat

Full-width at half-maximum, in rad/s

Afloat

Intensity

bfloat

Fraction of gaussianity

phifloat

Phase, in radians

Returns:
S1darray

Pseudo-Voigt function.

klassez.sim.t_voigt(t, u, fwhm, A=1, b=0, phi=0)[source]

Voigt function in the time domain. The parameter b affects the linewidth of the lorentzian and gaussian contributions.

\[s(t) = A\, \exp\{i \omega t \}\, \exp\{-(1-\beta) \Gamma t / 2-\beta\sigma^2 t^2/2 \}\]
Parameters:
t1darray

Independent variable

ufloat

Peak position, in Hz

fwhmfloat

Full-width at half-maximum, in rad/s

Afloat

Intensity

bfloat

Fraction of gaussianity

phifloat

Phase, in radians

Returns:
S1darray

Voigt function.

klassez.sim.water7(N, t2, vW, fwhm=300, A=1, spread=701.125)[source]

Simulates a feature like the water ridge in HSQC spectra, in the time domain.

Parameters:
Nint

Number of transients

t21darray

Time scale of the last temporal dimension.

vWfloat

Nominal peak position, in Hz.

fwhmfloat

Nominal full-width at half maximum of the peak, in rad/s.

Afloat

Signal intensity.

spreadfloat

Standard deviation of the peak position distribution, in Hz.

Returns:
ridge2darray

Matrix of the ridge.