[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 | |
---|
[b5846a10] | 134 | .. _Adding_your_own_models: |
---|
| 135 | |
---|
[f3377b8] | 136 | Adding your own models |
---|
| 137 | ---------------------- |
---|
[a6f3613] | 138 | |
---|
[f3377b8] | 139 | There are currently two ways to add your own models to SasView: |
---|
| 140 | |
---|
[8570246] | 141 | * Using the :ref:`Custom_Model_Editor` |
---|
| 142 | * By :ref:`Writing_a_Plugin` |
---|
[f3377b8] | 143 | |
---|
| 144 | *NB: Because of the way these options are implemented, it is not possible for them* |
---|
| 145 | *to use the polydispersity algorithms in SasView. Only models in the model library* |
---|
| 146 | *can do this. At the time of writing (Release 3.1.0) work is in hand to make it* |
---|
| 147 | *easier to add new models to the model library.* |
---|
[a6f3613] | 148 | |
---|
| 149 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 150 | |
---|
[f3377b8] | 151 | .. _Custom_Model_Editor: |
---|
| 152 | |
---|
[a6f3613] | 153 | Custom Model Editor |
---|
| 154 | ------------------- |
---|
| 155 | |
---|
[f3377b8] | 156 | From the *Fitting* option in the menu bar, select *Edit Custom Model*. |
---|
[a6f3613] | 157 | |
---|
| 158 | .. image:: edit_model_menu.bmp |
---|
| 159 | |
---|
[f3377b8] | 160 | and then one of the options |
---|
| 161 | |
---|
| 162 | * *New* - to create a new custom model template |
---|
| 163 | * *Sum|Multi(p1,p2)* - to create a new model by summing/multiplying existing models in the model library |
---|
| 164 | * *Advanced* - to edit a new custom model |
---|
| 165 | * *Delete* - to delete a custom model |
---|
[a6f3613] | 166 | |
---|
[f3377b8] | 167 | New |
---|
| 168 | ^^^^ |
---|
[a6f3613] | 169 | |
---|
| 170 | .. image:: new_model.bmp |
---|
| 171 | |
---|
[f3377b8] | 172 | A model template generated by this option can be viewed and further modified using |
---|
| 173 | the :ref:`Advanced` option. |
---|
| 174 | |
---|
[a6f3613] | 175 | Sum|Multi(p1,p2) |
---|
| 176 | ^^^^^^^^^^^^^^^^ |
---|
| 177 | |
---|
| 178 | .. image:: sum_model.bmp |
---|
[a0637de] | 179 | |
---|
[f3377b8] | 180 | This option creates a custom model of the form |
---|
| 181 | |
---|
[8570246] | 182 | Custom Model = scale_factor \* (model1 +/\* model2) |
---|
[f3377b8] | 183 | |
---|
| 184 | In the *Easy Sum/Multi Editor* give the new custom model a function name and brief |
---|
| 185 | description (to appear under the *Details* button on the *Fit Page*). Then select |
---|
| 186 | two existing models, as p1 and p2, and the required operator, '+' or '*' between |
---|
| 187 | them. Finally, click the *Apply* button to generate the model and then click *Close*. |
---|
| 188 | |
---|
| 189 | *NB: Any changes to a custom model generated in this way only become effective after* |
---|
| 190 | *it is re-selected from the model drop-down menu on the Fit Page.* |
---|
| 191 | |
---|
| 192 | .. _Advanced: |
---|
| 193 | |
---|
[a6f3613] | 194 | Advanced |
---|
| 195 | ^^^^^^^^ |
---|
[ec392464] | 196 | |
---|
[f3377b8] | 197 | Selecting this option shows all the custom models in the plugin model folder |
---|
| 198 | |
---|
[8570246] | 199 | *C:\\Users\\[username]\\.sasview\\plugin_models* - (on Windows) |
---|
[f3377b8] | 200 | |
---|
| 201 | You can edit, modify, and save the Python code in any of these models using the |
---|
| 202 | *Advanced Custom Model Editor*. |
---|
| 203 | |
---|
| 204 | *NB: Unless you are confident about what you are doing, it is recommended that you* |
---|
| 205 | *only modify lines denoted with the ## <----- comments!* |
---|
| 206 | |
---|
| 207 | When editing is complete, select *Run -> Compile* from the *Model Editor* menu bar. An |
---|
| 208 | *Info* box will appear with the results of the compilation and model unit tests. The |
---|
| 209 | model will only be usable if the tests 'pass'. |
---|
| 210 | |
---|
| 211 | To use the model, go to the relevant *Fit Page*, select the *Customized Models* |
---|
| 212 | category and then select the model from the drop-down menu. |
---|
| 213 | |
---|
| 214 | *NB: Any changes to a custom model generated in this way only become effective after* |
---|
| 215 | *it is re-selected from the model drop-down menu on the Fit Page.* |
---|
[a6f3613] | 216 | |
---|
| 217 | Delete |
---|
| 218 | ^^^^^^ |
---|
| 219 | |
---|
[f3377b8] | 220 | Simply highlight the custom model to be removed. This operation is final! |
---|
| 221 | |
---|
| 222 | *NB: Custom models shipped with SasView cannot be removed in this way.* |
---|
[ec392464] | 223 | |
---|
| 224 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 225 | |
---|
[f3377b8] | 226 | .. _Writing_a_Plugin: |
---|
| 227 | |
---|
| 228 | Writing a Plugin |
---|
[a6f3613] | 229 | ---------------- |
---|
| 230 | |
---|
[f3377b8] | 231 | Advanced users can write their own model in Python and save it to the the SasView |
---|
| 232 | *plugin_models* folder |
---|
[a6f3613] | 233 | |
---|
[8570246] | 234 | *C:\\Users\\[username]\\.sasview\\plugin_models* - (on Windows) |
---|
[a6f3613] | 235 | |
---|
[f3377b8] | 236 | in .py format. The next time SasView is started it will compile the plugin and add |
---|
| 237 | it to the list of *Customized Models*. |
---|
[a6f3613] | 238 | |
---|
[f3377b8] | 239 | It is recommended that existing plugin models be used as templates. |
---|
[a6f3613] | 240 | |
---|
[f3377b8] | 241 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
[ec392464] | 242 | |
---|
[4666660] | 243 | .. _Fitting_Options: |
---|
| 244 | |
---|
[f3377b8] | 245 | Fitting Options |
---|
| 246 | --------------- |
---|
[a6f3613] | 247 | |
---|
[f3377b8] | 248 | It is possible to specify which optimiser SasView should use to fit the data, and |
---|
| 249 | to modify some of the configurational parameters for each optimiser. |
---|
| 250 | |
---|
| 251 | From *Fitting* in the menu bar select *Fit Options*, then select one of the following |
---|
| 252 | optimisers: |
---|
[a6f3613] | 253 | |
---|
[f3377b8] | 254 | * DREAM |
---|
| 255 | * Levenberg-Marquardt |
---|
| 256 | * Quasi-Newton BFGS |
---|
| 257 | * Differential Evolution |
---|
| 258 | * Nelder-Mead Simplex |
---|
[a6f3613] | 259 | |
---|
[6af2785] | 260 | The DREAM optimiser is the most sophisticated, but may not necessarily be the best |
---|
| 261 | option for fitting simple models. If uncertain, try the Levenberg-Marquardt optimiser |
---|
| 262 | initially. |
---|
| 263 | |
---|
[f3377b8] | 264 | These optimisers form the *Bumps* package written by P Kienzle. For more information |
---|
[4666660] | 265 | on each optimiser, see the :ref:`Fitting_Documentation`. |
---|
[a6f3613] | 266 | |
---|
[f3377b8] | 267 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
[a6f3613] | 268 | |
---|
[5ac0a7a] | 269 | Fitting Limits |
---|
| 270 | -------------- |
---|
| 271 | |
---|
| 272 | By default, *SasView* will attempt to model fit the full range of the data; ie, |
---|
| 273 | across all *Q* values. If necessary, however, it is possible to specify only a |
---|
| 274 | sub-region of the data for fitting. |
---|
| 275 | |
---|
| 276 | In a *FitPage* or *BatchPage* change the *Q* values in the *Min* and/or *Max* |
---|
| 277 | text boxes. Vertical coloured bars will appear on the graph with the data and |
---|
| 278 | 'theory' indicating the current *Q* limits (red = *Qmin*, purple = *Qmax*). |
---|
| 279 | |
---|
| 280 | To return to including all data in the fit, click the *Reset* button. |
---|
| 281 | |
---|
| 282 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 283 | |
---|
| 284 | |
---|
[f3377b8] | 285 | Shortcuts |
---|
| 286 | --------- |
---|
[a6f3613] | 287 | |
---|
[f3377b8] | 288 | Copy/Paste Parameters |
---|
| 289 | ^^^^^^^^^^^^^^^^^^^^^ |
---|
[a6f3613] | 290 | |
---|
[f3377b8] | 291 | It is possible to copy the parameters from one *Fit Page* and to paste them into |
---|
| 292 | another *Fit Page* using the same model. |
---|
[a6f3613] | 293 | |
---|
[f3377b8] | 294 | To *copy* parameters, either: |
---|
[a6f3613] | 295 | |
---|
[f3377b8] | 296 | * Select *Edit -> Copy Params* from the menu bar, or |
---|
| 297 | * Use Ctrl(Cmd on Mac) + Left Mouse Click on the *Fit Page*. |
---|
[a6f3613] | 298 | |
---|
[f3377b8] | 299 | To *paste* parameters, either: |
---|
| 300 | |
---|
| 301 | * Select *Edit -> Paste Params* from the menu bar, or |
---|
| 302 | * Use Ctrl(Cmd on Mac) + Shift + Left-click on the *Fit Page*. |
---|
| 303 | |
---|
| 304 | If either operation is successful a message will appear in the info line at the |
---|
| 305 | bottom of the SasView window. |
---|
| 306 | |
---|
| 307 | Bookmark |
---|
| 308 | ^^^^^^^^ |
---|
[a6f3613] | 309 | |
---|
[1fda506] | 310 | To *Bookmark* a *Fit Page* either: |
---|
[a6f3613] | 311 | |
---|
[f3377b8] | 312 | * Select a *Fit Page* and then click on *Bookmark* in the tool bar, or |
---|
| 313 | * Right-click and select the *Bookmark* in the popup menu. |
---|
[a6f3613] | 314 | |
---|
| 315 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 316 | |
---|
[4666660] | 317 | .. _Status_bar: |
---|
| 318 | |
---|
[1fda506] | 319 | Status Bar & Console |
---|
| 320 | -------------------- |
---|
| 321 | |
---|
| 322 | The status bar is located at the bottom of the SasView window and displays |
---|
| 323 | messages, hints, warnings and errors. |
---|
| 324 | |
---|
| 325 | At the right-hand side of the status bar is a button marked *Console*. The *Console* |
---|
| 326 | displays available message history and some run-time traceback information. |
---|
| 327 | |
---|
| 328 | During a long task the *Console* can also be used to monitor the progress. |
---|
| 329 | |
---|
| 330 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 331 | |
---|
[6af2785] | 332 | .. _Single_Fit_Mode: |
---|
| 333 | |
---|
[a6f3613] | 334 | Single Fit Mode |
---|
| 335 | --------------- |
---|
[ec392464] | 336 | |
---|
[4666660] | 337 | *NB: Before proceeding, ensure that the Single Mode radio button at the bottom of* |
---|
| 338 | *the Data Explorer is checked (see the section* :ref:`Loading_data` *).* |
---|
| 339 | |
---|
[63d314b] | 340 | This mode fits one data set. |
---|
| 341 | |
---|
[4666660] | 342 | When data is sent to the fitting perspective it is plotted in a graph window as |
---|
| 343 | markers. |
---|
| 344 | |
---|
| 345 | If a graph does not appear, or a graph window appears but is empty, then the data |
---|
| 346 | has not loaded correctly. Check to see if there is a message in the :ref:`Status_Bar` |
---|
| 347 | or in the *Console* window. |
---|
| 348 | |
---|
| 349 | Assuming the data has loaded correctly, when a model is selected a green model |
---|
| 350 | calculation (or what SasView calls a 'Theory') line will appear in the earlier graph |
---|
| 351 | window, and a second graph window will appear displaying the residuals (the |
---|
| 352 | difference between the experimental data and the theory) at the same X-data values. |
---|
[f9250dc] | 353 | See :ref:`Assessing_Fit_Quality`. |
---|
[4666660] | 354 | |
---|
| 355 | The objective of model-fitting is to find a *physically-plausible* model, and set |
---|
| 356 | of model parameters, that generate a theory that reproduces the experimental data |
---|
| 357 | and gives residual values as close to zero as possible. |
---|
| 358 | |
---|
| 359 | Change the default values of the model parameters by hand until the theory line |
---|
| 360 | starts to represent the experimental data. Then uncheck the tick boxes alongside |
---|
| 361 | all parameters *except* the 'background' and the 'scale'. Click the *Fit* button. |
---|
| 362 | SasView will optimise the values of the 'background' and 'scale' and also display |
---|
| 363 | the corresponding uncertainties on the optimised values. |
---|
| 364 | |
---|
| 365 | *NB: If no uncertainty is shown it generally means that the model is not very* |
---|
| 366 | *dependent on the corresponding parameter (or that one or more parameters are* |
---|
| 367 | *'correlated').* |
---|
| 368 | |
---|
| 369 | In the bottom left corner of the *Fit Page* is a box displaying the normalised value |
---|
| 370 | of the statistical |chi|\ :sup:`2` parameter returned by the optimiser. |
---|
| 371 | |
---|
| 372 | Now check the box for another model parameter and click *Fit* again. Repeat this |
---|
| 373 | process until most or all parameters are checked and have been optimised. As the |
---|
| 374 | fit of the theory to the experimental data improves the value of 'chi2/Npts' will |
---|
| 375 | decrease. A good model fit should easily produce values of 'chi2/Npts' that are |
---|
[ff42a26] | 376 | close to zero, and certainly <100. See :ref:`Assessing_Fit_Quality`. |
---|
[4666660] | 377 | |
---|
| 378 | SasView has a number of different optimisers (see the section :ref:`Fitting_Options`). |
---|
| 379 | The DREAM optimiser is the most sophisticated, but may not necessarily be the best |
---|
| 380 | option for fitting simple models. If uncertain, try the Levenberg-Marquardt optimiser |
---|
| 381 | initially. |
---|
[ec392464] | 382 | |
---|
| 383 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 384 | |
---|
[a6f3613] | 385 | Simultaneous Fit Mode |
---|
| 386 | --------------------- |
---|
[ec392464] | 387 | |
---|
[63d314b] | 388 | *NB: Before proceeding, ensure that the Single Mode radio button at the bottom of* |
---|
| 389 | *the Data Explorer is checked (see the section* :ref:`Loading_data` *).* |
---|
[ec392464] | 390 | |
---|
[6af2785] | 391 | This mode is an extension of the :ref:`Single_Fit_Mode` that fits two or more data |
---|
[63d314b] | 392 | sets *to the same model* simultaneously. If necessary it is possible to constrain |
---|
| 393 | fit parameters between data sets (eg, to fix a background level, or radius, etc). |
---|
| 394 | |
---|
[b5846a10] | 395 | If the data to be fit are in multiple files, load each file, then select each file |
---|
| 396 | in the *Data Explorer*, and *Send To Fitting*. If multiple data sets are in one file, |
---|
| 397 | load that file, *Unselect All Data*, select just those data sets to be fitted, and |
---|
| 398 | *Send To Fitting*. Either way, the result should be that for *n* data sets you have |
---|
[6af2785] | 399 | 2\ *n* graphs (*n* of the data and model fit, and *n* of the resulting residuals). But |
---|
[f9250dc] | 400 | it may be helpful to minimise the residuals plots for clarity. Also see |
---|
| 401 | :ref:`Assessing_Fit_Quality`. |
---|
[b5846a10] | 402 | |
---|
| 403 | *NB: If you need to use a customized model, you must ensure that model is available* |
---|
| 404 | *first (see* :ref:`Adding_your_own_models` *).* |
---|
| 405 | |
---|
[6af2785] | 406 | Method |
---|
| 407 | ^^^^^^ |
---|
| 408 | |
---|
[b5846a10] | 409 | Now go to each *FitPage* in turn and: |
---|
| 410 | |
---|
| 411 | Select the required category and model; |
---|
| 412 | |
---|
| 413 | Unselect all the model parameters; |
---|
| 414 | |
---|
| 415 | Enter some starting guesses for the parameters; |
---|
| 416 | |
---|
| 417 | Enter any parameter limits (recommended); |
---|
[63d314b] | 418 | |
---|
[b5846a10] | 419 | Select which parameters will refine (selecting all is generally a bad idea...); |
---|
[63d314b] | 420 | |
---|
[b5846a10] | 421 | When done, select *Constrained or Simultaneous Fit* under *Fitting* in the menu bar. |
---|
| 422 | |
---|
| 423 | In the *Const & Simul Fit* page that appears, select which data sets are to be |
---|
| 424 | simultaneously fitted (this will probably be all of them or you would not have loaded |
---|
| 425 | them in the first place!). |
---|
| 426 | |
---|
| 427 | To tie parameters between the data sets with constraints, check the 'yes' radio button |
---|
| 428 | next to *Add Constraint?* in the *Fit Constraints* box. |
---|
| 429 | |
---|
| 430 | *NB: You can only constrain parameters that are set to refine.* |
---|
| 431 | |
---|
| 432 | When ready, click the *Fit* button on the *Const & Simul Fit* page, NOT the *Fit* |
---|
| 433 | button on the individual *FitPage*'s. |
---|
[63d314b] | 434 | |
---|
| 435 | Simultaneous Fits without Constraints |
---|
| 436 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
---|
[ec392464] | 437 | |
---|
[b5846a10] | 438 | The results of the model-fitting will be returned to each of the individual |
---|
| 439 | *FitPage*'s. |
---|
[ec392464] | 440 | |
---|
[b5846a10] | 441 | Note that the chi2/Npts value returned is the SUM of the chi2/Npts of each fit. To |
---|
[6af2785] | 442 | see the chi2/Npts value for a specific *FitPage*, click the *Compute* button at the |
---|
[f9250dc] | 443 | bottom of that *FitPage* to recalculate. Also see :ref:`Assessing_Fit_Quality`. |
---|
[ec392464] | 444 | |
---|
[63d314b] | 445 | Simultaneous Fits with Constraints |
---|
| 446 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
---|
[ec392464] | 447 | |
---|
[b5846a10] | 448 | Use the *Easy Setup* drop-down buttons in the *Const & Simul Fit* page to set |
---|
| 449 | up constraints between *FitPage*'s. |
---|
| 450 | |
---|
[6af2785] | 451 | Constraints will generally be of the form |
---|
| 452 | |
---|
| 453 | Mi Parameter1 = Mj.Parameter1 |
---|
| 454 | |
---|
| 455 | however the text box after the '=' sign can be used to adjust this |
---|
| 456 | relationship; for example |
---|
| 457 | |
---|
| 458 | Mi Parameter1 = scalar \* Mj.Parameter1 |
---|
| 459 | |
---|
| 460 | A 'free-form' constraint box is also provided. |
---|
[b5846a10] | 461 | |
---|
| 462 | Many constraints can be entered for a single fit. |
---|
| 463 | |
---|
| 464 | The results of the model-fitting will be returned to each of the individual |
---|
| 465 | *FitPage*'s. |
---|
[ec392464] | 466 | |
---|
[b5846a10] | 467 | Note that the chi2/Npts value returned is the SUM of the chi2/Npts of each fit. To |
---|
[6af2785] | 468 | see the chi2/Npts value for a specific *FitPage*, click the *Compute* button at the |
---|
[f9250dc] | 469 | bottom of that *FitPage* to recalculate. Also see :ref:`Assessing_Fit_Quality`. |
---|
[ec392464] | 470 | |
---|
| 471 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 472 | |
---|
[a6f3613] | 473 | Batch Fit Mode |
---|
| 474 | -------------- |
---|
[ec392464] | 475 | |
---|
[6af2785] | 476 | *NB: Before proceeding, ensure that the Single Mode radio button at the bottom of* |
---|
| 477 | *the Data Explorer is checked (see the section* :ref:`Loading_data` *). The Batch* |
---|
| 478 | *Mode button will be used later on!* |
---|
[63d314b] | 479 | |
---|
[6af2785] | 480 | This mode *sequentially* fits two or more data sets *to the same model*. Unlike in |
---|
| 481 | simultaneous fitting, in batch fitting it is not possible to constrain fit parameters |
---|
| 482 | between data sets. |
---|
[ec392464] | 483 | |
---|
[6af2785] | 484 | If the data to be fit are in multiple files, load each file in the *Data Explorer*. |
---|
| 485 | If multiple data sets are in one file, load just that file. *Unselect All Data*, then |
---|
| 486 | select a single initial data set to be fitted. Fit that selected data set as described |
---|
| 487 | above under :ref:`Single_Fit_Mode` . |
---|
[ec392464] | 488 | |
---|
[6af2785] | 489 | *NB: If you need to use a customized model, you must ensure that model is available* |
---|
| 490 | *first (see* :ref:`Adding_your_own_models` *).* |
---|
[ec392464] | 491 | |
---|
[6af2785] | 492 | Method |
---|
| 493 | ^^^^^^ |
---|
[ec392464] | 494 | |
---|
[6af2785] | 495 | Now *Select All Data* in the *Data Explorer*, check the *Batch Mode* radio button |
---|
| 496 | at the bottom of that panel and *Send To Fitting*. A *BatchPage* will be created. |
---|
[ec392464] | 497 | |
---|
[6af2785] | 498 | .. image:: batch_button_area.bmp |
---|
[ec392464] | 499 | |
---|
[6af2785] | 500 | *NB: The Batch Page can also be created by checking the Batch Mode radio button* |
---|
| 501 | *and selecting New Fit Page under Fitting in the menu bar.* |
---|
[ec392464] | 502 | |
---|
[6af2785] | 503 | Using the drop-down menus in the *BatchPage*, now set up the *same* data set |
---|
| 504 | with the *same* model that you just fitted in single fit mode. A quick way to |
---|
| 505 | set the model parameter values is to just copy them from the earlier Single |
---|
| 506 | Fit. To do this, go back to the Single Fit *FitPage*, select *Copy Params* |
---|
| 507 | under *Edit* in the menu bar, then go back to the *BatchPage* and *Paste Params*. |
---|
[ec392464] | 508 | |
---|
[6af2785] | 509 | When ready, use the *Fit* button on the *BatchPage* to perform the fitting, NOT |
---|
| 510 | the *Fit* button on the individual *FitPage*'s. |
---|
[ec392464] | 511 | |
---|
[6af2785] | 512 | Unlike in single fit mode, the results of batch fits are not returned to |
---|
| 513 | the *BatchPage*. Instead, a spreadsheet-like :ref:`Grid_Window` will appear. |
---|
[ec392464] | 514 | |
---|
[6af2785] | 515 | If you want to visually check a graph of a particular fit, click on the name of |
---|
| 516 | a *Data set* in the *Grid Window* and then click the *View Fits* button. The |
---|
| 517 | data and the model fit will be displayed. If you select mutliple data sets they |
---|
| 518 | will all appear on one graph. |
---|
[ec392464] | 519 | |
---|
[6af2785] | 520 | .. image:: view_button.bmp |
---|
[ec392464] | 521 | |
---|
[6af2785] | 522 | *NB: In theory, returning to the BatchPage and changing the name of the I(Q)* |
---|
| 523 | *data source should also work, but at the moment whilst this does change the* |
---|
| 524 | *data set displayed it always superimposes the 'theory' corresponding to the* |
---|
| 525 | *starting parameters.* |
---|
[ec392464] | 526 | |
---|
[6af2785] | 527 | If you select a 'Chi2' value and click the *View Fits* button a graph of the |
---|
| 528 | residuals for that data set is displayed. Again, if you select multiple 'Chi2' |
---|
[f9250dc] | 529 | values then all the residuals data will appear on one graph. Also see |
---|
| 530 | :ref:`Assessing_Fit_Quality`. |
---|
[ec392464] | 531 | |
---|
[6af2785] | 532 | Chain Fitting |
---|
| 533 | ^^^^^^^^^^^^^ |
---|
[ec392464] | 534 | |
---|
[6af2785] | 535 | By default, the *same* parameter values copied from the initial single fit into |
---|
| 536 | the *BatchPage* will be used as the starting parameters for all batch fits. It |
---|
| 537 | is, however, possible to get *SasView* to use the results of a fit to a preceding |
---|
| 538 | data set as the starting parameters for the next fit in the sequence. This |
---|
| 539 | variation of batch fitting is called *Chain Fitting*, and will considerably speed |
---|
| 540 | up model-fitting if you have lots of very similar data sets where a few parameters |
---|
| 541 | are gradually changing. Do not use chain fitting on disparate data sets. |
---|
[ec392464] | 542 | |
---|
[6af2785] | 543 | To use chain fitting, select *Chain Fitting* under *Fitting* in the menu bar. It |
---|
| 544 | toggles on/off, so selecting it again will switch back to normal batch fitting. |
---|
[ec392464] | 545 | |
---|
[6af2785] | 546 | .. _Grid_Window: |
---|
[ec392464] | 547 | |
---|
[6af2785] | 548 | Grid Window |
---|
| 549 | ^^^^^^^^^^^ |
---|
[ec392464] | 550 | |
---|
[6af2785] | 551 | The *Grid Window* provides an easy way to view the results from batch fitting. |
---|
| 552 | It will be displayed automatically when a batch fit completes, but may be |
---|
| 553 | opened at any time by selecting *Show Grid Window* under *View* in the menu |
---|
| 554 | bar. |
---|
[ec392464] | 555 | |
---|
[6af2785] | 556 | .. image:: restore_batch_window.bmp |
---|
[ec392464] | 557 | |
---|
[6af2785] | 558 | Once a batch fit is completed, all model parameters are displayed but *not* |
---|
| 559 | their uncertainties. To view the uncertainties, click on a given column then |
---|
| 560 | go to *Edit* in the menu bar, select *Insert Column Before* and choose the |
---|
| 561 | required data from the list. An empty column can be inserted in the same way. |
---|
[ec392464] | 562 | |
---|
[6af2785] | 563 | To remove a column from the grid, click on the column header and choose |
---|
| 564 | *Remove Column* under *Edit* in the menu bar. The same functionality also |
---|
| 565 | allows you to re-order columns. |
---|
[ec392464] | 566 | |
---|
[6af2785] | 567 | *NB: You cannot insert/remove/re-order the rows in the Grid Window.* |
---|
[ec392464] | 568 | |
---|
[6af2785] | 569 | All of the above functions are also available by right-clicking on a column |
---|
| 570 | label. |
---|
[ec392464] | 571 | |
---|
[6af2785] | 572 | .. image:: edit_menu.bmp |
---|
[ec392464] | 573 | |
---|
[6af2785] | 574 | *NB: If there is an existing Grid Window and another batch fit is performed,* |
---|
| 575 | *an additional 'Table' tab will be added to the Grid Window.* |
---|
[ec392464] | 576 | |
---|
[6af2785] | 577 | The parameter values in the *currently selected* table of the *Grid Window* |
---|
| 578 | can be output to a CSV file by choosing *Save As* under *File* in the (*Grid* |
---|
| 579 | *Window*) menu bar. The default filename includes the date and time that the |
---|
| 580 | batch fit was performed. |
---|
[ec392464] | 581 | |
---|
[6af2785] | 582 | Saved CSV files can be reloaded by choosing *Open* under *File* in the *Grid* |
---|
| 583 | *Window* menu bar. The loaded parameters will appear in a new table tab. |
---|
[ec392464] | 584 | |
---|
[6af2785] | 585 | .. image:: file_menu.bmp |
---|
[ec392464] | 586 | |
---|
[6af2785] | 587 | *NB: Saving the Grid Window does not save any experimental data, residuals* |
---|
| 588 | *or actual model fits. Consequently if you reload a saved CSV file the* |
---|
| 589 | *ability to View Fits will be lost.* |
---|
[ec392464] | 590 | |
---|
[6af2785] | 591 | Parameter Plots |
---|
| 592 | ^^^^^^^^^^^^^^^ |
---|
[ec392464] | 593 | |
---|
[6af2785] | 594 | Any column of *numeric* parameter values can be plotted against another using |
---|
| 595 | the *Grid Window*. Simply select one column at the time and click the *Add* |
---|
| 596 | button next to the required *X/Y-axis Selection Range* text box. When both |
---|
| 597 | the X and Y axis boxes have been completed, click the *Plot* button. |
---|
[ec392464] | 598 | |
---|
[6af2785] | 599 | When the *Add* button is clicked, *SasView* also automatically completes the |
---|
| 600 | *X/Y-axis Label* text box with the heading from Row 1 of the selected table, |
---|
| 601 | but different labels and units can be entered manually. |
---|
[ec392464] | 602 | |
---|
| 603 | .. image:: plot_button.bmp |
---|
| 604 | |
---|
[6af2785] | 605 | The *X/Y-axis Selection Range* can be edited manually. The text control box |
---|
| 606 | recognises the operators +, -, \*, /, or 'pow', and allows the following |
---|
| 607 | types of expression : |
---|
| 608 | |
---|
| 609 | 1) if an axis label range is a function of 1 or more *columns*, write |
---|
| 610 | this type of expression |
---|
[ec392464] | 611 | |
---|
[6af2785] | 612 | constant1 * column_name1 [minimum row index : maximum row index] |
---|
| 613 | operator constant2 * column_name2 [minimum row index : maximum row index] |
---|
[ec392464] | 614 | |
---|
[6af2785] | 615 | Example: radius [2 : 5] -3 * scale [2 : 5] |
---|
[ec392464] | 616 | |
---|
[6af2785] | 617 | 2) if only some *values* of a given column are needed but the range between |
---|
| 618 | the first row and the last row used is not continuous, write this type of |
---|
| 619 | expression |
---|
[ec392464] | 620 | |
---|
[6af2785] | 621 | column_name1 [minimum row index1 : maximum row index1] , column_name1 |
---|
| 622 | [minimum row index2 : maximum row index2] |
---|
[ec392464] | 623 | |
---|
[6af2785] | 624 | Example: radius [2 : 5] , radius [10 : 25] |
---|
[ec392464] | 625 | |
---|
| 626 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
[6af2785] | 627 | |
---|
| 628 | .. note:: This help document was last changed by Steve King, 04Jun2015 |
---|