Changes in / [13f5656:131d94b] in sasview
- Files:
-
- 2 added
- 4 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
docs/sphinx-docs/source/dev/dev.rst
re8447d8 r476d4e3 1 1 Developer Documentation 2 2 ======================= 3 4 .. note:: In Windows use [Alt]-[Cursor left] to return to the previous page5 3 6 4 Contents -
docs/sphinx-docs/source/user/tutorial.rst
re8447d8 rec860a8f 6 6 ======== 7 7 8 .. note:: In Windows use [Alt]-[Cursor left] to return to the previous page9 10 8 :download:`Tutorial <../../../../sasview/media/Tutorial.pdf>` -
src/sas/sascalc/fit/MultiplicationModel.py
rfd62331 rcb4ef58 8 8 r""" 9 9 Use for P(Q)\*S(Q); function call must be in the order of P(Q) and then S(Q): 10 The model parameters are combined from both models, P(Q) and S(Q), except 1) ' radius_effective' of S(Q)11 which will be calculated from P(Q) via calculate_ER(), 12 and 2) 'scale' in P model which is synchronized w/ volfraction in S 10 The model parameters are combined from both models, P(Q) and S(Q), except 1) 'effect_radius' of S(Q) 11 which will be calculated from P(Q) via calculate_ER(), 12 and 2) 'scale' in P model which is synchronized w/ volfraction in S 13 13 then P*S is multiplied by a new parameter, 'scale_factor'. 14 14 The polydispersion is applicable only to P(Q), not to S(Q). … … 34 34 ## Parameter details [units, min, max] 35 35 self.details = {} 36 37 ## Define parameters to exclude from multiplication model 38 self.excluded_params={'radius_effective','scale','background'} 39 40 ##models 36 37 ##models 41 38 self.p_model = p_model 42 self.s_model = s_model 39 self.s_model = s_model 43 40 self.magnetic_params = [] 44 41 ## dispersion … … 48 45 ## New parameter:Scaling factor 49 46 self.params['scale_factor'] = 1 50 self.params['background'] = 0 51 47 52 48 ## Parameter details [units, min, max] 53 49 self._set_details() 54 50 self.details['scale_factor'] = ['', 0.0, numpy.inf] 55 self.details['background'] = ['',-numpy.inf,numpy.inf] 56 51 57 52 #list of parameter that can be fitted 58 self._set_fixed_params() 53 self._set_fixed_params() 59 54 ## parameters with orientation 60 55 for item in self.p_model.orientation_params: 61 56 self.orientation_params.append(item) 62 for item in self.p_model.magnetic_params: 63 self.magnetic_params.append(item) 57 for item in self.p_model.magnetic_params: 58 self.magnetic_params.append(item) 64 59 for item in self.s_model.orientation_params: 65 60 if not item in self.orientation_params: … … 71 66 multiplicity = 1 72 67 ## functional multiplicity of the model 73 self.multiplicity = multiplicity 74 68 self.multiplicity = multiplicity 69 75 70 # non-fittable parameters 76 self.non_fittable = p_model.non_fittable 77 self.multiplicity_info = [] 71 self.non_fittable = p_model.non_fittable 72 self.multiplicity_info = [] 78 73 self.fun_list = {} 79 74 if self.non_fittable > 1: 80 75 try: 81 self.multiplicity_info = p_model.multiplicity_info 76 self.multiplicity_info = p_model.multiplicity_info 82 77 self.fun_list = p_model.fun_list 83 78 self.is_multiplicity_model = True … … 87 82 self.is_multiplicity_model = False 88 83 self.multiplicity_info = [0] 89 84 90 85 def _clone(self, obj): 91 86 """ … … 101 96 #obj = copy.deepcopy(self) 102 97 return obj 103 104 98 99 105 100 def _set_dispersion(self): 106 101 """ … … 108 103 applied to s_model 109 104 """ 110 ##set dispersion only from p_model 105 ##set dispersion only from p_model 111 106 for name , value in self.p_model.dispersion.iteritems(): 112 self.dispersion[name] = value 113 107 self.dispersion[name] = value 108 114 109 def getProfile(self): 115 110 """ 116 111 Get SLD profile of p_model if exists 117 112 118 113 :return: (r, beta) where r is a list of radius of the transition points\ 119 114 beta is a list of the corresponding SLD values … … 126 121 x = None 127 122 y = None 128 123 129 124 return x, y 130 125 131 126 def _set_params(self): 132 127 """ 133 128 Concatenate the parameters of the two models to create 134 these model parameters 129 these model parameters 135 130 """ 136 131 137 132 for name , value in self.p_model.params.iteritems(): 138 if not name in self.params.keys() and name not in self.excluded_params:133 if not name in self.params.keys() and name != 'scale': 139 134 self.params[name] = value 140 135 141 136 for name , value in self.s_model.params.iteritems(): 142 #Remove the radius_effectivefrom the (P*S) model parameters.143 if not name in self.params.keys() and name not in self.excluded_params:137 #Remove the effect_radius from the (P*S) model parameters. 138 if not name in self.params.keys() and name != 'effect_radius': 144 139 self.params[name] = value 145 140 146 141 # Set "scale and effec_radius to P and S model as initializing 147 142 # since run P*S comes from P and S separately. 148 self._set_backgrounds()149 143 self._set_scale_factor() 150 self._set_ radius_effective()151 144 self._set_effect_radius() 145 152 146 def _set_details(self): 153 147 """ 154 148 Concatenate details of the two models to create 155 this model's details 149 this model's details 156 150 """ 157 151 for name, detail in self.p_model.details.iteritems(): 158 if name not in self.excluded_params:152 if name != 'scale': 159 153 self.details[name] = detail 160 154 161 155 for name , detail in self.s_model.details.iteritems(): 162 if not name in self.details.keys() or name not in self.exluded_params:156 if not name in self.details.keys() or name != 'effect_radius': 163 157 self.details[name] = detail 164 165 def _set_backgrounds(self): 166 """ 167 Set component backgrounds to zero 168 """ 169 self.p_model.setParam('background',0) 170 self.s_model.setParam('background',0) 171 172 158 173 159 def _set_scale_factor(self): 174 160 """ … … 176 162 """ 177 163 value = self.params['volfraction'] 178 if value != None: 164 if value != None: 179 165 factor = self.p_model.calculate_VR() 180 166 if factor == None or factor == NotImplemented or factor == 0.0: … … 184 170 self.p_model.setParam('scale', value) 185 171 self.s_model.setParam('volfraction', val) 186 187 def _set_ radius_effective(self):172 173 def _set_effect_radius(self): 188 174 """ 189 175 Set effective radius to S(Q) model 190 176 """ 191 if not ' radius_effective' in self.s_model.params.keys():177 if not 'effect_radius' in self.s_model.params.keys(): 192 178 return 193 179 effective_radius = self.p_model.calculate_ER() 194 180 #Reset the effective_radius of s_model just before the run 195 181 if effective_radius != None and effective_radius != NotImplemented: 196 self.s_model.setParam(' radius_effective', effective_radius)197 182 self.s_model.setParam('effect_radius', effective_radius) 183 198 184 def setParam(self, name, value): 199 """ 185 """ 200 186 Set the value of a model parameter 201 187 202 188 :param name: name of the parameter 203 189 :param value: value of the parameter … … 205 191 # set param to P*S model 206 192 self._setParamHelper( name, value) 207 208 ## setParam to p model 209 # set 'scale' in P(Q) equal to volfraction 193 194 ## setParam to p model 195 # set 'scale' in P(Q) equal to volfraction 210 196 if name == 'volfraction': 211 197 self._set_scale_factor() 212 elif name in self.p_model.getParamList() and name not in self.excluded_params:198 elif name in self.p_model.getParamList(): 213 199 self.p_model.setParam( name, value) 214 215 ## setParam to s model 216 # This is a little bit abundant: Todo: find better way 217 self._set_ radius_effective()218 if name in self.s_model.getParamList() and name not in self.excluded_params:200 201 ## setParam to s model 202 # This is a little bit abundant: Todo: find better way 203 self._set_effect_radius() 204 if name in self.s_model.getParamList(): 219 205 if name != 'volfraction': 220 206 self.s_model.setParam( name, value) 221 207 222 208 223 209 #self._setParamHelper( name, value) 224 210 225 211 def _setParamHelper(self, name, value): 226 212 """ … … 242 228 self.params[item] = value 243 229 return 244 230 245 231 raise ValueError, "Model does not contain parameter %s" % name 246 247 232 233 248 234 def _set_fixed_params(self): 249 235 """ … … 254 240 255 241 self.fixed.sort() 256 257 242 243 258 244 def run(self, x = 0.0): 259 """ 245 """ 260 246 Evaluate the model 261 247 262 248 :param x: input q-value (float or [float, float] as [r, theta]) 263 249 :return: (scattering function value) 264 250 """ 265 251 # set effective radius and scaling factor before run 266 self._set_ radius_effective()252 self._set_effect_radius() 267 253 self._set_scale_factor() 268 254 return self.params['scale_factor'] * self.p_model.run(x) * \ 269 self.s_model.run(x) + self.params['background']255 self.s_model.run(x) 270 256 271 257 def runXY(self, x = 0.0): 272 """ 258 """ 273 259 Evaluate the model 274 260 275 261 :param x: input q-value (float or [float, float] as [qx, qy]) 276 262 :return: scattering function value 277 """ 263 """ 278 264 # set effective radius and scaling factor before run 279 self._set_ radius_effective()265 self._set_effect_radius() 280 266 self._set_scale_factor() 281 267 out = self.params['scale_factor'] * self.p_model.runXY(x) * \ 282 self.s_model.runXY(x) + self.params['background']268 self.s_model.runXY(x) 283 269 return out 284 285 ## Now (May27,10) directly uses the model eval function 270 271 ## Now (May27,10) directly uses the model eval function 286 272 ## instead of the for-loop in Base Component. 287 273 def evalDistribution(self, x = []): 288 """ 274 """ 289 275 Evaluate the model in cartesian coordinates 290 276 291 277 :param x: input q[], or [qx[], qy[]] 292 278 :return: scattering function P(q[]) 293 279 """ 294 280 # set effective radius and scaling factor before run 295 self._set_ radius_effective()281 self._set_effect_radius() 296 282 self._set_scale_factor() 297 283 out = self.params['scale_factor'] * self.p_model.evalDistribution(x) * \ 298 self.s_model.evalDistribution(x) + self.params['background']284 self.s_model.evalDistribution(x) 299 285 return out 300 286 … … 302 288 """ 303 289 Set the dispersion object for a model parameter 304 290 305 291 :param parameter: name of the parameter [string] 306 292 :dispersion: dispersion object of type DispersionModel … … 313 299 return value 314 300 except: 315 raise 301 raise 316 302 317 303 def fill_description(self, p_model, s_model): … … 320 306 """ 321 307 description = "" 322 description += "Note:1) The radius_effective(effective radius) of %s \n"%\308 description += "Note:1) The effect_radius (effective radius) of %s \n"%\ 323 309 (s_model.name) 324 310 description += " is automatically calculated " … … 332 318 description += " for details of individual models." 333 319 self.description += description 320 -
src/sas/sasgui/perspectives/calculator/media/python_shell_help.rst
rafb93df rd85c194 3 3 .. This is a port of the original SasView html help file to ReSTructured text 4 4 .. by S King, ISIS, during SasView CodeCamp-III in Feb 2015. 5 .. Text revised during Code Camp V in Oct 2016.6 5 7 .. _Python_shell: 8 9 Python Shell-Editor Tool 10 ======================== 6 Python Shell Tool 7 ================= 11 8 12 9 Description 13 10 ----------- 14 11 15 This is a Python shell/editor provided with WxPython. 12 This is a Python shell/editor (PyCrust) provided with WxPython. An editing 13 notebook will show up when a Python file is created/loaded with the *New* or 14 *Open* options on the menu. 16 15 17 For the help about Python, visit the website http://docs.python.org/tutorial/ 16 *Run* enables the editor to compile and run the Python code. 18 17 19 .. note:: This shell/editor has its own help, but the Help() and Credits() calls do not work on Macs. 18 For the details about the Python, visit the website http://docs.python.org/tutorial/ 20 19 21 The NumPy, SciPy, and Matplotlib, etc, libraries are shipped with SasView and so functions from these can be imported into the shell/editor, however, some functionality may not work. 20 The NumPy, SciPy, and Matplotlib, etc, libraries are shipped with SasView. 21 However, some functionality may not work. 22 22 23 .. image:: new_pycrust_example.png 24 :align: center 23 PyCrust has its own Help. 25 24 26 When a Python file, for example a fitting model, is created or loaded with the *New* or *Open* options from the menu, a new tab opens with an editing notebook. 25 *NOTE! The Help() and Credits() calls do not work on Macs.* 27 26 28 .. image:: new_pycrust_example_2.png 29 :align: center 27 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 30 28 31 If a Python (.py) model has a linked C (.c) subroutine *in the same folder* then the shell/editor will open both! However input focus is usually transferred to the tab with the .c file. 29 Example 30 ------- 32 31 33 To compile a model, select *Run* > *Check Model* from the shell/editor menu. If the model contains a unit test (which it should!!!) then this will also run and a popup window will report the success/failure of the test. 32 An example calling the Matplotlib plotting gallery: 33 34 .. image:: pycrust_example.png 34 35 35 36 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 36 37 37 .. note:: This help document was last changed by Steve King, 1 0Oct201538 .. note:: This help document was last changed by Steve King, 19Feb2015 -
src/sas/sasgui/perspectives/fitting/media/fitting.rst
re8447d8 r2a6d757 3 3 Fitting Documentation 4 4 ===================== 5 6 .. note:: In Windows use [Alt]-[Cursor left] to return to the previous page7 5 8 6 .. toctree:: -
src/sas/sasgui/perspectives/fitting/media/fitting_help.rst
rafb93df r05829fb 141 141 From the *Fitting* option in the menu bar, select *Edit Custom Model*. 142 142 143 .. image:: edit_model_menu. png143 .. image:: edit_model_menu.bmp 144 144 145 145 and then one of the options 146 146 147 * *New* - to create a custom model template with a help dialog148 * *Sum|Multi(p1,p2)* - to create a custom model by summing/multiplying *existing models*in the model library149 * *Advanced* - to create/edit a custom model in a Python shell147 * *New* - to create a new custom model template 148 * *Sum|Multi(p1,p2)* - to create a new model by summing/multiplying existing models in the model library 149 * *Advanced* - to edit a new custom model 150 150 * *Delete* - to delete a custom model 151 * *Load* - to (re-)load custom models152 151 153 152 New … … 185 184 ^^^^^^^^ 186 185 187 Selecting this option shows all the custom models in the plugin model folder , on Windows this is188 189 *C:\\Users\\ {username}\\.sasview\\plugin_models*186 Selecting this option shows all the custom models in the plugin model folder 187 188 *C:\\Users\\[username]\\.sasview\\plugin_models* - (on Windows) 190 189 191 190 You can edit, modify, and save the Python code in any of these models using the 192 *Advanced Custom Model Editor*. Note that this is actually the same tool as the :ref:`Python_shell` . 193 194 For details of the SasView plugin model format see :ref:`Writing_a_Plugin` . 195 196 .. note:: Model files generated with the Sum/Multi option are still using the SasView 3.x model format. Unless you are confident about what you are doing, it is recommended that you only modify lines denoted with the ## <----- comments! 197 198 When editing is complete, select *Run* > *Check Model* from the *Advanced Custom Model Editor* menu bar. An *Info* box will appear with the results of the compilation and model unit tests. The model will only be usable if the tests 'pass'. 191 *Advanced Custom Model Editor*. 192 193 See :ref:`Writing_a_Plugin` for details on the plugin format. 194 195 *NB: Sum/Product models are still using the SasView 3.x model format. Unless 196 you are confident about what you are doing, it is recommended that you 197 only modify lines denoted with the ## <----- comments!* 198 199 When editing is complete, select *Run -> Compile* from the *Model Editor* menu bar. An 200 *Info* box will appear with the results of the compilation and model unit tests. The 201 model will only be usable if the tests 'pass'. 199 202 200 203 To use the model, go to the relevant *Fit Page*, select the *Customized Models* 201 204 category and then select the model from the drop-down menu. 202 205 203 Any changes to a custom model generated in this way only become effective *after* it is re-selected from the model drop-down menu on the FitPage. 206 *NB: Any changes to a custom model generated in this way only become effective after* 207 *it is re-selected from the model drop-down menu on the Fit Page.* 204 208 205 209 Delete … … 209 213 210 214 *NB: Custom models shipped with SasView cannot be removed in this way.* 211 212 Load213 ^^^^214 215 This option loads (or re-loads) all models present in the plugin model folder.216 215 217 216 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
Note: See TracChangeset
for help on using the changeset viewer.