Package specific_analyses :: Package relax_fit :: Module parameter_object
[hide private]
[frames] | no frames]

Source Code for Module specific_analyses.relax_fit.parameter_object

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2004-2014 Edward d'Auvergne                                   # 
  4  #                                                                             # 
  5  # This file is part of the program relax (http://www.nmr-relax.com).          # 
  6  #                                                                             # 
  7  # This program is free software: you can redistribute it and/or modify        # 
  8  # it under the terms of the GNU General Public License as published by        # 
  9  # the Free Software Foundation, either version 3 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # This program is distributed in the hope that it will be useful,             # 
 13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 15  # GNU General Public License for more details.                                # 
 16  #                                                                             # 
 17  # You should have received a copy of the GNU General Public License           # 
 18  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
 19  #                                                                             # 
 20  ############################################################################### 
 21   
 22  # Module docstring. 
 23  """The module for the relaxation curve fitting parameter list object.""" 
 24   
 25  # Python module imports. 
 26  from numpy import average 
 27   
 28  # relax module imports. 
 29  from lib.mathematics import round_to_next_order 
 30  from specific_analyses.parameter_object import Param_list 
 31   
 32   
33 -def i_scaling(model_info=None):
34 """Determine the scaling factor for the peak intensities. 35 36 This is for the scaling of the I0 and Iinf parameters during optimisation. The maximum intensity will be used to scale all values. 37 38 39 @keyword model_info: The spin container and the spin ID string from the _model_loop_spin() specific API method. 40 @type model_info: SpinContainer instance, str 41 @return: The average peak intensity of the first time point. 42 @rtype: float 43 """ 44 45 # Unpack the data. 46 spin, spin_id = model_info 47 48 # The scaling factor as the maximum intensity. 49 return round_to_next_order(max(spin.peak_intensity.values()))
50 51
52 -def i0_upper(incs=None, model_info=None):
53 """Find the upper bound for the I0 parameter. 54 55 @keyword incs: The number of grid search increments. 56 @type incs: int 57 @keyword model_info: The spin container and the spin ID string from the _model_loop_spin() specific API method. 58 @type model_info: SpinContainer instance, str 59 @return: The average peak intensity of the first time point. 60 @rtype: float 61 """ 62 63 # Unpack the data. 64 spin, spin_id = model_info 65 66 # Find the maximum intensity. 67 upper = max(spin.peak_intensity.values()) 68 69 # Multiply the value by 2.0 and then round up to the next order - this will be the upper bound. 70 return round_to_next_order(upper * 2.0)
71 72
73 -def iinf_upper(incs=None, model_info=None):
74 """Find the average intensity of the last time point. 75 76 This is for the grid search upper bound for the Iinf parameter. 77 78 79 @keyword incs: The number of grid search increments. 80 @type incs: int 81 @keyword model_info: The spin container and the spin ID string from the _model_loop_spin() specific API method. 82 @type model_info: SpinContainer instance, str 83 @return: The average peak intensity of the last time point. 84 @rtype: float 85 """ 86 87 # Unpack the data. 88 spin, spin_id = model_info 89 90 # Find the ID of the last time point. 91 max_time = max(cdp.relax_times.values()) 92 for key in cdp.relax_times: 93 if cdp.relax_times[key] == max_time: 94 id = key 95 break 96 97 # The averaged value. 98 upper = average(spin.peak_intensity[id]) 99 100 # Multiply the value by 2.0 and then round up to the next order - this will be the upper bound. 101 return round_to_next_order(upper * 2.0)
102 103 104
105 -class Relax_fit_params(Param_list):
106 """The relaxation curve fitting parameter list singleton.""" 107 108 # Class variable for storing the class instance (for the singleton design pattern). 109 _instance = None 110
111 - def __init__(self):
112 """Define all the parameters of the analysis.""" 113 114 # The object is already initialised. 115 if self._initialised: return 116 117 # Execute the base class __init__() method. 118 Param_list.__init__(self) 119 120 # Add the base data. 121 self._add_peak_intensity() 122 123 # Add the signal to noise ratio. 124 self._add_sn_ratio() 125 126 # Add the base information for the analysis. 127 self._add( 128 'relax_times', 129 scope = 'spin', 130 py_type = dict, 131 grace_string = '\\qRelaxation time period (s)\\Q' 132 ) 133 134 # Add the model variables. 135 self._add_model_info(model_flag=False) 136 137 # Add the model parameters. 138 self._add( 139 'rx', 140 scope = 'spin', 141 default = 8.0, 142 units = 'rad.s^-1', 143 desc = 'Either the R1 or R2 relaxation rate', 144 set = 'params', 145 py_type = float, 146 scaling = 1.0, 147 grid_lower = 0.0, 148 grid_upper = 20.0, 149 grace_string = '\\qR\\sx\\Q', 150 err = True, 151 sim = True 152 ) 153 self._add( 154 'i0', 155 scope = 'spin', 156 default = 10000.0, 157 desc = 'The initial intensity', 158 py_type = float, 159 set = 'params', 160 scaling = i_scaling, 161 grid_lower = 0.0, 162 grid_upper = i0_upper, 163 grace_string = '\\qI\\s0\\Q', 164 err = True, 165 sim = True 166 ) 167 self._add( 168 'iinf', 169 scope = 'spin', 170 default = 0.0, 171 desc = 'The intensity at infinity', 172 py_type = float, 173 set = 'params', 174 scaling = i_scaling, 175 grid_lower = 0.0, 176 grid_upper = iinf_upper, 177 grace_string = '\\qI\\sinf\\Q', 178 err = True, 179 sim = True 180 ) 181 182 # Add the minimisation data. 183 self._add_min_data(min_stats_global=False, min_stats_spin=True) 184 185 # Set up the user function documentation. 186 self._set_uf_title("Relaxation curve fitting parameters") 187 self._uf_param_table(label="table: curve-fit parameters", caption="Relaxation curve fitting parameters.") 188 self._uf_param_table(label="table: curve-fit parameters and min stats", caption="Relaxation curve fitting parameters and minimisation statistics.", sets=['params', 'fixed', 'min']) 189 self._uf_param_table(label="table: curve-fit parameter value setting", caption="Relaxation curve fitting parameters.") 190 self._uf_param_table(label="table: curve-fit parameter value setting with defaults", caption="Relaxation curve fitting parameter value setting.", default=True)
191