mailr18053 - /trunk/generic_fns/temperature.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on November 30, 2012 - 13:06:
Author: bugman
Date: Fri Nov 30 13:06:46 2012
New Revision: 18053

URL: http://svn.gna.org/viewcvs/relax?rev=18053&view=rev
Log:
Modified the temperature user function - the value can be set twice if it is 
the same value.


Modified:
    trunk/generic_fns/temperature.py

Modified: trunk/generic_fns/temperature.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/generic_fns/temperature.py?rev=18053&r1=18052&r2=18053&view=diff
==============================================================================
--- trunk/generic_fns/temperature.py (original)
+++ trunk/generic_fns/temperature.py Fri Nov 30 13:06:46 2012
@@ -1,6 +1,6 @@
 
###############################################################################
 #                                                                            
 #
-# Copyright (C) 2008-2009 Edward d'Auvergne                                  
 #
+# Copyright (C) 2008-2012 Edward d'Auvergne                                  
 #
 #                                                                            
 #
 # This file is part of the program relax (http://www.nmr-relax.com).         
 #
 #                                                                            
 #
@@ -30,8 +30,7 @@
 def set(id=None, temp=None):
     """Set the experimental temperature.
 
-    @keyword id:    The experimental identification string (allowing for 
multiple experiments per
-                    data pipe).
+    @keyword id:    The experimental identification string (allowing for 
multiple experiments per data pipe).
     @type id:       str
     @keyword temp:  The temperature in kelvin.
     @type temp:     float
@@ -44,9 +43,12 @@
     if not hasattr(cdp, 'temperature'):
         cdp.temperature = {}
 
+    # Convert to a float.
+    temp = float(temp)
+
     # Test the temperature has not already been set.
-    if id in cdp.temperature:
-        raise RelaxError("The temperature for the experiment " + repr(id) + 
" has already been set.")
+    if id in cdp.temperature and cdp.temperature[id] != temp:
+        raise RelaxError("The temperature for the experiment '%s' has 
already been set to %s K." % (id, cdp.temperature[id]))
 
     # Set the temperature.
-    cdp.temperature[id] = float(temp)
+    cdp.temperature[id] = temp




Related Messages


Powered by MHonArc, Updated Fri Nov 30 13:20:01 2012