Author: bugman Date: Wed Oct 28 11:49:03 2009 New Revision: 9830 URL: http://svn.gna.org/viewcvs/relax?rev=9830&view=rev Log: Merged revisions 9829 via svnmerge from svn+ssh://bugman@xxxxxxxxxxx/svn/relax/1.3 ........ r9829 | bugman | 2009-10-28 11:47:59 +0100 (Wed, 28 Oct 2009) | 3 lines Added functions for determining the element name and isotope number from an isotope name. ........ Modified: branches/bmrb/ (props changed) branches/bmrb/physical_constants.py Propchange: branches/bmrb/ ------------------------------------------------------------------------------ --- svnmerge-integrated (original) +++ svnmerge-integrated Wed Oct 28 11:49:03 2009 @@ -1,1 +1,1 @@ -/1.3:1-9811 +/1.3:1-9829 Modified: branches/bmrb/physical_constants.py URL: http://svn.gna.org/viewcvs/relax/branches/bmrb/physical_constants.py?rev=9830&r1=9829&r2=9830&view=diff ============================================================================== --- branches/bmrb/physical_constants.py (original) +++ branches/bmrb/physical_constants.py Wed Oct 28 11:49:03 2009 @@ -1,6 +1,6 @@ ############################################################################### # # -# Copyright (C) 2007-2008 Edward d'Auvergne # +# Copyright (C) 2007-2009 Edward d'Auvergne # # # # This file is part of the program relax. # # # @@ -26,7 +26,7 @@ # Python module imports. from math import pi -from string import upper +from string import ascii_letters, digits, upper # relax module imports. from relax_errors import RelaxError @@ -259,3 +259,33 @@ # Unknown mass. raise RelaxError("The mass of the element " + repr(element) + " has not yet been programmed into relax.") + + + +# Element info. +############### + +def element_from_isotope(isotope): + """Determine and return the element name for the given isotope. + + @param isotope: The isotope name, such as '1H', '15N'. + @type isotope: str + @return: The element name. + @rtype: str + """ + + # Remove the digit characters. + return isotrope.strip(digits) + + +def number_from_isotope(isotope): + """Determine and return the isotope number for the given isotope. + + @param isotope: The isotope name, such as '1H', '15N'. + @type isotope: str + @return: The isotope number. + @rtype: int + """ + + # Remove the digit characters. + return int(isotrope.strip(ascii_letters))