Author: bugman Date: Wed Apr 3 14:03:36 2013 New Revision: 19323 URL: http://svn.gna.org/viewcvs/relax?rev=19323&view=rev Log: Created the relax_disp.spin_lock_field user function. This is used to set the spin-lock field strength of a given R1rho spectrum. 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=19323&r1=19322&r2=19323&view=diff ============================================================================== --- branches/relax_disp/specific_analyses/relax_disp.py (original) +++ branches/relax_disp/specific_analyses/relax_disp.py Wed Apr 3 14:03:36 2013 @@ -29,7 +29,7 @@ from re import match, search # relax module imports. -from lib.errors import RelaxError, RelaxFuncSetupError, RelaxLenError, RelaxNoModelError, RelaxNoSequenceError +from lib.errors import RelaxError, RelaxFuncSetupError, RelaxLenError, RelaxNoModelError, RelaxNoSequenceError, RelaxNoSpectraError from minfx.generic import generic_minimise from pipe_control import pipes from pipe_control.mol_res_spin import exists_mol_res_spin_data, return_spin, spin_loop @@ -263,6 +263,30 @@ # Set up the model. self.model_setup(model, params) + + + def _spin_lock_field(self, spectrum_id=None, field=None): + """Set the spin-lock field strength (nu1) for the given spectrum. + + @keyword spectrum_id: The spectrum ID string. + @type spectrum_id: str + @keyword field: The spin-lock field strength (nu1) in Hz. + @type field: int or float + """ + + # Test if the spectrum ID exists. + if spectrum_id not in cdp.spectrum_ids: + raise RelaxNoSpectraError(spectrum_id) + + # Initialise the global nu1 data structure if needed. + if not hasattr(cdp, 'spin_lock_nu1'): + cdp.spin_lock_nu1 = {} + + # Add the frequency, converting to a float if needed. + cdp.spin_lock_nu1[spectrum_id] = float(field) + + # Printout. + print("Setting the '%s' spectrum spin-lock field strength to %s kHz." % (spectrum_id, cdp.spin_lock_nu1[spectrum_id]/1000.0)) def assemble_param_vector(self, spin=None, sim_index=None): 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=19323&r1=19322&r2=19323&view=diff ============================================================================== --- branches/relax_disp/user_functions/relax_disp.py (original) +++ branches/relax_disp/user_functions/relax_disp.py Wed Apr 3 14:03:36 2013 @@ -271,3 +271,35 @@ uf.wizard_height_desc = 500 uf.wizard_size = (1000, 700) uf.wizard_apply_button = False + + +# The relax_disp.spin_lock_field user function. +uf = uf_info.add_uf('relax_disp.spin_lock_field') +uf.title = "Set the relaxation dispersion spin-lock field strength (nu1)." +uf.title_short = "Spin-lock field strength." +uf.add_keyarg( + name = "spectrum_id", + py_type = "str", + desc_short = "spectrum ID string", + desc = "The spectrum ID string to associate the spin-lock field strength to.", + wiz_element_type = 'combo', + wiz_combo_iter = spectrum.get_ids, + wiz_read_only = True +) +uf.add_keyarg( + name = "field", + py_type = "num", + desc_short = "field strength nu1 (Hz)", + desc = "The spin-lock field strength, nu1, in Hz." +) +# Description. +uf.desc.append(Desc_container()) +uf.desc[-1].add_paragraph("This sets the spin-lock field strength, nu1, for the specified R1rho spectrum in Hertz.") +# Prompt examples. +uf.desc.append(Desc_container("Prompt examples")) +uf.desc[-1].add_paragraph("To set a spin-lock field strength of 2.1 kHz for the spectrum 'nu1_2.1kHz_relaxT_0.010', type one of:") +uf.desc[-1].add_prompt("relax> relax_disp.spin_lock_field(2100, 'nu1_2.1kHz_relaxT_0.010')") +uf.desc[-1].add_prompt("relax> relax_disp.spin_lock_field(field=2100, spectrum_id='nu1_2.1kHz_relaxT_0.010')") +uf.backend = relax_disp_obj._spin_lock_field +uf.menu_text = "spin_lock_&field" +uf.wizard_size = (800, 500)