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 (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 manipulating the spectrometer frequency of experiments.""" 
24   
25  # relax module imports. 
26  from generic_fns import pipes 
27  from relax_errors import RelaxError 
28   
29   
30 -def get_values():
31 """Return a list of all the current frequencies. 32 33 @return: The frequency list for the current data pipe. 34 @rtype: list of float 35 """ 36 37 # No frequency data. 38 if not hasattr(cdp, 'frq'): 39 return [] 40 41 # The frequency values. 42 values = cdp.frq.values() 43 44 # Build a list of the unique frequencies. 45 frq = [] 46 for value in values: 47 if value not in frq: 48 frq.append(value) 49 50 # Return the frqs. 51 return frq
52 53
54 -def set(id=None, frq=None):
55 """Set the spectrometer frequency of the experiment. 56 57 @keyword id: The experimental identification string (allowing for multiple experiments per 58 data pipe). 59 @type id: str 60 @keyword frq: The spectrometer frequency in Hertz. 61 @type frq: float 62 """ 63 64 # Test if the current data pipe exists. 65 pipes.test() 66 67 # Set up the dictionary data structure if it doesn't exist yet. 68 if not hasattr(cdp, 'frq'): 69 cdp.frq = {} 70 71 # Test the frequency has not already been set. 72 if id in cdp.frq: 73 raise RelaxError("The frequency for the experiment " + repr(id) + " has already been set.") 74 75 # Set the frequency. 76 cdp.frq[id] = frq
77