Author: bugman Date: Mon Aug 11 13:59:01 2008 New Revision: 7139 URL: http://svn.gna.org/viewcvs/relax?rev=7139&view=rev Log: Wrote the spectrometer frequency setting function generic_fns.frq.set(). Added: branches/rdc_analysis/generic_fns/frq.py Added: branches/rdc_analysis/generic_fns/frq.py URL: http://svn.gna.org/viewcvs/relax/branches/rdc_analysis/generic_fns/frq.py?rev=7139&view=auto ============================================================================== --- branches/rdc_analysis/generic_fns/frq.py (added) +++ branches/rdc_analysis/generic_fns/frq.py Mon Aug 11 13:59:01 2008 @@ -1,0 +1,58 @@ +############################################################################### +# # +# Copyright (C) 2008 Edward d'Auvergne # +# # +# This file is part of the program relax. # +# # +# relax is free software; you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation; either version 2 of the License, or # +# (at your option) any later version. # +# # +# relax is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with relax; if not, write to the Free Software # +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# # +############################################################################### + +# Module docstring. +"""Module for manipulating the spectrometer frequency of experiments.""" + +# relax module imports. +from data import Relax_data_store; ds = Relax_data_store() +from relax_errors import RelaxError + + +def set(id=None, frq=None): + """Set the spectrometer frequency of the experiment. + + @keyword id: The experimental identification string (allowing for multiple experiments per + data pipe). + @type id: str + @keyword frq: The spectrometer frequency in Hertz. + @type frq: float + """ + + # Test if the current data pipe exists. + if not ds.current_pipe: + raise RelaxNoPipeError + + # Alias the current data pipe. + cdp = ds[ds.current_pipe] + + # Set up the dictionary data structure if it doesn't exist yet. + if not hasattr(cdp, 'frq'): + cdp.frq = {} + + # Test the frequency has not already been set. + if cdp.frq.has_key(id): + raise RelaxError, "The frequency for the experiment " + `id` + " has already been set." + + # Set the frequency. + cdp.frq[id] = frq +