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