Author: bugman Date: Tue Dec 18 11:48:26 2012 New Revision: 18164 URL: http://svn.gna.org/viewcvs/relax?rev=18164&view=rev Log: Added the 'units' argument to the frq.set user function to allow values other than Hz to be input. Modified: trunk/generic_fns/frq.py trunk/user_functions/frq.py Modified: trunk/generic_fns/frq.py URL: http://svn.gna.org/viewcvs/relax/trunk/generic_fns/frq.py?rev=18164&r1=18163&r2=18164&view=diff ============================================================================== --- trunk/generic_fns/frq.py (original) +++ trunk/generic_fns/frq.py Tue Dec 18 11:48:26 2012 @@ -51,13 +51,15 @@ return frq -def set(id=None, frq=None): +def set(id=None, frq=None, units='Hz'): """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 + @keyword units: The units of frequency. This can be one of "Hz", "kHz", "MHz", or "GHz". + @type units: str """ # Test if the current data pipe exists. @@ -71,6 +73,18 @@ if id in cdp.frq and cdp.frq[id] != frq: raise RelaxError("The frequency for the experiment '%s' has already been set to %s Hz." % (id, cdp.frq[id])) + # Unit conversion. + if units == 'Hz': + conv = 1.0 + elif units == 'kHz': + conv = 1e3 + elif units == 'MHz': + conv = 1e6 + elif units == 'GHz': + conv = 1e9 + else: + raise RelaxError("The frequency units of '%s' are unknown." % units) + # Set the frequency. - cdp.frq[id] = frq + cdp.frq[id] = frq * conv Modified: trunk/user_functions/frq.py URL: http://svn.gna.org/viewcvs/relax/trunk/user_functions/frq.py?rev=18164&r1=18163&r2=18164&view=diff ============================================================================== --- trunk/user_functions/frq.py (original) +++ trunk/user_functions/frq.py Tue Dec 18 11:48:26 2012 @@ -51,10 +51,25 @@ desc_short = "spectrometer frequency", desc = "The spectrometer frequency in Hertz." ) +uf.add_keyarg( + name = "units", + default = "Hz", + py_type = "str", + desc_short = "frequency units", + desc = "The units of frequency.", + wiz_element_type = "combo", + wiz_combo_choices = [ + "Hz", + "kHz" + "MHz" + "GHz" + ], + wiz_read_only = True +) # Description. uf.desc.append(Desc_container()) -uf.desc[-1].add_paragraph("This allows the spectrometer frequency of a given experiment to be set.") +uf.desc[-1].add_paragraph("This allows the spectrometer frequency of a given experiment to be set. The expected units are that of the proton resonance frequency in Hertz. See the 'sfrq' parameter in the Varian procpar file or the 'SFO1' parameter in the Bruker acqus file for the exact value.") uf.backend = generic_fns.frq.set uf.menu_text = "&set" uf.gui_icon = "oxygen.actions.edit-rename" -uf.wizard_size = (700, 400) +uf.wizard_size = (750, 500)