Author: bugman Date: Wed May 28 11:05:16 2014 New Revision: 23493 URL: http://svn.gna.org/viewcvs/relax?rev=23493&view=rev Log: Renamed the relax_disp.set_grid_r20_from_min_r2eff user function to relax_disp.r20_from_min_r2eff. This follows from the proposal at http://thread.gmane.org/gmane.science.nmr.relax.devel/5957. Modified: trunk/auto_analyses/relax_disp.py trunk/specific_analyses/relax_disp/data.py trunk/test_suite/system_tests/relax_disp.py trunk/test_suite/system_tests/scripts/relax_disp/cpmg_synthetic.py trunk/user_functions/relax_disp.py Modified: trunk/auto_analyses/relax_disp.py URL: http://svn.gna.org/viewcvs/relax/trunk/auto_analyses/relax_disp.py?rev=23493&r1=23492&r2=23493&view=diff ============================================================================== --- trunk/auto_analyses/relax_disp.py (original) +++ trunk/auto_analyses/relax_disp.py Wed May 28 11:05:16 2014 @@ -77,7 +77,7 @@ @type mc_sim_all_models: bool @keyword eliminate: A flag which if True will enable the elimination of failed models and failed Monte Carlo simulations through the eliminate user function. @type eliminate: bool - @keyword set_grid_r20: A flag which if True will set the grid R20 values from the minimum R2eff values through the set_grid_r20_from_min_r2eff user function. This will speed up the grid search with a factor GRID_INC^(Nr_spec_freq). For a CPMG experiment with two fields and standard GRID_INC=21, the speed-up is a factor 441. + @keyword set_grid_r20: A flag which if True will set the grid R20 values from the minimum R2eff values through the r20_from_min_r2eff user function. This will speed up the grid search with a factor GRID_INC^(Nr_spec_freq). For a CPMG experiment with two fields and standard GRID_INC=21, the speed-up is a factor 441. @type set_grid_r20: bool """ @@ -361,7 +361,7 @@ # Speed-up grid-search by using minium R2eff value. if self.set_grid_r20 and model != MODEL_R2EFF: - self.interpreter.relax_disp.set_grid_r20_from_min_r2eff(force=True) + self.interpreter.relax_disp.r20_from_min_r2eff(force=True) # Use pre-run results as the optimisation starting point. if self.pre_run_dir: Modified: trunk/specific_analyses/relax_disp/data.py URL: http://svn.gna.org/viewcvs/relax/trunk/specific_analyses/relax_disp/data.py?rev=23493&r1=23492&r2=23493&view=diff ============================================================================== --- trunk/specific_analyses/relax_disp/data.py (original) +++ trunk/specific_analyses/relax_disp/data.py Wed May 28 11:05:16 2014 @@ -2087,6 +2087,59 @@ # Add the file to the results file list. add_result_file(type='grace', label='Grace', file=file_path) + + +def r20_from_min_r2eff(force=True, verbosity=1): + """Set the R20 values to the minimum R2eff values. + + For a 2 field cpmg experiment with model CR72, that would drop number of uniform grid search point from gridNr^5 to gridNr^3. + For standard 21 grid Nr, it would make the grid search 441 times faster. + + @keyword force: A flag forcing the overwriting of current values. + @type force: bool + @keyword verbosity: A flag specifying to print the setting of values. + @type verbosity: int + """ + + # Number of spectrometer fields. + fields = [None] + field_count = 1 + if hasattr(cdp, 'spectrometer_frq_count'): + fields = cdp.spectrometer_frq_list + field_count = cdp.spectrometer_frq_count + + # Loop over all spins. + for spin, spin_id in spin_loop(return_id=True, skip_desel=True): + # Nothing to do (the R2eff model has no dispersion curves). + if spin.model == MODEL_R2EFF: + print("The spin model is %s. The %s model has no dispersion curves, so will not set the grid values."%(spin.model, spin.model)) + continue + + # Get all the data. + try: + values, errors, missing, frqs, frqs_H, exp_types, relax_times = return_r2eff_arrays(spins=[spin], spin_ids=[spin_id], fields=fields, field_count=field_count) + + # No R2eff data, so skip the rest. + except RelaxError: + continue + + # Loop over the experiments, magnetic fields, and offsets. + for exp_type, frq, offset, ei, mi, oi in loop_exp_frq_offset(return_indices=True): + # No data. + if not len(values[ei][0][mi][oi]): + continue + + # The minimum + min_val = values[ei][0][mi][oi].min() + + # Loop over the parameters for the current model + for param in MODEL_PARAMS[spin.model]: + # Check if the param is r2 + if param in PARAMS_R20: + # Set the value + value.set(val=min_val, param=param, index=mi, spin_id=spin_id, force=force) + if verbosity: + print("For %s, frq=%3.1f, offset=%3.1f, for grid search setting initial %s=%3.2f for spin: %s"%(exp_type, frq/1E6, offset, param, min_val, spin_id)) def r2eff_read(id=None, file=None, dir=None, disp_frq=None, offset=None, spin_id_col=None, mol_name_col=None, res_num_col=None, res_name_col=None, spin_num_col=None, spin_name_col=None, data_col=None, error_col=None, sep=None): @@ -3530,59 +3583,6 @@ print(text) -def set_grid_r20_from_min_r2eff(force=True, verbosity=1): - """Set the R20 values to the minimum R2eff values. - - For a 2 field cpmg experiment with model CR72, that would drop number of uniform grid search point from gridNr^5 to gridNr^3. - For standard 21 grid Nr, it would make the grid search 441 times faster. - - @keyword force: A flag forcing the overwriting of current values. - @type force: bool - @keyword verbosity: A flag specifying to print the setting of values. - @type verbosity: int - """ - - # Number of spectrometer fields. - fields = [None] - field_count = 1 - if hasattr(cdp, 'spectrometer_frq_count'): - fields = cdp.spectrometer_frq_list - field_count = cdp.spectrometer_frq_count - - # Loop over all spins. - for spin, spin_id in spin_loop(return_id=True, skip_desel=True): - # Nothing to do (the R2eff model has no dispersion curves). - if spin.model == MODEL_R2EFF: - print("The spin model is %s. The %s model has no dispersion curves, so will not set the grid values."%(spin.model, spin.model)) - continue - - # Get all the data. - try: - values, errors, missing, frqs, frqs_H, exp_types, relax_times = return_r2eff_arrays(spins=[spin], spin_ids=[spin_id], fields=fields, field_count=field_count) - - # No R2eff data, so skip the rest. - except RelaxError: - continue - - # Loop over the experiments, magnetic fields, and offsets. - for exp_type, frq, offset, ei, mi, oi in loop_exp_frq_offset(return_indices=True): - # No data. - if not len(values[ei][0][mi][oi]): - continue - - # The minimum - min_val = values[ei][0][mi][oi].min() - - # Loop over the parameters for the current model - for param in MODEL_PARAMS[spin.model]: - # Check if the param is r2 - if param in PARAMS_R20: - # Set the value - value.set(val=min_val, param=param, index=mi, spin_id=spin_id, force=force) - if verbosity: - print("For %s, frq=%3.1f, offset=%3.1f, for grid search setting initial %s=%3.2f for spin: %s"%(exp_type, frq/1E6, offset, param, min_val, spin_id)) - - def spin_has_frq_data(spin=None, frq=None): """Determine if the spin has intensity data for the given spectrometer frequency. Modified: trunk/test_suite/system_tests/relax_disp.py URL: http://svn.gna.org/viewcvs/relax/trunk/test_suite/system_tests/relax_disp.py?rev=23493&r1=23492&r2=23493&view=diff ============================================================================== --- trunk/test_suite/system_tests/relax_disp.py (original) +++ trunk/test_suite/system_tests/relax_disp.py Wed May 28 11:05:16 2014 @@ -498,7 +498,7 @@ if GRID: # Set the R20 parameters in the default grid search using the minimum R2eff value. # This speeds it up considerably. - self.interpreter.relax_disp.set_grid_r20_from_min_r2eff(force=False) + self.interpreter.relax_disp.r20_from_min_r2eff(force=False) # Then do grid search. self.interpreter.grid_search(lower=None, upper=None, inc=GRID, constraints=True, verbosity=1) @@ -683,7 +683,7 @@ if GRID: # Set the R20 parameters in the default grid search using the minimum R2eff value. # This speeds it up considerably. - self.interpreter.relax_disp.set_grid_r20_from_min_r2eff(force=False) + self.interpreter.relax_disp.r20_from_min_r2eff(force=False) # Then do grid search. self.interpreter.grid_search(lower=None, upper=None, inc=GRID, constraints=True, verbosity=1) @@ -878,8 +878,8 @@ #ds.resdir = None ds.resdir = ds.tmpdir - # Do set_grid_r20_from_min_r2eff ?. - ds.set_grid_r20_from_min_r2eff = True + # Do r20_from_min_r2eff ?. + ds.r20_from_min_r2eff = True # Remove insignificant level. ds.insignificance = 0.0 @@ -1017,8 +1017,8 @@ #ds.resdir = None ds.resdir = ds.tmpdir - # Do set_grid_r20_from_min_r2eff ?. - ds.set_grid_r20_from_min_r2eff = True + # Do r20_from_min_r2eff ?. + ds.r20_from_min_r2eff = True # Remove insignificant level. ds.insignificance = 0.0 @@ -1159,8 +1159,8 @@ #ds.resdir = None ds.resdir = ds.tmpdir - # Do set_grid_r20_from_min_r2eff ?. - ds.set_grid_r20_from_min_r2eff = True + # Do r20_from_min_r2eff ?. + ds.r20_from_min_r2eff = True # Remove insignificant level. ds.insignificance = 0.0 @@ -1298,8 +1298,8 @@ #ds.resdir = None ds.resdir = ds.tmpdir - # Do set_grid_r20_from_min_r2eff ?. - ds.set_grid_r20_from_min_r2eff = True + # Do r20_from_min_r2eff ?. + ds.r20_from_min_r2eff = True # Remove insignificant level. ds.insignificance = 0.0 @@ -4413,7 +4413,7 @@ self.assertEqual(cdp.mol[0].res[2].spin[0].ri_data['R2eff.600'], 7.2385) - def test_set_grid_r20_from_min_r2eff_cpmg(self): + def test_r20_from_min_r2eff_cpmg(self): """Test speeding up grid search. Support requst sr #3151 U{https://gna.org/support/index.php?3151}. User function to set the R20 parameters in the default grid search using the minimum R2eff value. @@ -4448,7 +4448,7 @@ self.interpreter.relax_disp.select_model(model=MODEL) # Set the R20 parameters in the default grid search using the minimum R2eff value. - self.interpreter.relax_disp.set_grid_r20_from_min_r2eff(force=False) + self.interpreter.relax_disp.r20_from_min_r2eff(force=False) # Test result, for normal run. for spin, mol_name, resi, resn, spin_id in spin_loop(full_info=True, return_id=True, skip_desel=True): @@ -4688,7 +4688,7 @@ clust_results = [] # Set the R20 parameters in the default grid search using the minimum R2eff value. - self.interpreter.relax_disp.set_grid_r20_from_min_r2eff(force=False) + self.interpreter.relax_disp.r20_from_min_r2eff(force=False) # Deselect insignificant spins. self.interpreter.relax_disp.insignificance(level=1.0) Modified: trunk/test_suite/system_tests/scripts/relax_disp/cpmg_synthetic.py URL: http://svn.gna.org/viewcvs/relax/trunk/test_suite/system_tests/scripts/relax_disp/cpmg_synthetic.py?rev=23493&r1=23492&r2=23493&view=diff ============================================================================== --- trunk/test_suite/system_tests/scripts/relax_disp/cpmg_synthetic.py (original) +++ trunk/test_suite/system_tests/scripts/relax_disp/cpmg_synthetic.py Wed May 28 11:05:16 2014 @@ -1,6 +1,7 @@ ############################################################################### # # # Copyright (C) 2013-2014 Troels E. Linnet # +# Copyright (C) 2014 Edward d'Auvergne # # # # This file is part of the program relax (http://www.nmr-relax.com). # # # @@ -122,9 +123,9 @@ if not hasattr(ds, 'resdir'): ds.resdir = None -# Do set_grid_r20_from_min_r2eff. -if not hasattr(ds, 'set_grid_r20_from_min_r2eff'): - ds.set_grid_r20_from_min_r2eff = True +# Do r20_from_min_r2eff. +if not hasattr(ds, 'r20_from_min_r2eff'): + ds.r20_from_min_r2eff = True # Remove insignificant level. if not hasattr(ds, 'insignificance'): @@ -470,8 +471,8 @@ if ds.GRID_INC: # Set the R20 parameters in the default grid search using the minimum R2eff value. # This speeds it up considerably. - if ds.set_grid_r20_from_min_r2eff: - relax_disp.set_grid_r20_from_min_r2eff(force=False) + if ds.r20_from_min_r2eff: + relax_disp.r20_from_min_r2eff(force=False) # Then do grid search. grid_search(lower=None, upper=None, inc=ds.GRID_INC, constraints=True, verbosity=ds.verbosity) Modified: trunk/user_functions/relax_disp.py URL: http://svn.gna.org/viewcvs/relax/trunk/user_functions/relax_disp.py?rev=23493&r1=23492&r2=23493&view=diff ============================================================================== --- trunk/user_functions/relax_disp.py (original) +++ trunk/user_functions/relax_disp.py Wed May 28 11:05:16 2014 @@ -39,7 +39,7 @@ from pipe_control.mol_res_spin import get_spin_ids from specific_analyses.relax_disp.catia import catia_execute, catia_input from specific_analyses.relax_disp.cpmgfit import cpmgfit_execute, cpmgfit_input -from specific_analyses.relax_disp.data import cpmg_setup, insignificance, plot_disp_curves, plot_exp_curves, r2eff_read, r2eff_read_spin, relax_time, set_exp_type, set_grid_r20_from_min_r2eff, spin_lock_field, spin_lock_offset, write_disp_curves +from specific_analyses.relax_disp.data import cpmg_setup, insignificance, plot_disp_curves, plot_exp_curves, r2eff_read, r2eff_read_spin, relax_time, set_exp_type, r20_from_min_r2eff, spin_lock_field, spin_lock_offset, write_disp_curves 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 @@ -922,8 +922,8 @@ uf.wizard_image = ANALYSIS_IMAGE_PATH + 'relax_disp_200x200.png' -# The relax_disp.set_grid_r20_from_min_r2eff user function. -uf = uf_info.add_uf('relax_disp.set_grid_r20_from_min_r2eff') +# The relax_disp.r20_from_min_r2eff user function. +uf = uf_info.add_uf('relax_disp.r20_from_min_r2eff') uf.title = "Set the R20 parameter values to that of the minimum R2eff value." uf.title_short = "Set R20 from the minimum R2eff." uf.add_keyarg( @@ -938,8 +938,8 @@ uf.desc[-1].add_paragraph("Set the R20 parameter values to that of the minimum R2eff value. This user function will look through all R2eff values per magnetic field strength, and find the minimum. This minimum is a very good guess for the minimisation.") uf.desc[-1].add_paragraph("Instead of making the grid search find initial values of the R20 parameter, the minimum for the R2eff points are used instead. For example for a two field CPMG experiment with model CR72, that would drop the number of uniform grid search points from 5D to 3D. For standard 21 grid increments per dimension, it would make the grid search 441 times faster.") uf.desc[-1].add_paragraph("This is an experimental unpublished feature of the dispersion analysis. If R20 << min(R2eff), the grid search will be performed in a region of the optimisation space quite distant from the true minimum. If unsure, do not activate this option, and let the grid search find a better starting value.") -uf.backend = set_grid_r20_from_min_r2eff -uf.menu_text = "&set_grid_r20_from_min_r2eff" +uf.backend = r20_from_min_r2eff +uf.menu_text = "&r20_from_min_r2eff" uf.gui_icon = "relax.grid_search" uf.wizard_size = (800, 500) uf.wizard_apply_button = False