Package generic_fns :: Module temperature
[hide private]
[frames] | no frames]

Source Code for Module generic_fns.temperature

 1  ############################################################################### 
 2  #                                                                             # 
 3  # Copyright (C) 2008-2012 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 for setting the experimental temperature.""" 
24   
25  # relax module imports. 
26  from generic_fns import pipes 
27  from relax_errors import RelaxError 
28   
29   
30 -def set(id=None, temp=None):
31 """Set the experimental temperature. 32 33 @keyword id: The experimental identification string (allowing for multiple experiments per data pipe). 34 @type id: str 35 @keyword temp: The temperature in kelvin. 36 @type temp: float 37 """ 38 39 # Test if the current data pipe exists. 40 pipes.test() 41 42 # Set up the dictionary data structure if it doesn't exist yet. 43 if not hasattr(cdp, 'temperature'): 44 cdp.temperature = {} 45 46 # Convert to a float. 47 temp = float(temp) 48 49 # Test the temperature has not already been set. 50 if id in cdp.temperature and cdp.temperature[id] != temp: 51 raise RelaxError("The temperature for the experiment '%s' has already been set to %s K." % (id, cdp.temperature[id])) 52 53 # Set the temperature. 54 cdp.temperature[id] = temp
55