Skip to content

Latest commit

 

History

History
65 lines (40 loc) · 2.67 KB

fitting_t1_data.rst

File metadata and controls

65 lines (40 loc) · 2.67 KB

fitting example: fitting_t1_data

This example shows how to use nmrglue and the SciPy optimize module to fit T1 relaxation trajectories. Three scripts are used in the process.

The data used in this example is available for download.

First the extract_trajs.py script reads in box limits from boxes.in and a list of spectra from spectra.in. The script integrates each peak in each spectrum and writes the trajectory for each peak to disk as traj.npy in NumPy .npy format.

[extract_trajs.py <../../../examples/fitting_data/t1_measurements/extract_trajs.py>]

../../../examples/fitting_data/t1_measurements/extract_trajs.py

[boxes.in <../../../examples/fitting_data/t1_measurements/boxes.in>]

../../../examples/fitting_data/t1_measurements/boxes.in

[spectra.in <../../../examples/fitting_data/t1_measurements/spectra.in>]

../../../examples/fitting_data/t1_measurements/spectra.in

The second script fit_exp_leastsq.py reads in this traj.npy file and the T1 relaxation times associated with the spectra collected from time.dat. Each trajectory is fit using the least squares approach. Other optimization algorithms can be substituted with small changes to the code, see the scipy.optimize documentation). The resulting fits are saved to a fits.pickle file for easy reading into python as well as the human readable fits.txt file.

[fit_exp_leastsq.py <../../../examples/fitting_data/t1_measurements/fit_exp_leastsq.py>]

../../../examples/fitting_data/t1_measurements/fit_exp_leastsq.py

[time.dat <../../../examples/fitting_data/t1_measurements/time.dat>]

../../../examples/fitting_data/t1_measurements/time.dat

Results:

[fits.txt <../../../examples/fitting_data/t1_measurements/fits.txt>]

../../../examples/fitting_data/t1_measurements/fits.txt

The last script pt.py reads in the fits, trajectories and T1 relaxation times and plots the experimental points and best fit to a series of *_plot.png files.

[pt.py <../../../examples/fitting_data/t1_measurements/pt.py>]

../../../examples/fitting_data/t1_measurements/pt.py

Results:

[A24_plot.png <../../../examples/fitting_data/t1_measurements/A24_plot.png>]

image