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

Source Code for Module generic_fns.frq

 1  ############################################################################### 
 2  #                                                                             # 
 3  # Copyright (C) 2008-2012 Edward d'Auvergne                                   # 
 4  #                                                                             # 
 5  # This file is part of the program relax.                                     # 
 6  #                                                                             # 
 7  # relax 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 2 of the License, or           # 
10  # (at your option) any later version.                                         # 
11  #                                                                             # 
12  # relax 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 relax; if not, write to the Free Software                        # 
19  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   # 
20  #                                                                             # 
21  ############################################################################### 
22   
23  # Module docstring. 
24  """Module for manipulating the spectrometer frequency of experiments.""" 
25   
26  # relax module imports. 
27  from generic_fns import pipes 
28  from relax_errors import RelaxError 
29   
30   
31 -def get_values():
32 """Return a list of all the current frequencies. 33 34 @return: The frequency list for the current data pipe. 35 @rtype: list of float 36 """ 37 38 # No frequency data. 39 if not hasattr(cdp, 'frq'): 40 return [] 41 42 # The frequency values. 43 values = cdp.frq.values() 44 45 # Build a list of the unique frequencies. 46 frq = [] 47 for value in values: 48 if value not in frq: 49 frq.append(value) 50 51 # Return the frqs. 52 return frq
53 54
55 -def set(id=None, frq=None):
56 """Set the spectrometer frequency of the experiment. 57 58 @keyword id: The experimental identification string (allowing for multiple experiments per 59 data pipe). 60 @type id: str 61 @keyword frq: The spectrometer frequency in Hertz. 62 @type frq: float 63 """ 64 65 # Test if the current data pipe exists. 66 pipes.test() 67 68 # Set up the dictionary data structure if it doesn't exist yet. 69 if not hasattr(cdp, 'frq'): 70 cdp.frq = {} 71 72 # Test the frequency has not already been set. 73 if id in cdp.frq: 74 raise RelaxError("The frequency for the experiment " + repr(id) + " has already been set.") 75 76 # Set the frequency. 77 cdp.frq[id] = frq
78