Author: bugman Date: Sun Mar 23 16:30:08 2008 New Revision: 5199 URL: http://svn.gna.org/viewcvs/relax?rev=5199&view=rev Log: Wrote the return_gyromagnetic_ratio() for returning the desired value. Modified: 1.3/physical_constants.py Modified: 1.3/physical_constants.py URL: http://svn.gna.org/viewcvs/relax/1.3/physical_constants.py?rev=5199&r1=5198&r2=5199&view=diff ============================================================================== --- 1.3/physical_constants.py (original) +++ 1.3/physical_constants.py Sun Mar 23 16:30:08 2008 @@ -65,6 +65,31 @@ g31P = 10.841 * 1e7 """The 31P gyromagnetic ratio.""" +# Function for returning the desired gyromagnetic ratio. +def return_gyromagnetic_ratio(nucleus=None): + """Return the gyromagnetic ratio for the given nucleus type. + + @keyword nucleus: The nucleus type. + @type nucleus: str + @raises RelaxError: If the nucleus type is unknown. + @returns: The desired gyromagnetic ratio. + @rtype: float + """ + + # Matching loop. + if nucleus == '13C': + return g13C + elif nucleus == '1H': + return g1H + elif nucleus == '15N': + return g15N + elif nucleus == '17O': + return g17O + elif nucleus == '31P': + return g31P + else: + raise RelaxError, "The nucleus type " + `nucleus` + " is unknown." + # Relative atomic masses. #########################