1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 """Module containing functions related to basic NMR concepts."""
24
25
26 from math import atan2, pi, sqrt
27
28
29 from lib.periodic_table import periodic_table
30
31
33 """Convert the given frequency from ppm to Hertz units.
34
35 @keyword frq: The frequency in ppm.
36 @type frq: float
37 @keyword B0: The magnetic field strength as the proton frequency in Hertz.
38 @type B0: float
39 @keyword isotope: The isotope type of the nucleus of interest.
40 @type isotope: str
41 @return: The frequency in Hertz.
42 @rtype: float
43 """
44
45
46 return frq * B0 / periodic_table.gyromagnetic_ratio('1H') * periodic_table.gyromagnetic_ratio(isotope) * 1e-6
47
48
50 """Convert the given frequency from Hertz to ppm units.
51
52 @keyword frq: The frequency in Hertz.
53 @type frq: float
54 @keyword B0: The magnetic field strength as the proton frequency in Hertz.
55 @type B0: float
56 @keyword isotope: The isotope type of the nucleus of interest.
57 @type isotope: str
58 @return: The frequency in ppm.
59 @rtype: float
60 """
61
62
63 return frq / B0 * periodic_table.gyromagnetic_ratio('1H') / periodic_table.gyromagnetic_ratio(isotope) / 1e-6
64
65
67 """Convert the given frequency from rad/s to ppm units.
68
69 @keyword frq: The frequency in rad/s.
70 @type frq: float
71 @keyword B0: The magnetic field strength as the proton frequency in Hertz.
72 @type B0: float
73 @keyword isotope: The isotope type of the nucleus of interest.
74 @type isotope: str
75 @return: The frequency in ppm.
76 @rtype: float
77 """
78
79
80 return frq / (2.0 * pi) / B0 * periodic_table.gyromagnetic_ratio('1H') / periodic_table.gyromagnetic_ratio(isotope) / 1e-6
81
82
84 """Convert the given frequency from ppm to rad/s units.
85
86 @keyword frq: The frequency in ppm.
87 @type frq: float
88 @keyword B0: The magnetic field strength as the proton frequency in Hertz.
89 @type B0: float
90 @keyword isotope: The isotope type of the nucleus of interest.
91 @type isotope: str
92 @return: The frequency in rad/s.
93 @rtype: float
94 """
95
96
97 return frq * 2.0 * pi * B0 / periodic_table.gyromagnetic_ratio('1H') * periodic_table.gyromagnetic_ratio(isotope) * 1e-6
98
99
101 """Calculate the rotating frame paramaters.
102
103 @keyword chemical_shift: The chemical shift in rad/s.
104 @type chemical_shift: float
105 @keyword spin_lock_offset: spin-lock offset in rad/s.
106 @type spin_lock_offset: float
107 @keyword omega1: Spin-lock field strength in rad/s.
108 @type omega1: float
109 @return: The average resonance offset in the rotating frame, angle describing the tilted rotating frame relative to the laboratory, effective field in rotating frame.
110 @rtype: float, float, float
111 """
112
113
114 Delta_omega = chemical_shift - spin_lock_offset
115
116
117
118
119
120
121 if Delta_omega == 0.0:
122 theta = pi / 2.0
123 else:
124 theta = atan2(omega1, Delta_omega)
125
126
127 w_eff = sqrt( Delta_omega*Delta_omega + omega1*omega1 )
128
129 return Delta_omega, theta, w_eff
130