Processing Relaxation measurement

Processing NMR spectra taken for relaxation measurements

Import API

import spectrochempy as scp

# short version of the unit registry
U = scp.ur

Importing a pseudo 2D NMR spectra

Define the folder where are the spectra

datadir = scp.preferences.datadir
nmrdir = datadir / "nmrdata" / "bruker" / "tests" / "nmr"

dataset = scp.read_topspin(nmrdir / "relax" / "100" / "ser", use_list="vdlist")

Analysing the data

Print dataset summary

name relax expno:100 procno:1 (SER)
author runner@fv-az1152-754
created 2024-03-08 01:00:24+00:00
DATA
title intensity
values
R[[ 0.5522 2.137 ... -1.437 -0.02603]
[ 1.099 3.404 ... -0.6497 -0.0129]
...
[ 1.603 5.99 ... 4.959 0.09235]
[ 1.61 6.14 ... -0.7725 -0.01501]] pp
I[[ -1.513 -2.733 ... 4.471 0.08437]
[ -2.496 -4.623 ... -6.003 -0.1152]
...
[ -4.25 -7.726 ... 4.695 0.08693]
[ -4.302 -7.69 ... 0.222 0.004867]] pp
shape (y:9, x:1982(complex))
DIMENSION `x`
size 1982
title F2 acquisition time
coordinates
[ 0 6.4 ... 1.267e+04 1.268e+04] µs
DIMENSION `y`
size 9
title time
coordinates
[ 1 2 ... 20 50] s


Plot the dataset

ds = dataset.em(lb=15 * U.Hz)
ds = ds.fft()
ds = ds.pk(phc0=-10 * U.deg, phc1=0 * U.deg)
_ = ds.plot(xlim=(-60, -140))
plot processing nmr relax

Integrate a region

dsint = ds[:, -90.0:-115.0].simpson()
_ = dsint.plot(marker="^", ls=":")
dsint.real
plot processing nmr relax
/home/runner/micromamba/envs/scpy_docs/lib/python3.10/site-packages/spectrochempy/analysis/integration/integrate.py:178: DeprecationWarning: 'scipy.integrate.simps' is deprecated in favour of 'scipy.integrate.simpson' and will be removed in SciPy 1.14.0
  return scipy.integrate.simps(dataset.data, **kwargs)
name relax expno:100 procno:1 (SER)
author runner@fv-az1152-754
created 2024-03-08 01:00:24+00:00
description
Integration of NDDataset 'relax expno:100 procno:1 (SER)' along dim: 'x'.
history
2024-03-08 01:00:25+00:00> Dataset resulting from application of `simpson` method
DATA
title area
values
[ 1556 2472 ... 4253 4284] pp.ppm
size 9
DIMENSION `y`
size 9
title time
coordinates
[ 1 2 ... 20 50] s


Fit a model

create an Optimize object using a simple leastsq method

fitter = scp.Optimize(log_level="INFO", method="leastsq")

Define the model to fit

def T1_model(t, I0, T1):  # no underscore in parameters names.
    # T1 relaxation model
    import numpy as np

    I = I0 * (1 - np.exp(-t / T1))
    return I

Add the model to the fitter usermodels as it it not a built-in model

fitter.usermodels = {"T1_model": T1_model}

Define the parameter variables using a script (parameter: value, low_bound, high_bound) no underscore in parameters names.

fitter.script = """
MODEL: T1
shape: T1_model
  $ I0:  1000.0, 1, none
  $ T1:  2.0,    0.1, none
"""

Performs the fit


name relax expno:100 procno:1 (SER)_Optimize.inverse_transform
author runner@fv-az1152-754
created 2024-03-08 01:00:25+00:00
history
2024-03-08 01:00:25+00:00> Created using method Optimize.inverse_transform
DATA
title area
values
[ 1500 2467 ... 4223 4223] pp.ppm
size 9
DIMENSION `y`
size 9
title time
coordinates
[ 1 2 ... 20 50] s


_ = fitter.plotmerit(dsint, som, method="scatter", title="T1 relaxation fitting")
T1 relaxation fitting

This ends the example ! The following line can be removed or commented when the example is run as a notebook (*.ipynb).

# scp.show()

Total running time of the script: ( 0 minutes 0.531 seconds)

Gallery generated by Sphinx-Gallery