[ec392464] | 1 | .. fitting_help.rst |
---|
| 2 | |
---|
| 3 | .. This is a port of the original SasView html help file to ReSTructured text |
---|
| 4 | .. by S King, ISIS, during SasView CodeCamp-III in Feb 2015. |
---|
| 5 | |
---|
| 6 | .. |beta| unicode:: U+03B2 |
---|
| 7 | .. |gamma| unicode:: U+03B3 |
---|
| 8 | .. |mu| unicode:: U+03BC |
---|
| 9 | .. |sigma| unicode:: U+03C3 |
---|
| 10 | .. |phi| unicode:: U+03C6 |
---|
| 11 | .. |theta| unicode:: U+03B8 |
---|
[98b30b4] | 12 | .. |chi| unicode:: U+03C7 |
---|
| 13 | |
---|
| 14 | .. |inlineimage004| image:: sm_image004.gif |
---|
| 15 | .. |inlineimage005| image:: sm_image005.gif |
---|
| 16 | .. |inlineimage008| image:: sm_image008.gif |
---|
| 17 | .. |inlineimage009| image:: sm_image009.gif |
---|
| 18 | .. |inlineimage010| image:: sm_image010.gif |
---|
| 19 | .. |inlineimage011| image:: sm_image011.gif |
---|
| 20 | .. |inlineimage012| image:: sm_image012.gif |
---|
| 21 | .. |inlineimage018| image:: sm_image018.gif |
---|
| 22 | .. |inlineimage019| image:: sm_image019.gif |
---|
| 23 | |
---|
[ec392464] | 24 | |
---|
| 25 | Fitting Perspective |
---|
| 26 | =================== |
---|
| 27 | |
---|
[a6f3613] | 28 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 29 | |
---|
| 30 | Preparing to fit data |
---|
| 31 | --------------------- |
---|
| 32 | |
---|
| 33 | To fit some data you must first load some data, activate one or more data sets, |
---|
| 34 | send those data sets to the fitting perspective, and select a model to fit to |
---|
| 35 | each data set. |
---|
| 36 | |
---|
[f3377b8] | 37 | Instructions on how to load and activate data are in the section :ref:`Loading_data`. |
---|
[ec392464] | 38 | |
---|
[a6f3613] | 39 | SasView can fit data in one of three ways: |
---|
[ec392464] | 40 | |
---|
[a6f3613] | 41 | * in *Single* fit mode - individual data sets are fitted independently one-by-one |
---|
[ec392464] | 42 | |
---|
[f3377b8] | 43 | * in *Simultaneous* fit mode - multiple data sets are fitted simultaneously to the *same* model with/without constrained parameters (this might be useful, for example, if you have measured the same sample at different contrasts) |
---|
[ec392464] | 44 | |
---|
[f3377b8] | 45 | * in *Batch* fit mode - multiple data sets are fitted sequentially to the *same* model (this might be useful, for example, if you have performed a kinetic or time-resolved experiment and have *lots* of data sets!) |
---|
[a6f3613] | 46 | |
---|
| 47 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
[ec392464] | 48 | |
---|
[a6f3613] | 49 | Selecting a model |
---|
| 50 | ----------------- |
---|
[ec392464] | 51 | |
---|
[a6f3613] | 52 | By default, the models in SasView are grouped into five categories |
---|
[ec392464] | 53 | |
---|
[a6f3613] | 54 | * *Shapes* - models describing 'objects' (spheres, cylinders, etc) |
---|
[f3377b8] | 55 | * *Shape-Independent* - models describing structure in terms of density correlation functions, fractals, peaks, power laws, etc |
---|
[8570246] | 56 | * *Customized Models* - SasView- or User-created (non-library) Python models |
---|
[a6f3613] | 57 | * *Uncategorised* - other models (for reflectivity, etc) |
---|
| 58 | * *Structure Factor* - S(Q) models |
---|
[ec392464] | 59 | |
---|
[a6f3613] | 60 | Use the *Category* drop-down menu to chose a category of model, then select |
---|
[f3377b8] | 61 | a model from the drop-down menu beneath. A graph of the chosen model, calculated |
---|
| 62 | using default parameter values, will appear. The graph will update dynamically |
---|
| 63 | as the parameter values are changed. |
---|
| 64 | |
---|
| 65 | You can decide your own model categorizations using the :ref:`Category_Manager`. |
---|
[ce62e75] | 66 | |
---|
[a6f3613] | 67 | Once you have selected a model you can read its help documentation by clicking |
---|
| 68 | on the *Description* button to the right. |
---|
| 69 | |
---|
| 70 | Show 1D/2D |
---|
| 71 | ^^^^^^^^^^ |
---|
| 72 | |
---|
| 73 | Models are normally fitted to 1D (ie, I(Q) vs Q) data sets, but some models in |
---|
| 74 | SasView can also be fitted to 2D (ie, I(Qx,Qy) vs Qx vs Qy) data sets. |
---|
| 75 | |
---|
| 76 | *NB: Magnetic scattering can only be fitted in SasView in 2D.* |
---|
| 77 | |
---|
| 78 | To activate 2D fitting mode, click the *Show 2D* button on the *Fit Page*. To |
---|
| 79 | return to 1D fitting model, click the same button (which will now say *Show 1D*). |
---|
[ce62e75] | 80 | |
---|
[ec392464] | 81 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 82 | |
---|
[a6f3613] | 83 | .. _Category_Manager: |
---|
[a0637de] | 84 | |
---|
[a6f3613] | 85 | Category Manager |
---|
| 86 | ---------------- |
---|
| 87 | |
---|
[f3377b8] | 88 | To change the model categorizations, either choose *Category Manager* from the |
---|
| 89 | *View* option on the menubar, or click on the *Modify* button on the *Fit Page*. |
---|
[a6f3613] | 90 | |
---|
[f3377b8] | 91 | .. image:: cat_fig0.bmp |
---|
[a6f3613] | 92 | |
---|
[f3377b8] | 93 | The categorization of all models except the customized models can be reassigned, |
---|
| 94 | added to, and removed using *Category Manager*. Models can also be hidden from view |
---|
| 95 | in the drop-down menus. |
---|
[a6f3613] | 96 | |
---|
[f3377b8] | 97 | .. image:: cat_fig1.bmp |
---|
[a6f3613] | 98 | |
---|
[f3377b8] | 99 | Changing category |
---|
| 100 | ^^^^^^^^^^^^^^^^^ |
---|
[a6f3613] | 101 | |
---|
[f3377b8] | 102 | To change category, highlight a model in the list by left-clicking on its entry and |
---|
| 103 | then click the *Modify* button. Use the *Change Category* panel that appears to make |
---|
| 104 | the required changes. |
---|
[a6f3613] | 105 | |
---|
[f3377b8] | 106 | .. image:: cat_fig2.bmp |
---|
[a6f3613] | 107 | |
---|
[f3377b8] | 108 | To create a category for the selected model, click the *Add* button. In order |
---|
| 109 | to delete a category, select the category name and click the *Remove Selected* |
---|
| 110 | button. Then click *Done*. |
---|
[a6f3613] | 111 | |
---|
[f3377b8] | 112 | Showing/hiding models |
---|
| 113 | ^^^^^^^^^^^^^^^^^^^^^ |
---|
[a6f3613] | 114 | |
---|
[8570246] | 115 | Use the *Enable All / Disable All* buttons and the check boxes beside each model to |
---|
[f3377b8] | 116 | select the models to show/hide. To apply the selection, click *Ok*. Otherwise click |
---|
| 117 | *Cancel*. |
---|
[a6f3613] | 118 | |
---|
[8570246] | 119 | *NB: It may be necessary to change to a different category and then back again* |
---|
[f3377b8] | 120 | *before any changes take effect.* |
---|
[a6f3613] | 121 | |
---|
| 122 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 123 | |
---|
[f3377b8] | 124 | Model Functions |
---|
| 125 | --------------- |
---|
[a6f3613] | 126 | |
---|
[f3377b8] | 127 | For a complete list of all the library models available in SasView, see the section |
---|
| 128 | :ref:`SasView_model_functions`. |
---|
[a6f3613] | 129 | |
---|
[f3377b8] | 130 | It is also possible to add your own models. |
---|
[a6f3613] | 131 | |
---|
[f3377b8] | 132 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
[a6f3613] | 133 | |
---|
[f3377b8] | 134 | Adding your own models |
---|
| 135 | ---------------------- |
---|
[a6f3613] | 136 | |
---|
[f3377b8] | 137 | There are currently two ways to add your own models to SasView: |
---|
| 138 | |
---|
[8570246] | 139 | * Using the :ref:`Custom_Model_Editor` |
---|
| 140 | * By :ref:`Writing_a_Plugin` |
---|
[f3377b8] | 141 | |
---|
| 142 | *NB: Because of the way these options are implemented, it is not possible for them* |
---|
| 143 | *to use the polydispersity algorithms in SasView. Only models in the model library* |
---|
| 144 | *can do this. At the time of writing (Release 3.1.0) work is in hand to make it* |
---|
| 145 | *easier to add new models to the model library.* |
---|
[a6f3613] | 146 | |
---|
| 147 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 148 | |
---|
[f3377b8] | 149 | .. _Custom_Model_Editor: |
---|
| 150 | |
---|
[a6f3613] | 151 | Custom Model Editor |
---|
| 152 | ------------------- |
---|
| 153 | |
---|
[f3377b8] | 154 | From the *Fitting* option in the menu bar, select *Edit Custom Model*. |
---|
[a6f3613] | 155 | |
---|
| 156 | .. image:: edit_model_menu.bmp |
---|
| 157 | |
---|
[f3377b8] | 158 | and then one of the options |
---|
| 159 | |
---|
| 160 | * *New* - to create a new custom model template |
---|
| 161 | * *Sum|Multi(p1,p2)* - to create a new model by summing/multiplying existing models in the model library |
---|
| 162 | * *Advanced* - to edit a new custom model |
---|
| 163 | * *Delete* - to delete a custom model |
---|
[a6f3613] | 164 | |
---|
[f3377b8] | 165 | New |
---|
| 166 | ^^^^ |
---|
[a6f3613] | 167 | |
---|
| 168 | .. image:: new_model.bmp |
---|
| 169 | |
---|
[f3377b8] | 170 | A model template generated by this option can be viewed and further modified using |
---|
| 171 | the :ref:`Advanced` option. |
---|
| 172 | |
---|
[a6f3613] | 173 | Sum|Multi(p1,p2) |
---|
| 174 | ^^^^^^^^^^^^^^^^ |
---|
| 175 | |
---|
| 176 | .. image:: sum_model.bmp |
---|
[a0637de] | 177 | |
---|
[f3377b8] | 178 | This option creates a custom model of the form |
---|
| 179 | |
---|
[8570246] | 180 | Custom Model = scale_factor \* (model1 +/\* model2) |
---|
[f3377b8] | 181 | |
---|
| 182 | In the *Easy Sum/Multi Editor* give the new custom model a function name and brief |
---|
| 183 | description (to appear under the *Details* button on the *Fit Page*). Then select |
---|
| 184 | two existing models, as p1 and p2, and the required operator, '+' or '*' between |
---|
| 185 | them. Finally, click the *Apply* button to generate the model and then click *Close*. |
---|
| 186 | |
---|
| 187 | *NB: Any changes to a custom model generated in this way only become effective after* |
---|
| 188 | *it is re-selected from the model drop-down menu on the Fit Page.* |
---|
| 189 | |
---|
| 190 | .. _Advanced: |
---|
| 191 | |
---|
[a6f3613] | 192 | Advanced |
---|
| 193 | ^^^^^^^^ |
---|
[ec392464] | 194 | |
---|
[f3377b8] | 195 | Selecting this option shows all the custom models in the plugin model folder |
---|
| 196 | |
---|
[8570246] | 197 | *C:\\Users\\[username]\\.sasview\\plugin_models* - (on Windows) |
---|
[f3377b8] | 198 | |
---|
| 199 | You can edit, modify, and save the Python code in any of these models using the |
---|
| 200 | *Advanced Custom Model Editor*. |
---|
| 201 | |
---|
| 202 | *NB: Unless you are confident about what you are doing, it is recommended that you* |
---|
| 203 | *only modify lines denoted with the ## <----- comments!* |
---|
| 204 | |
---|
| 205 | When editing is complete, select *Run -> Compile* from the *Model Editor* menu bar. An |
---|
| 206 | *Info* box will appear with the results of the compilation and model unit tests. The |
---|
| 207 | model will only be usable if the tests 'pass'. |
---|
| 208 | |
---|
| 209 | To use the model, go to the relevant *Fit Page*, select the *Customized Models* |
---|
| 210 | category and then select the model from the drop-down menu. |
---|
| 211 | |
---|
| 212 | *NB: Any changes to a custom model generated in this way only become effective after* |
---|
| 213 | *it is re-selected from the model drop-down menu on the Fit Page.* |
---|
[a6f3613] | 214 | |
---|
| 215 | Delete |
---|
| 216 | ^^^^^^ |
---|
| 217 | |
---|
[f3377b8] | 218 | Simply highlight the custom model to be removed. This operation is final! |
---|
| 219 | |
---|
| 220 | *NB: Custom models shipped with SasView cannot be removed in this way.* |
---|
[ec392464] | 221 | |
---|
| 222 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 223 | |
---|
[f3377b8] | 224 | .. _Writing_a_Plugin: |
---|
| 225 | |
---|
| 226 | Writing a Plugin |
---|
[a6f3613] | 227 | ---------------- |
---|
| 228 | |
---|
[f3377b8] | 229 | Advanced users can write their own model in Python and save it to the the SasView |
---|
| 230 | *plugin_models* folder |
---|
[a6f3613] | 231 | |
---|
[8570246] | 232 | *C:\\Users\\[username]\\.sasview\\plugin_models* - (on Windows) |
---|
[a6f3613] | 233 | |
---|
[f3377b8] | 234 | in .py format. The next time SasView is started it will compile the plugin and add |
---|
| 235 | it to the list of *Customized Models*. |
---|
[a6f3613] | 236 | |
---|
[f3377b8] | 237 | It is recommended that existing plugin models be used as templates. |
---|
[a6f3613] | 238 | |
---|
[f3377b8] | 239 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
[ec392464] | 240 | |
---|
[4666660] | 241 | .. _Fitting_Options: |
---|
| 242 | |
---|
[f3377b8] | 243 | Fitting Options |
---|
| 244 | --------------- |
---|
[a6f3613] | 245 | |
---|
[f3377b8] | 246 | It is possible to specify which optimiser SasView should use to fit the data, and |
---|
| 247 | to modify some of the configurational parameters for each optimiser. |
---|
| 248 | |
---|
| 249 | From *Fitting* in the menu bar select *Fit Options*, then select one of the following |
---|
| 250 | optimisers: |
---|
[a6f3613] | 251 | |
---|
[f3377b8] | 252 | * DREAM |
---|
| 253 | * Levenberg-Marquardt |
---|
| 254 | * Quasi-Newton BFGS |
---|
| 255 | * Differential Evolution |
---|
| 256 | * Nelder-Mead Simplex |
---|
[a6f3613] | 257 | |
---|
[f3377b8] | 258 | These optimisers form the *Bumps* package written by P Kienzle. For more information |
---|
[4666660] | 259 | on each optimiser, see the :ref:`Fitting_Documentation`. |
---|
[a6f3613] | 260 | |
---|
[f3377b8] | 261 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
[a6f3613] | 262 | |
---|
[f3377b8] | 263 | Shortcuts |
---|
| 264 | --------- |
---|
[a6f3613] | 265 | |
---|
[f3377b8] | 266 | Copy/Paste Parameters |
---|
| 267 | ^^^^^^^^^^^^^^^^^^^^^ |
---|
[a6f3613] | 268 | |
---|
[f3377b8] | 269 | It is possible to copy the parameters from one *Fit Page* and to paste them into |
---|
| 270 | another *Fit Page* using the same model. |
---|
[a6f3613] | 271 | |
---|
[f3377b8] | 272 | To *copy* parameters, either: |
---|
[a6f3613] | 273 | |
---|
[f3377b8] | 274 | * Select *Edit -> Copy Params* from the menu bar, or |
---|
| 275 | * Use Ctrl(Cmd on Mac) + Left Mouse Click on the *Fit Page*. |
---|
[a6f3613] | 276 | |
---|
[f3377b8] | 277 | To *paste* parameters, either: |
---|
| 278 | |
---|
| 279 | * Select *Edit -> Paste Params* from the menu bar, or |
---|
| 280 | * Use Ctrl(Cmd on Mac) + Shift + Left-click on the *Fit Page*. |
---|
| 281 | |
---|
| 282 | If either operation is successful a message will appear in the info line at the |
---|
| 283 | bottom of the SasView window. |
---|
| 284 | |
---|
| 285 | Bookmark |
---|
| 286 | ^^^^^^^^ |
---|
[a6f3613] | 287 | |
---|
[1fda506] | 288 | To *Bookmark* a *Fit Page* either: |
---|
[a6f3613] | 289 | |
---|
[f3377b8] | 290 | * Select a *Fit Page* and then click on *Bookmark* in the tool bar, or |
---|
| 291 | * Right-click and select the *Bookmark* in the popup menu. |
---|
[a6f3613] | 292 | |
---|
| 293 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 294 | |
---|
[4666660] | 295 | .. _Status_bar: |
---|
| 296 | |
---|
[1fda506] | 297 | Status Bar & Console |
---|
| 298 | -------------------- |
---|
| 299 | |
---|
| 300 | The status bar is located at the bottom of the SasView window and displays |
---|
| 301 | messages, hints, warnings and errors. |
---|
| 302 | |
---|
| 303 | At the right-hand side of the status bar is a button marked *Console*. The *Console* |
---|
| 304 | displays available message history and some run-time traceback information. |
---|
| 305 | |
---|
| 306 | During a long task the *Console* can also be used to monitor the progress. |
---|
| 307 | |
---|
| 308 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 309 | |
---|
[a6f3613] | 310 | Single Fit Mode |
---|
| 311 | --------------- |
---|
[ec392464] | 312 | |
---|
[4666660] | 313 | *NB: Before proceeding, ensure that the Single Mode radio button at the bottom of* |
---|
| 314 | *the Data Explorer is checked (see the section* :ref:`Loading_data` *).* |
---|
| 315 | |
---|
[63d314b] | 316 | This mode fits one data set. |
---|
| 317 | |
---|
[4666660] | 318 | When data is sent to the fitting perspective it is plotted in a graph window as |
---|
| 319 | markers. |
---|
| 320 | |
---|
| 321 | If a graph does not appear, or a graph window appears but is empty, then the data |
---|
| 322 | has not loaded correctly. Check to see if there is a message in the :ref:`Status_Bar` |
---|
| 323 | or in the *Console* window. |
---|
| 324 | |
---|
| 325 | Assuming the data has loaded correctly, when a model is selected a green model |
---|
| 326 | calculation (or what SasView calls a 'Theory') line will appear in the earlier graph |
---|
| 327 | window, and a second graph window will appear displaying the residuals (the |
---|
| 328 | difference between the experimental data and the theory) at the same X-data values. |
---|
| 329 | |
---|
| 330 | The objective of model-fitting is to find a *physically-plausible* model, and set |
---|
| 331 | of model parameters, that generate a theory that reproduces the experimental data |
---|
| 332 | and gives residual values as close to zero as possible. |
---|
| 333 | |
---|
| 334 | Change the default values of the model parameters by hand until the theory line |
---|
| 335 | starts to represent the experimental data. Then uncheck the tick boxes alongside |
---|
| 336 | all parameters *except* the 'background' and the 'scale'. Click the *Fit* button. |
---|
| 337 | SasView will optimise the values of the 'background' and 'scale' and also display |
---|
| 338 | the corresponding uncertainties on the optimised values. |
---|
| 339 | |
---|
| 340 | *NB: If no uncertainty is shown it generally means that the model is not very* |
---|
| 341 | *dependent on the corresponding parameter (or that one or more parameters are* |
---|
| 342 | *'correlated').* |
---|
| 343 | |
---|
| 344 | In the bottom left corner of the *Fit Page* is a box displaying the normalised value |
---|
| 345 | of the statistical |chi|\ :sup:`2` parameter returned by the optimiser. |
---|
| 346 | |
---|
| 347 | Now check the box for another model parameter and click *Fit* again. Repeat this |
---|
| 348 | process until most or all parameters are checked and have been optimised. As the |
---|
| 349 | fit of the theory to the experimental data improves the value of 'chi2/Npts' will |
---|
| 350 | decrease. A good model fit should easily produce values of 'chi2/Npts' that are |
---|
| 351 | close to zero, and certainly <100. |
---|
| 352 | |
---|
| 353 | SasView has a number of different optimisers (see the section :ref:`Fitting_Options`). |
---|
| 354 | The DREAM optimiser is the most sophisticated, but may not necessarily be the best |
---|
| 355 | option for fitting simple models. If uncertain, try the Levenberg-Marquardt optimiser |
---|
| 356 | initially. |
---|
[ec392464] | 357 | |
---|
| 358 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 359 | |
---|
[a6f3613] | 360 | Simultaneous Fit Mode |
---|
| 361 | --------------------- |
---|
[ec392464] | 362 | |
---|
[63d314b] | 363 | *NB: Before proceeding, ensure that the Single Mode radio button at the bottom of* |
---|
| 364 | *the Data Explorer is checked (see the section* :ref:`Loading_data` *).* |
---|
[ec392464] | 365 | |
---|
[63d314b] | 366 | This mode is an extension of the :ref:`Single Fit Mode` that fits two or more data |
---|
| 367 | sets *to the same model* simultaneously. If necessary it is possible to constrain |
---|
| 368 | fit parameters between data sets (eg, to fix a background level, or radius, etc). |
---|
| 369 | |
---|
| 370 | If the data to be fit are in multiple files, load each file, select it in the |
---|
| 371 | *Data Explorer*, and *Send To Fitting*. |
---|
| 372 | |
---|
| 373 | If multiple data sets are in one file, load that file, *Unselect All Data*, then |
---|
| 374 | select each dataset one at a time and Send To Fitting. |
---|
| 375 | |
---|
| 376 | The result should be that for |
---|
| 377 | n |
---|
| 378 | datsets you have 2 |
---|
| 379 | n |
---|
| 380 | graphs ( |
---|
| 381 | n |
---|
| 382 | of the data & model fit and |
---|
| 383 | n |
---|
| 384 | residuals plots). |
---|
| 385 | |
---|
| 386 | IMPORTANT! |
---|
| 387 | If you need to create a n |
---|
| 388 | ew model with the new model wizard, or use a |
---|
| 389 | model which is the sum of two existing models, go Fitting |
---|
| 390 | |
---|
| 391 | Edit Custom Model |
---|
| 392 | before |
---|
| 393 | sending the data to the fitting engine. |
---|
| 394 | The model will be available under |
---|
| 395 | |
---|
| 396 | Customised |
---|
| 397 | Models |
---|
| 398 | |
---|
| 399 | on |
---|
| 400 | the FitPage. NB: the name will likely be abbreviated; eg, |
---|
| 401 | |
---|
| 402 | Peak |
---|
| 403 | Gauss |
---|
| 404 | Model + Absolute Power Law Model |
---|
| 405 | |
---|
| 406 | will appear as |
---|
| 407 | |
---|
| 408 | PGM + APL |
---|
| 409 | |
---|
| 410 | . |
---|
| 411 | 3. |
---|
| 412 | Go to each Fit |
---|
| 413 | Page in turn |
---|
| 414 | and: |
---|
| 415 | |
---|
| 416 | Select the required model. |
---|
| 417 | |
---|
| 418 | Unselect all the model par |
---|
| 419 | ameters. |
---|
| 420 | |
---|
| 421 | Enter some starting guesses for the parameters (it may be helpful to remove the |
---|
| 422 | residuals plots for clarity; go Graph |
---|
| 423 | |
---|
| 424 | Show and untick graph windows as required). |
---|
| 425 | |
---|
| 426 | Enter any parameter limits (recommended). |
---|
| 427 | |
---|
| 428 | Select which parameters will refine (sele |
---|
| 429 | cting all is probably a bad idea...). |
---|
| 430 | 4. |
---|
| 431 | Select Fitting |
---|
| 432 | |
---|
| 433 | Simultaneous Fit (this also selects the Complex Fit Engine). |
---|
| 434 | 5. |
---|
| 435 | Go to the Simultaneous Fit page |
---|
| 436 | and: |
---|
| 437 | |
---|
| 438 | Select which datasets are to be fitted (which will probably be all of them or you wouldnt |
---|
| 439 | have |
---|
| 440 | loaded them in!). |
---|
| 441 | |
---|
| 442 | It is possible to tie parameters between datasets with constraints; eg, make the |
---|
| 443 | Background in FitPage1 the same as the Background in FitPage2, and so on. To do this, |
---|
| 444 | answer yes to Add Constraints in the Fit Constraints box. |
---|
| 445 | |
---|
| 446 | But note th |
---|
| 447 | at SANSView only lets you constrain parameters that are refining. |
---|
| 448 | 6. |
---|
| 449 | Click Fit |
---|
| 450 | |
---|
| 451 | |
---|
| 452 | |
---|
| 453 | Simultaneous Fits without Constraints |
---|
| 454 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
---|
[ec392464] | 455 | |
---|
| 456 | Assuming some FitPages are already set up, check the checkboxes of the |
---|
| 457 | model_data rows to fit. And click the 'Fit' button. The results will return to |
---|
| 458 | each FitPages. |
---|
| 459 | |
---|
| 460 | Note that the chi2/Npts returned is the sum of the chi2/Npts of each fits. If |
---|
| 461 | one needs the chi2 value only for a page, click the 'Compute' button in the |
---|
| 462 | FitPage to recalculate. |
---|
| 463 | |
---|
[63d314b] | 464 | Simultaneous Fits with Constraints |
---|
| 465 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
---|
[ec392464] | 466 | |
---|
| 467 | Enter constraint in the text control next to *constraint fit* button. |
---|
| 468 | Constraint should be of type model1 parameter name = f(model2 parameter name) |
---|
| 469 | for example, M0.radius=2*M1.radius. Many constraints can be entered for a |
---|
| 470 | single fit. Each of them should be separated by a newline charater or ";" |
---|
| 471 | The easy setup can generate many constraint inputs easily when the selected |
---|
| 472 | two models are the same type. |
---|
| 473 | |
---|
| 474 | Note that the chi2/Npts returned is the sum of the chi2/Npts of each fits. |
---|
| 475 | If one needs the chi2 value only for one fit, click the 'Compute' button in |
---|
| 476 | the FitPage to recalculate. |
---|
| 477 | |
---|
| 478 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 479 | |
---|
[a6f3613] | 480 | Batch Fit Mode |
---|
| 481 | -------------- |
---|
[ec392464] | 482 | |
---|
[63d314b] | 483 | *NB: Before proceeding, ensure that the Batch Mode radio button at the bottom of* |
---|
| 484 | *the Data Explorer is checked (see the section* :ref:`Loading_data` *).* |
---|
| 485 | |
---|
[ec392464] | 486 | Batch Fit |
---|
[a6f3613] | 487 | ^^^^^^^^^ |
---|
[ec392464] | 488 | |
---|
| 489 | Create a *Batch Page* by selecting the *Batch* radio button on the DataExplorer |
---|
| 490 | (see figure below) and for a new control page select 'New FitPage' in the |
---|
| 491 | Fitting menubar. |
---|
| 492 | |
---|
| 493 | .. image:: batch_button_area.bmp |
---|
| 494 | |
---|
| 495 | Figure 1: MenuBar: |
---|
| 496 | |
---|
| 497 | Load Data to the DataExplorer if not already loaded. |
---|
| 498 | |
---|
| 499 | Select one or more data sets by checking the check boxes, and then make sure |
---|
| 500 | that "Fitting" is selected in the dropdown menu next to the "Send To" button. |
---|
| 501 | Once ready, click the 'Send To' button to set data to a BatchPage. If already |
---|
| 502 | an empty batch page exists, it will be set there. Otherwise it will create a |
---|
| 503 | new Batch Page. Set up the model and the parameter values as same as a single |
---|
[f3377b8] | 504 | fitting (see Single Fit help). Then use 'Fit' button to |
---|
[ec392464] | 505 | perform the fitting. |
---|
| 506 | |
---|
| 507 | Unlike a single fit, the results of the fittings will not return to the |
---|
| 508 | BatchPage'. Instead, a Grid window will be provided once the fitting is |
---|
| 509 | completed. The Grid window is also accessible from the 'View' menu |
---|
| 510 | (see Figure 2). |
---|
| 511 | |
---|
| 512 | Note that only one model is used for all the data. The initial parameter |
---|
| 513 | values given in the control page will be used all the data fittings. If one |
---|
| 514 | wants the FitEngine to use the initial values from the results of the |
---|
| 515 | previous data fitting (if any), choose the 'Chain Fitting' option in the |
---|
| 516 | Fitting menubar, which will speed up the fitting especially when you have |
---|
| 517 | lots of, and similar, data sets. |
---|
| 518 | |
---|
| 519 | Batch Window |
---|
[a6f3613] | 520 | ^^^^^^^^^^^^ |
---|
[ec392464] | 521 | Batch Window provides an easy way to view the fit results, i.e., plot data, |
---|
| 522 | fits, and residuals. Batch window will be automatically shown after a batch |
---|
| 523 | fit is finished. |
---|
| 524 | |
---|
| 525 | Once closed, it can be opened anytime from the "View" menubar item (see |
---|
| 526 | Figure 2). |
---|
| 527 | |
---|
| 528 | .. image:: restore_batch_window.bmp |
---|
| 529 | |
---|
| 530 | Figure 2: Edit Menu: |
---|
| 531 | |
---|
| 532 | Edit Grid |
---|
[a6f3613] | 533 | ^^^^^^^^^ |
---|
[ec392464] | 534 | |
---|
| 535 | Once a batch fit is completed, all fitted and fixed model parameters are |
---|
| 536 | displayed to the current sheet of the batch window except the errors of the |
---|
| 537 | parameters. To view the errors, click on a given column then under *Edit* |
---|
| 538 | menubar item, and insert the desired parameter by selecting a menu item with |
---|
| 539 | the appropriated label. Empty column can be inserted in the same way. A |
---|
| 540 | column value can be customized by editing an existing empty column. |
---|
| 541 | |
---|
| 542 | To Remove column from the grid, select it, choose edit menu, and click the |
---|
| 543 | *'remove'* menu item. Any removed column should reinserted whenever needed. |
---|
| 544 | |
---|
| 545 | All above options are also available when right clicking on a given column |
---|
| 546 | label(see Figure 3). |
---|
| 547 | |
---|
| 548 | *Note:* A column always needs to be selected in order to remove or insert a |
---|
| 549 | column in the grid. |
---|
| 550 | |
---|
| 551 | .. image:: edit_menu.bmp |
---|
| 552 | |
---|
| 553 | Figure 3: Edit Menu: |
---|
| 554 | |
---|
| 555 | Save Grid |
---|
[a6f3613] | 556 | ^^^^^^^^^ |
---|
[ec392464] | 557 | To save the current page on the batch window, select the *'File'* menubar |
---|
| 558 | item(see Figure 4), then choose the *'Save as'* menu item to save it as a |
---|
| 559 | .csv file. |
---|
| 560 | |
---|
| 561 | *Note:* The grid doesn't save the data array, fits, and the array residuals. |
---|
| 562 | As a result, the 'View (fit) Results' functionality will be lost when |
---|
| 563 | reloading the saved file. |
---|
| 564 | |
---|
| 565 | Warning! To ensure accuracy of saved fit results, it is recommended to save |
---|
| 566 | the current grid before modifying it . |
---|
| 567 | |
---|
[a6f3613] | 568 | Open Batch Results |
---|
| 569 | ^^^^^^^^^^^^^^^^^^ |
---|
[ec392464] | 570 | |
---|
| 571 | Any *csv* file can be opened in the grid by selecting the *'Open'* under |
---|
| 572 | the *'File'* menu in the Grid Window(see Figure 4). All columns in the file |
---|
| 573 | will be displayed but insertion will not available. Insertion will be |
---|
| 574 | available only when at least one column will be removed from the grid. |
---|
| 575 | |
---|
| 576 | .. image:: file_menu.bmp |
---|
| 577 | |
---|
| 578 | Figure 4: MenuBar: |
---|
| 579 | |
---|
| 580 | Plot |
---|
[a6f3613] | 581 | ^^^^ |
---|
[ec392464] | 582 | |
---|
| 583 | To *plot* a column versus another, select one column at the time, click the |
---|
| 584 | *'Add'* button next to the text control of X/Y -axis *Selection Range* to |
---|
| 585 | plot the value of this column on the X/Y axis. Alternatively, all available |
---|
| 586 | range can be selected by clicking the column letter (eg. B). Repeat the same |
---|
| 587 | procedure the next axis. Finally, click the *'Plot'* button. When clicking |
---|
| 588 | on *Add* button, the grid will automatically fill the axis label, but |
---|
| 589 | different labels and units can be entered in the correct controls before |
---|
| 590 | clicking on the plot button. |
---|
| 591 | |
---|
| 592 | *X/Y -Axis Selection Range* can be edited manually. These text controls |
---|
| 593 | allow the following types of expression (operation can be + - * /, or pow) |
---|
| 594 | |
---|
| 595 | 1) if the current axis label range is a function of 1 or more columns, write |
---|
| 596 | this type of expression |
---|
| 597 | |
---|
| 598 | constant1 * column_name1 [minimum row index : maximum row index] operator |
---|
| 599 | constant2 * column_name2 [minimum row index : maximum row index] |
---|
| 600 | |
---|
| 601 | Example: radius [2 : 5] -3 * scale [2 : 5] |
---|
| 602 | |
---|
| 603 | 2) if only some values of a given column are need but the range between the |
---|
| 604 | first row and the last row used is not continuous, write the following |
---|
| 605 | expression in the text control |
---|
| 606 | |
---|
| 607 | column_name1 [minimum row index1 : maximum row index1] , column_name1 |
---|
| 608 | [minimum row index2 : maximum row index2] |
---|
| 609 | |
---|
| 610 | Example : radius [2 : 5] , radius [10 : 25] |
---|
| 611 | |
---|
| 612 | Note: Both text controls ( X and Y-axis Selection Ranges) need to be filled |
---|
| 613 | with valid entries for plotting to work. The dY-bar is optional (see Figure 5). |
---|
| 614 | |
---|
| 615 | .. image:: plot_button.bmp |
---|
| 616 | |
---|
| 617 | Figure 5: Plotting |
---|
| 618 | |
---|
| 619 | View Column/Cell(s) |
---|
[a6f3613] | 620 | ^^^^^^^^^^^^^^^^^^^ |
---|
[ec392464] | 621 | |
---|
| 622 | Select 1 or more cells from the same column, click the 'View Fits' button to |
---|
| 623 | display available curves. |
---|
| 624 | |
---|
| 625 | For example, select the cells of the 'Chi2' column, then click the 'View Fits' |
---|
| 626 | button. The plots generates will represent the residuals plots. |
---|
| 627 | |
---|
| 628 | If you select any cells of the 'Data' column and click the 'View Fits' button. |
---|
| 629 | It generates both data and fits in the graph (see Figure 6). |
---|
| 630 | |
---|
| 631 | Alternatively, just click the column letter (eg. B) to choose all the |
---|
| 632 | available data sets, then simply click the 'View Fits' button to plot the |
---|
| 633 | data and fits. |
---|
| 634 | |
---|
| 635 | .. image:: view_button.bmp |
---|
| 636 | |
---|
| 637 | Figure 6: View Fits |
---|
| 638 | |
---|
| 639 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|