Author: bugman Date: Wed Apr 3 19:18:47 2013 New Revision: 19336 URL: http://svn.gna.org/viewcvs/relax?rev=19336&view=rev Log: Modified the relax_disp.cpmg_frq user function to match relax_disp.spin_lock_field. Both the front and back ends now use the same logic as the relax_disp.spin_lock_field user function and will allow some sanity to the analysis specific code. Modified: branches/relax_disp/specific_analyses/relax_disp.py branches/relax_disp/user_functions/relax_disp.py Modified: branches/relax_disp/specific_analyses/relax_disp.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/specific_analyses/relax_disp.py?rev=19336&r1=19335&r2=19336&view=diff ============================================================================== --- branches/relax_disp/specific_analyses/relax_disp.py (original) +++ branches/relax_disp/specific_analyses/relax_disp.py Wed Apr 3 19:18:47 2013 @@ -320,39 +320,28 @@ print("The CPMG delay T for experiment '%s' has been set to %s s." % (id, cdp.delayT[id])) - def _cpmg_frq(self, cpmg_frq=None, spectrum_id=None): + def _cpmg_frq(self, spectrum_id=None, cpmg_frq=None): """Set the CPMG frequency associated with a given spectrum. + @keyword spectrum_id: The spectrum identification string. + @type spectrum_id: str @keyword cpmg_frq: The frequency, in Hz, of the CPMG pulse train. @type cpmg_frq: float - @keyword spectrum_id: The spectrum identification string. - @type spectrum_id: str """ # Test if the spectrum id exists. if spectrum_id not in cdp.spectrum_ids: - raise RelaxError("The peak heights corresponding to spectrum id '%s' have not been loaded." % spectrum_id) - - # Store the CPMG frequency in the class instance. - if cpmg_frq != None: - self.__cpmg_frq = float(cpmg_frq) - - # The index. - index = cdp.spectrum_ids.index(spectrum_id) + raise RelaxNoSpectraError(spectrum_id) # Initialise the global CPMG frequency data structure if needed. if not hasattr(cdp, 'cpmg_frqs'): - cdp.cpmg_frqs = [None] * len(cdp.spectrum_ids) - - # Index not present in the global CPMG frequency data structure. - while 1: - if index > len(cdp.cpmg_frqs) - 1: - cdp.cpmg_frqs.append(None) - else: - break - - # Add the frequency at the correct position. - cdp.cpmg_frqs[index] = cpmg_frq + cdp.cpmg_frqs = {} + + # Add the frequency at the correct position, converting to a float if needed. + cdp.cpmg_frqs[spectrum_id] = float(cpmg_frq) + + # Printout. + print("Setting the '%s' spectrum CPMG frequency %s Hz." % (spectrum_id, cdp.cpmg_frqs[spectrum_id])) def _calc_r2eff(self, exp_type='cpmg', id=None, delayT=None, int_cpmg=1.0, int_ref=1.0): Modified: branches/relax_disp/user_functions/relax_disp.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/user_functions/relax_disp.py?rev=19336&r1=19335&r2=19336&view=diff ============================================================================== --- branches/relax_disp/user_functions/relax_disp.py (original) +++ branches/relax_disp/user_functions/relax_disp.py Wed Apr 3 19:18:47 2013 @@ -143,17 +143,20 @@ uf.title = "Set the CPMG frequency associated with a given spectrum." uf.title_short = "CPMG frequency setting." uf.add_keyarg( + name = "spectrum_id", + py_type = "str", + desc_short = "spectrum ID string", + desc = "The spectrum ID string to associate the CPMG frequency to.", + wiz_element_type = 'combo', + wiz_combo_iter = spectrum.get_ids, + wiz_read_only = True +) +uf.add_keyarg( name = "cpmg_frq", py_type = "num", desc_short = "CPMG frequency (Hz)", desc = "The frequency, in Hz, of the CPMG pulse train.", can_be_none = True -) -uf.add_keyarg( - name = "spectrum_id", - py_type = "str", - desc_short = "spectrum ID string", - desc = "The spectrum ID string." ) # Description. uf.desc.append(Desc_container())