Author: bugman Date: Tue Dec 18 11:52:56 2012 New Revision: 18166 URL: http://svn.gna.org/viewcvs/relax?rev=18166&view=rev Log: Merged revisions 18164-18165 via svnmerge from svn+ssh://bugman@xxxxxxxxxxx/svn/relax/trunk ........ r18164 | bugman | 2012-12-18 11:48:26 +0100 (Tue, 18 Dec 2012) | 3 lines Added the 'units' argument to the frq.set user function to allow values other than Hz to be input. ........ r18165 | bugman | 2012-12-18 11:52:35 +0100 (Tue, 18 Dec 2012) | 3 lines The frq.set user function now warns if the frequency is lower than 100 MHz or higher than 2 GHz. ........ Modified: branches/frame_order_testing/ (props changed) branches/frame_order_testing/generic_fns/frq.py branches/frame_order_testing/user_functions/frq.py Propchange: branches/frame_order_testing/ ------------------------------------------------------------------------------ --- svnmerge-integrated (original) +++ svnmerge-integrated Tue Dec 18 11:52:56 2012 @@ -1,1 +1,1 @@ -/trunk:1-18160 +/trunk:1-18165 Modified: branches/frame_order_testing/generic_fns/frq.py URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_testing/generic_fns/frq.py?rev=18166&r1=18165&r2=18166&view=diff ============================================================================== --- branches/frame_order_testing/generic_fns/frq.py (original) +++ branches/frame_order_testing/generic_fns/frq.py Tue Dec 18 11:52:56 2012 @@ -22,9 +22,13 @@ # Module docstring. """Module for manipulating the spectrometer frequency of experiments.""" +# Python module imports. +from warnings import warn + # relax module imports. from generic_fns import pipes from relax_errors import RelaxError +from relax_warnings import RelaxWarning def get_values(): @@ -51,13 +55,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 +77,23 @@ 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 + # Warnings. + if cdp.frq[id] < 1e8: + warn(RelaxWarning("The proton frequency of %s Hz appears to be too low." % cdp.frq[id]) + if cdp.frq[id] > 2e9: + warn(RelaxWarning("The proton frequency of %s Hz appears to be too high." % cdp.frq[id]) Modified: branches/frame_order_testing/user_functions/frq.py URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_testing/user_functions/frq.py?rev=18166&r1=18165&r2=18166&view=diff ============================================================================== --- branches/frame_order_testing/user_functions/frq.py (original) +++ branches/frame_order_testing/user_functions/frq.py Tue Dec 18 11:52:56 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)