Package lib :: Module nmr
[hide private]
[frames] | no frames]

Source Code for Module lib.nmr

 1  ############################################################################### 
 2  #                                                                             # 
 3  # Copyright (C) 2013 Edward d'Auvergne                                        # 
 4  #                                                                             # 
 5  # This file is part of the program relax (http://www.nmr-relax.com).          # 
 6  #                                                                             # 
 7  # This program is free software: you can redistribute it and/or modify        # 
 8  # it under the terms of the GNU General Public License as published by        # 
 9  # the Free Software Foundation, either version 3 of the License, or           # 
10  # (at your option) any later version.                                         # 
11  #                                                                             # 
12  # This program is distributed in the hope that it will be useful,             # 
13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
15  # GNU General Public License for more details.                                # 
16  #                                                                             # 
17  # You should have received a copy of the GNU General Public License           # 
18  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
19  #                                                                             # 
20  ############################################################################### 
21   
22  # Module docstring. 
23  """Module containing functions related to basic NMR concepts.""" 
24   
25  # Python module imports. 
26  from math import pi 
27   
28  # relax module imports. 
29  from lib.physical_constants import g1H, return_gyromagnetic_ratio 
30   
31   
32 -def frequency_to_Hz(frq=None, B0=None, isotope=None):
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 # Convert and return. 46 return frq * B0 / g1H * return_gyromagnetic_ratio(isotope) * 1e-6
47 48
49 -def frequency_to_ppm(frq=None, B0=None, isotope=None):
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 # Convert and return. 63 return frq / B0 * g1H / return_gyromagnetic_ratio(isotope) / 1e-6
64 65
66 -def frequency_to_rad_per_s(frq=None, B0=None, isotope=None):
67 """Convert the given frequency from ppm to rad/s units. 68 69 @keyword frq: The frequency in ppm. 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 rad/s. 76 @rtype: float 77 """ 78 79 # Convert and return. 80 return frq * 2.0 * pi * B0 / g1H * return_gyromagnetic_ratio(isotope) * 1e-6
81