Author: bugman Date: Mon Aug 26 15:34:30 2013 New Revision: 20687 URL: http://svn.gna.org/viewcvs/relax?rev=20687&view=rev Log: Implemented the relax_disp.spin_lock_offset user function. This includes both the front end and the back end specific_analyses.relax_disp.disp_data.spin_lock_offset() function. Modified: branches/relax_disp/specific_analyses/relax_disp/disp_data.py branches/relax_disp/user_functions/relax_disp.py Modified: branches/relax_disp/specific_analyses/relax_disp/disp_data.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/specific_analyses/relax_disp/disp_data.py?rev=20687&r1=20686&r2=20687&view=diff ============================================================================== --- branches/relax_disp/specific_analyses/relax_disp/disp_data.py (original) +++ branches/relax_disp/specific_analyses/relax_disp/disp_data.py Mon Aug 26 15:34:30 2013 @@ -1039,3 +1039,41 @@ print("Setting the '%s' spectrum as the reference." % spectrum_id) else: print("Setting the '%s' spectrum spin-lock field strength to %s kHz." % (spectrum_id, cdp.spin_lock_nu1[spectrum_id]/1000.0)) + + +def spin_lock_offset(spectrum_id=None, offset=None): + """Set the spin-lock offset (omega_rf) for the given spectrum. + + @keyword spectrum_id: The spectrum ID string. + @type spectrum_id: str + @keyword offset: The spin-lock offset (omega_rf) in ppm. + @type offset: int or float + """ + + # Test if the spectrum ID exists. + if spectrum_id not in cdp.spectrum_ids: + raise RelaxNoSpectraError(spectrum_id) + + # Initialise the global offset data structures if needed. + if not hasattr(cdp, 'spin_lock_offset'): + cdp.spin_lock_offset = {} + if not hasattr(cdp, 'spin_lock_offset_list'): + cdp.spin_lock_offset_list = [] + + # Add the offset, converting to a float if needed. + if offset == None: + raise RelaxError("The offset value must be provided.") + cdp.spin_lock_offset[spectrum_id] = float(offset) + + # The unique curves for the R2eff fitting (R1rho). + if cdp.spin_lock_offset[spectrum_id] not in cdp.spin_lock_offset_list: + cdp.spin_lock_offset_list.append(cdp.spin_lock_offset[spectrum_id]) + + # Sort the list. + cdp.spin_lock_offset_list.sort() + + # Update the exponential curve count. + cdp.dispersion_points = len(cdp.spin_lock_offset_list) + + # Printout. + print("Setting the '%s' spectrum spin-lock offset to %s ppm." % (spectrum_id, cdp.spin_lock_offset[spectrum_id])) 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=20687&r1=20686&r2=20687&view=diff ============================================================================== --- branches/relax_disp/user_functions/relax_disp.py (original) +++ branches/relax_disp/user_functions/relax_disp.py Mon Aug 26 15:34:30 2013 @@ -36,7 +36,7 @@ from pipe_control.mol_res_spin import get_spin_ids from graphics import ANALYSIS_IMAGE_PATH, WIZARD_IMAGE_PATH from specific_analyses.relax_disp.cpmgfit import cpmgfit_execute, cpmgfit_input -from specific_analyses.relax_disp.disp_data import cpmg_frq, plot_disp_curves, plot_exp_curves, relax_time, spin_lock_field +from specific_analyses.relax_disp.disp_data import cpmg_frq, plot_disp_curves, plot_exp_curves, relax_time, spin_lock_field, spin_lock_offset from specific_analyses.relax_disp.nessy import nessy_input from specific_analyses.relax_disp.parameters import copy from specific_analyses.relax_disp.sherekhan import sherekhan_input @@ -624,3 +624,37 @@ uf.menu_text = "spin_lock_&field" uf.wizard_size = (800, 500) uf.wizard_image = ANALYSIS_IMAGE_PATH + 'relax_disp_200x200.png' + + +# The relax_disp.spin_lock_offset user function. +uf = uf_info.add_uf('relax_disp.spin_lock_offset') +uf.title = "Set the relaxation dispersion spin-lock offset (omega_rf)." +uf.title_short = "Spin-lock offset." +uf.add_keyarg( + name = "spectrum_id", + py_type = "str", + desc_short = "spectrum ID string", + desc = "The spectrum ID string to associate the spin-lock offset to.", + wiz_element_type = 'combo', + wiz_combo_iter = spectrum.get_ids, + wiz_read_only = True +) +uf.add_keyarg( + name = "offset", + py_type = "num", + desc_short = "spin-lock offset (ppm)", + desc = "The spin-lock offset, omega_rf, in ppm.", + can_be_none = True +) +# Description. +uf.desc.append(Desc_container()) +uf.desc[-1].add_paragraph("This sets the spin-lock offset, omega_rf, for the specified R1rho spectrum in ppm.") +# Prompt examples. +uf.desc.append(Desc_container("Prompt examples")) +uf.desc[-1].add_paragraph("To set a spin-lock offset of 110.0 ppm for the spectrum 'nu1_2.1kHz_relaxT_0.010', type one of:") +uf.desc[-1].add_prompt("relax> relax_disp.spin_lock_offset('nu1_2.1kHz_relaxT_0.010', 110.0)") +uf.desc[-1].add_prompt("relax> relax_disp.spin_lock_offset(spectrum_id='nu1_2.1kHz_relaxT_0.010', offset=110.0)") +uf.backend = spin_lock_offset +uf.menu_text = "spin_lock_&offset" +uf.wizard_size = (800, 500) +uf.wizard_image = ANALYSIS_IMAGE_PATH + 'relax_disp_200x200.png'