[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 | |
---|
[98b30b4] | 6 | .. |inlineimage004| image:: sm_image004.gif |
---|
| 7 | .. |inlineimage005| image:: sm_image005.gif |
---|
| 8 | .. |inlineimage008| image:: sm_image008.gif |
---|
| 9 | .. |inlineimage009| image:: sm_image009.gif |
---|
| 10 | .. |inlineimage010| image:: sm_image010.gif |
---|
| 11 | .. |inlineimage011| image:: sm_image011.gif |
---|
| 12 | .. |inlineimage012| image:: sm_image012.gif |
---|
| 13 | .. |inlineimage018| image:: sm_image018.gif |
---|
| 14 | .. |inlineimage019| image:: sm_image019.gif |
---|
| 15 | |
---|
[ec392464] | 16 | |
---|
[b64b87c] | 17 | Fitting |
---|
| 18 | ======= |
---|
[ec392464] | 19 | |
---|
[3e1c9e5] | 20 | .. note:: If some code blocks are not readable, expand the documentation window |
---|
| 21 | |
---|
[a6f3613] | 22 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 23 | |
---|
| 24 | Preparing to fit data |
---|
| 25 | --------------------- |
---|
| 26 | |
---|
| 27 | To fit some data you must first load some data, activate one or more data sets, |
---|
[b64b87c] | 28 | send those data sets to fitting, and select a model to fit to each data set. |
---|
[a6f3613] | 29 | |
---|
[f3377b8] | 30 | Instructions on how to load and activate data are in the section :ref:`Loading_data`. |
---|
[ec392464] | 31 | |
---|
[a6f3613] | 32 | SasView can fit data in one of three ways: |
---|
[ec392464] | 33 | |
---|
[a6f3613] | 34 | * in *Single* fit mode - individual data sets are fitted independently one-by-one |
---|
[ec392464] | 35 | |
---|
[f3377b8] | 36 | * 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] | 37 | |
---|
[f3377b8] | 38 | * 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] | 39 | |
---|
| 40 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
[ec392464] | 41 | |
---|
[a6f3613] | 42 | Selecting a model |
---|
| 43 | ----------------- |
---|
[ec392464] | 44 | |
---|
[a6f3613] | 45 | By default, the models in SasView are grouped into five categories |
---|
[ec392464] | 46 | |
---|
[a6f3613] | 47 | * *Shapes* - models describing 'objects' (spheres, cylinders, etc) |
---|
[f3377b8] | 48 | * *Shape-Independent* - models describing structure in terms of density correlation functions, fractals, peaks, power laws, etc |
---|
[8570246] | 49 | * *Customized Models* - SasView- or User-created (non-library) Python models |
---|
[a6f3613] | 50 | * *Uncategorised* - other models (for reflectivity, etc) |
---|
| 51 | * *Structure Factor* - S(Q) models |
---|
[ec392464] | 52 | |
---|
[a6f3613] | 53 | Use the *Category* drop-down menu to chose a category of model, then select |
---|
[f3377b8] | 54 | a model from the drop-down menu beneath. A graph of the chosen model, calculated |
---|
| 55 | using default parameter values, will appear. The graph will update dynamically |
---|
| 56 | as the parameter values are changed. |
---|
| 57 | |
---|
| 58 | You can decide your own model categorizations using the :ref:`Category_Manager`. |
---|
[ce62e75] | 59 | |
---|
[a6f3613] | 60 | Once you have selected a model you can read its help documentation by clicking |
---|
| 61 | on the *Description* button to the right. |
---|
| 62 | |
---|
| 63 | Show 1D/2D |
---|
| 64 | ^^^^^^^^^^ |
---|
| 65 | |
---|
| 66 | Models are normally fitted to 1D (ie, I(Q) vs Q) data sets, but some models in |
---|
| 67 | SasView can also be fitted to 2D (ie, I(Qx,Qy) vs Qx vs Qy) data sets. |
---|
| 68 | |
---|
| 69 | *NB: Magnetic scattering can only be fitted in SasView in 2D.* |
---|
| 70 | |
---|
| 71 | To activate 2D fitting mode, click the *Show 2D* button on the *Fit Page*. To |
---|
| 72 | return to 1D fitting model, click the same button (which will now say *Show 1D*). |
---|
[ce62e75] | 73 | |
---|
[ec392464] | 74 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 75 | |
---|
[a6f3613] | 76 | .. _Category_Manager: |
---|
[a0637de] | 77 | |
---|
[a6f3613] | 78 | Category Manager |
---|
| 79 | ---------------- |
---|
| 80 | |
---|
[f3377b8] | 81 | To change the model categorizations, either choose *Category Manager* from the |
---|
| 82 | *View* option on the menubar, or click on the *Modify* button on the *Fit Page*. |
---|
[a6f3613] | 83 | |
---|
[f3377b8] | 84 | .. image:: cat_fig0.bmp |
---|
[a6f3613] | 85 | |
---|
[f3377b8] | 86 | The categorization of all models except the customized models can be reassigned, |
---|
| 87 | added to, and removed using *Category Manager*. Models can also be hidden from view |
---|
| 88 | in the drop-down menus. |
---|
[a6f3613] | 89 | |
---|
[f3377b8] | 90 | .. image:: cat_fig1.bmp |
---|
[a6f3613] | 91 | |
---|
[f3377b8] | 92 | Changing category |
---|
| 93 | ^^^^^^^^^^^^^^^^^ |
---|
[a6f3613] | 94 | |
---|
[f3377b8] | 95 | To change category, highlight a model in the list by left-clicking on its entry and |
---|
| 96 | then click the *Modify* button. Use the *Change Category* panel that appears to make |
---|
| 97 | the required changes. |
---|
[a6f3613] | 98 | |
---|
[f3377b8] | 99 | .. image:: cat_fig2.bmp |
---|
[a6f3613] | 100 | |
---|
[f3377b8] | 101 | To create a category for the selected model, click the *Add* button. In order |
---|
| 102 | to delete a category, select the category name and click the *Remove Selected* |
---|
| 103 | button. Then click *Done*. |
---|
[a6f3613] | 104 | |
---|
[f3377b8] | 105 | Showing/hiding models |
---|
| 106 | ^^^^^^^^^^^^^^^^^^^^^ |
---|
[a6f3613] | 107 | |
---|
[8570246] | 108 | Use the *Enable All / Disable All* buttons and the check boxes beside each model to |
---|
[f3377b8] | 109 | select the models to show/hide. To apply the selection, click *Ok*. Otherwise click |
---|
| 110 | *Cancel*. |
---|
[a6f3613] | 111 | |
---|
[8570246] | 112 | *NB: It may be necessary to change to a different category and then back again* |
---|
[f3377b8] | 113 | *before any changes take effect.* |
---|
[a6f3613] | 114 | |
---|
| 115 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 116 | |
---|
[f3377b8] | 117 | Model Functions |
---|
| 118 | --------------- |
---|
[a6f3613] | 119 | |
---|
[3e1c9e5] | 120 | For a complete list of all the library models available in SasView, see the `Model Documentation <../../../index.html>`_ . |
---|
[a6f3613] | 121 | |
---|
[f3377b8] | 122 | It is also possible to add your own models. |
---|
[a6f3613] | 123 | |
---|
[f3377b8] | 124 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
[a6f3613] | 125 | |
---|
[b5846a10] | 126 | .. _Adding_your_own_models: |
---|
| 127 | |
---|
[3e1c9e5] | 128 | Adding your own Models |
---|
[f3377b8] | 129 | ---------------------- |
---|
[a6f3613] | 130 | |
---|
[3e1c9e5] | 131 | There are essentially three ways to generate new fitting models for SasView: |
---|
| 132 | |
---|
| 133 | * Using the SasView :ref:`New_Plugin_Model` helper dialog (best for beginners and/or relatively simple models) |
---|
| 134 | * By copying/editing an existing model (this can include models generated by the *New Plugin Model* dialog) in the :ref:`Python_shell` or :ref:`Advanced_Plugin_Editor` (suitable for all use cases) |
---|
| 135 | * By writing a model from scratch outside of SasView (only recommended for code monkeys!) |
---|
| 136 | |
---|
| 137 | Please read the guidance on :ref:`Writing_a_Plugin` before proceeding. |
---|
[f3377b8] | 138 | |
---|
[3e1c9e5] | 139 | **To be found by SasView your model must reside in the *~\\.sasview\\plugin_models* folder.** |
---|
[f3377b8] | 140 | |
---|
[a6f3613] | 141 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 142 | |
---|
[3e1c9e5] | 143 | .. _Plugin_Model_Operations: |
---|
[f3377b8] | 144 | |
---|
[3e1c9e5] | 145 | Plugin Model Operations |
---|
| 146 | ----------------------- |
---|
[a6f3613] | 147 | |
---|
[3e1c9e5] | 148 | From the *Fitting* option in the menu bar, select *Plugin Model Operations* |
---|
[a6f3613] | 149 | |
---|
[82b0b05e] | 150 | .. image:: edit_model_menu.png |
---|
[a6f3613] | 151 | |
---|
[3e1c9e5] | 152 | and then one of the sub-options |
---|
[f3377b8] | 153 | |
---|
[3e1c9e5] | 154 | * *New Plugin Model* - to create a plugin model template with a helper dialog |
---|
| 155 | * *Sum|Multi(p1,p2)* - to create a plugin model by summing/multiplying *existing models* in the model library |
---|
| 156 | * *Advanced Plugin Editor* - to create/edit a plugin model in a Python shell |
---|
| 157 | * *Delete Plugin Models* - to delete a plugin model |
---|
| 158 | * *Load Plugin Models* - to (re-)load plugin models |
---|
[a6f3613] | 159 | |
---|
[3e1c9e5] | 160 | .. _New_Plugin_Model: |
---|
| 161 | |
---|
| 162 | New Plugin Model |
---|
| 163 | ^^^^^^^^^^^^^^^^ |
---|
[a6f3613] | 164 | |
---|
[26c8be3] | 165 | Relatively straightforward models can be programmed directly from the SasView GUI |
---|
| 166 | using the *New Plugin Model Function*. |
---|
| 167 | |
---|
[a6f3613] | 168 | .. image:: new_model.bmp |
---|
| 169 | |
---|
[26c8be3] | 170 | When using this feature, be aware that even if your code has errors, including |
---|
| 171 | syntax errors, a model file is still generated. When you then correct the errors |
---|
| 172 | and click 'Apply' again to re-compile you will get an error informing you that |
---|
| 173 | the model already exists if the 'Overwrite' box is not checked. In this case you |
---|
| 174 | will need to supply a new model function name. By default the 'Overwrite' box is |
---|
| 175 | *checked*\ . |
---|
[f3377b8] | 176 | |
---|
[26c8be3] | 177 | Also note that the 'Fit Parameters' have been split into two sections: those which |
---|
| 178 | can be polydisperse (shape and orientation parameters) and those which are not |
---|
| 179 | (eg, scattering length densities). |
---|
| 180 | |
---|
| 181 | A model file generated by this option can be viewed and further modified using |
---|
| 182 | the :ref:`Advanced_Plugin_Editor` . |
---|
[05829fb] | 183 | |
---|
[a6f3613] | 184 | Sum|Multi(p1,p2) |
---|
| 185 | ^^^^^^^^^^^^^^^^ |
---|
| 186 | |
---|
| 187 | .. image:: sum_model.bmp |
---|
[a0637de] | 188 | |
---|
[3e1c9e5] | 189 | This option creates a custom model of the form:: |
---|
[f3377b8] | 190 | |
---|
[3e1c9e5] | 191 | Custom Model = scale_factor \* {(scale_1 \* model_1) \+ (scale_2 \* model_2)} \+ background |
---|
[f3377b8] | 192 | |
---|
[3e1c9e5] | 193 | or:: |
---|
| 194 | |
---|
| 195 | Custom Model = scale_factor \* model_1 \* model_2 \+ background |
---|
| 196 | |
---|
| 197 | In the *Easy Sum/Multi Editor* give the new model a function name and brief |
---|
| 198 | description (to appear under the *Details* button on the *FitPage*). Then select |
---|
[f3377b8] | 199 | two existing models, as p1 and p2, and the required operator, '+' or '*' between |
---|
| 200 | them. Finally, click the *Apply* button to generate the model and then click *Close*. |
---|
| 201 | |
---|
[3e1c9e5] | 202 | Any changes to a plugin model generated in this way only become effective *after* it is re-selected from the model drop-down menu on the FitPage. |
---|
[f3377b8] | 203 | |
---|
[3e1c9e5] | 204 | .. _Advanced_Plugin_Editor: |
---|
[f3377b8] | 205 | |
---|
[3e1c9e5] | 206 | Advanced Plugin Editor |
---|
| 207 | ^^^^^^^^^^^^^^^^^^^^^^ |
---|
[ec392464] | 208 | |
---|
[3e1c9e5] | 209 | Selecting this option shows all the plugin models in the plugin model folder, on Windows this is |
---|
[f3377b8] | 210 | |
---|
[afb93df] | 211 | *C:\\Users\\{username}\\.sasview\\plugin_models* |
---|
[f3377b8] | 212 | |
---|
| 213 | You can edit, modify, and save the Python code in any of these models using the |
---|
[3e1c9e5] | 214 | *Advanced Plugin Model Editor*. Note that this is actually the same tool as the :ref:`Python_shell` . |
---|
[f3377b8] | 215 | |
---|
[afb93df] | 216 | For details of the SasView plugin model format see :ref:`Writing_a_Plugin` . |
---|
[05829fb] | 217 | |
---|
[afb93df] | 218 | .. 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! |
---|
[f3377b8] | 219 | |
---|
[3e1c9e5] | 220 | When editing is complete, select *Run* > *Check Model* from the *Advanced Plugin 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'. |
---|
[f3377b8] | 221 | |
---|
[3e1c9e5] | 222 | .. image:: ../calculator/new_pycrust_example_2.png |
---|
| 223 | |
---|
| 224 | To use the model, go to the relevant *Fit Page*, select the *Plugin Models* |
---|
[f3377b8] | 225 | category and then select the model from the drop-down menu. |
---|
| 226 | |
---|
[3e1c9e5] | 227 | Any changes to a plugin model generated in this way only become effective *after* it is re-selected from the model drop-down menu on the FitPage. |
---|
[a6f3613] | 228 | |
---|
[3e1c9e5] | 229 | Delete Plugin Models |
---|
| 230 | ^^^^^^^^^^^^^^^^^^^^ |
---|
[a6f3613] | 231 | |
---|
[3e1c9e5] | 232 | Simply highlight the plugin model to be removed. The operation is final!!! |
---|
[f3377b8] | 233 | |
---|
[3e1c9e5] | 234 | *NB: Plugin models shipped with SasView cannot be removed in this way.* |
---|
[ec392464] | 235 | |
---|
[3e1c9e5] | 236 | Load Plugin Models |
---|
| 237 | ^^^^^^^^^^^^^^^^^^ |
---|
[afb93df] | 238 | |
---|
[3e1c9e5] | 239 | This option loads (or re-loads) all models present in the *~\\.sasview\\plugin_models* folder. |
---|
[afb93df] | 240 | |
---|
[ec392464] | 241 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 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 | |
---|
[b64b87c] | 342 | When data is sent to the fitting it is plotted in a graph window as markers. |
---|
[4666660] | 343 | |
---|
| 344 | If a graph does not appear, or a graph window appears but is empty, then the data |
---|
| 345 | has not loaded correctly. Check to see if there is a message in the :ref:`Status_Bar` |
---|
| 346 | or in the *Console* window. |
---|
| 347 | |
---|
| 348 | Assuming the data has loaded correctly, when a model is selected a green model |
---|
| 349 | calculation (or what SasView calls a 'Theory') line will appear in the earlier graph |
---|
| 350 | window, and a second graph window will appear displaying the residuals (the |
---|
| 351 | difference between the experimental data and the theory) at the same X-data values. |
---|
[f9250dc] | 352 | See :ref:`Assessing_Fit_Quality`. |
---|
[4666660] | 353 | |
---|
| 354 | The objective of model-fitting is to find a *physically-plausible* model, and set |
---|
| 355 | of model parameters, that generate a theory that reproduces the experimental data |
---|
| 356 | and gives residual values as close to zero as possible. |
---|
| 357 | |
---|
| 358 | Change the default values of the model parameters by hand until the theory line |
---|
| 359 | starts to represent the experimental data. Then uncheck the tick boxes alongside |
---|
| 360 | all parameters *except* the 'background' and the 'scale'. Click the *Fit* button. |
---|
| 361 | SasView will optimise the values of the 'background' and 'scale' and also display |
---|
| 362 | the corresponding uncertainties on the optimised values. |
---|
| 363 | |
---|
| 364 | *NB: If no uncertainty is shown it generally means that the model is not very* |
---|
| 365 | *dependent on the corresponding parameter (or that one or more parameters are* |
---|
| 366 | *'correlated').* |
---|
| 367 | |
---|
| 368 | In the bottom left corner of the *Fit Page* is a box displaying the normalised value |
---|
| 369 | of the statistical |chi|\ :sup:`2` parameter returned by the optimiser. |
---|
| 370 | |
---|
| 371 | Now check the box for another model parameter and click *Fit* again. Repeat this |
---|
| 372 | process until most or all parameters are checked and have been optimised. As the |
---|
| 373 | fit of the theory to the experimental data improves the value of 'chi2/Npts' will |
---|
| 374 | decrease. A good model fit should easily produce values of 'chi2/Npts' that are |
---|
[ff42a26] | 375 | close to zero, and certainly <100. See :ref:`Assessing_Fit_Quality`. |
---|
[4666660] | 376 | |
---|
| 377 | SasView has a number of different optimisers (see the section :ref:`Fitting_Options`). |
---|
| 378 | The DREAM optimiser is the most sophisticated, but may not necessarily be the best |
---|
| 379 | option for fitting simple models. If uncertain, try the Levenberg-Marquardt optimiser |
---|
| 380 | initially. |
---|
[ec392464] | 381 | |
---|
| 382 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 383 | |
---|
[a6f3613] | 384 | Simultaneous Fit Mode |
---|
| 385 | --------------------- |
---|
[ec392464] | 386 | |
---|
[63d314b] | 387 | *NB: Before proceeding, ensure that the Single Mode radio button at the bottom of* |
---|
| 388 | *the Data Explorer is checked (see the section* :ref:`Loading_data` *).* |
---|
[ec392464] | 389 | |
---|
[6af2785] | 390 | This mode is an extension of the :ref:`Single_Fit_Mode` that fits two or more data |
---|
[63d314b] | 391 | sets *to the same model* simultaneously. If necessary it is possible to constrain |
---|
| 392 | fit parameters between data sets (eg, to fix a background level, or radius, etc). |
---|
| 393 | |
---|
[b5846a10] | 394 | If the data to be fit are in multiple files, load each file, then select each file |
---|
| 395 | in the *Data Explorer*, and *Send To Fitting*. If multiple data sets are in one file, |
---|
| 396 | load that file, *Unselect All Data*, select just those data sets to be fitted, and |
---|
| 397 | *Send To Fitting*. Either way, the result should be that for *n* data sets you have |
---|
[6af2785] | 398 | 2\ *n* graphs (*n* of the data and model fit, and *n* of the resulting residuals). But |
---|
[f9250dc] | 399 | it may be helpful to minimise the residuals plots for clarity. Also see |
---|
| 400 | :ref:`Assessing_Fit_Quality`. |
---|
[b5846a10] | 401 | |
---|
| 402 | *NB: If you need to use a customized model, you must ensure that model is available* |
---|
| 403 | *first (see* :ref:`Adding_your_own_models` *).* |
---|
| 404 | |
---|
[6af2785] | 405 | Method |
---|
| 406 | ^^^^^^ |
---|
| 407 | |
---|
[b5846a10] | 408 | Now go to each *FitPage* in turn and: |
---|
| 409 | |
---|
| 410 | Select the required category and model; |
---|
| 411 | |
---|
| 412 | Unselect all the model parameters; |
---|
| 413 | |
---|
| 414 | Enter some starting guesses for the parameters; |
---|
| 415 | |
---|
| 416 | Enter any parameter limits (recommended); |
---|
[63d314b] | 417 | |
---|
[b5846a10] | 418 | Select which parameters will refine (selecting all is generally a bad idea...); |
---|
[63d314b] | 419 | |
---|
[b5846a10] | 420 | When done, select *Constrained or Simultaneous Fit* under *Fitting* in the menu bar. |
---|
| 421 | |
---|
| 422 | In the *Const & Simul Fit* page that appears, select which data sets are to be |
---|
| 423 | simultaneously fitted (this will probably be all of them or you would not have loaded |
---|
| 424 | them in the first place!). |
---|
| 425 | |
---|
| 426 | To tie parameters between the data sets with constraints, check the 'yes' radio button |
---|
| 427 | next to *Add Constraint?* in the *Fit Constraints* box. |
---|
| 428 | |
---|
| 429 | *NB: You can only constrain parameters that are set to refine.* |
---|
| 430 | |
---|
| 431 | When ready, click the *Fit* button on the *Const & Simul Fit* page, NOT the *Fit* |
---|
| 432 | button on the individual *FitPage*'s. |
---|
[63d314b] | 433 | |
---|
| 434 | Simultaneous Fits without Constraints |
---|
| 435 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
---|
[ec392464] | 436 | |
---|
[b5846a10] | 437 | The results of the model-fitting will be returned to each of the individual |
---|
| 438 | *FitPage*'s. |
---|
[ec392464] | 439 | |
---|
[b5846a10] | 440 | Note that the chi2/Npts value returned is the SUM of the chi2/Npts of each fit. To |
---|
[6af2785] | 441 | see the chi2/Npts value for a specific *FitPage*, click the *Compute* button at the |
---|
[f9250dc] | 442 | bottom of that *FitPage* to recalculate. Also see :ref:`Assessing_Fit_Quality`. |
---|
[ec392464] | 443 | |
---|
[63d314b] | 444 | Simultaneous Fits with Constraints |
---|
| 445 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
---|
[ec392464] | 446 | |
---|
[b5846a10] | 447 | Use the *Easy Setup* drop-down buttons in the *Const & Simul Fit* page to set |
---|
| 448 | up constraints between *FitPage*'s. |
---|
| 449 | |
---|
[6af2785] | 450 | Constraints will generally be of the form |
---|
| 451 | |
---|
| 452 | Mi Parameter1 = Mj.Parameter1 |
---|
| 453 | |
---|
| 454 | however the text box after the '=' sign can be used to adjust this |
---|
| 455 | relationship; for example |
---|
| 456 | |
---|
| 457 | Mi Parameter1 = scalar \* Mj.Parameter1 |
---|
| 458 | |
---|
| 459 | A 'free-form' constraint box is also provided. |
---|
[b5846a10] | 460 | |
---|
| 461 | Many constraints can be entered for a single fit. |
---|
| 462 | |
---|
| 463 | The results of the model-fitting will be returned to each of the individual |
---|
| 464 | *FitPage*'s. |
---|
[ec392464] | 465 | |
---|
[b5846a10] | 466 | Note that the chi2/Npts value returned is the SUM of the chi2/Npts of each fit. To |
---|
[6af2785] | 467 | see the chi2/Npts value for a specific *FitPage*, click the *Compute* button at the |
---|
[f9250dc] | 468 | bottom of that *FitPage* to recalculate. Also see :ref:`Assessing_Fit_Quality`. |
---|
[ec392464] | 469 | |
---|
| 470 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 471 | |
---|
[a6f3613] | 472 | Batch Fit Mode |
---|
| 473 | -------------- |
---|
[ec392464] | 474 | |
---|
[6af2785] | 475 | *NB: Before proceeding, ensure that the Single Mode radio button at the bottom of* |
---|
| 476 | *the Data Explorer is checked (see the section* :ref:`Loading_data` *). The Batch* |
---|
| 477 | *Mode button will be used later on!* |
---|
[63d314b] | 478 | |
---|
[6af2785] | 479 | This mode *sequentially* fits two or more data sets *to the same model*. Unlike in |
---|
| 480 | simultaneous fitting, in batch fitting it is not possible to constrain fit parameters |
---|
| 481 | between data sets. |
---|
[ec392464] | 482 | |
---|
[6af2785] | 483 | If the data to be fit are in multiple files, load each file in the *Data Explorer*. |
---|
| 484 | If multiple data sets are in one file, load just that file. *Unselect All Data*, then |
---|
| 485 | select a single initial data set to be fitted. Fit that selected data set as described |
---|
| 486 | above under :ref:`Single_Fit_Mode` . |
---|
[ec392464] | 487 | |
---|
[6af2785] | 488 | *NB: If you need to use a customized model, you must ensure that model is available* |
---|
| 489 | *first (see* :ref:`Adding_your_own_models` *).* |
---|
[ec392464] | 490 | |
---|
[6af2785] | 491 | Method |
---|
| 492 | ^^^^^^ |
---|
[ec392464] | 493 | |
---|
[6af2785] | 494 | Now *Select All Data* in the *Data Explorer*, check the *Batch Mode* radio button |
---|
| 495 | at the bottom of that panel and *Send To Fitting*. A *BatchPage* will be created. |
---|
[ec392464] | 496 | |
---|
[6af2785] | 497 | .. image:: batch_button_area.bmp |
---|
[ec392464] | 498 | |
---|
[6af2785] | 499 | *NB: The Batch Page can also be created by checking the Batch Mode radio button* |
---|
| 500 | *and selecting New Fit Page under Fitting in the menu bar.* |
---|
[ec392464] | 501 | |
---|
[6af2785] | 502 | Using the drop-down menus in the *BatchPage*, now set up the *same* data set |
---|
| 503 | with the *same* model that you just fitted in single fit mode. A quick way to |
---|
| 504 | set the model parameter values is to just copy them from the earlier Single |
---|
| 505 | Fit. To do this, go back to the Single Fit *FitPage*, select *Copy Params* |
---|
| 506 | under *Edit* in the menu bar, then go back to the *BatchPage* and *Paste Params*. |
---|
[ec392464] | 507 | |
---|
[6af2785] | 508 | When ready, use the *Fit* button on the *BatchPage* to perform the fitting, NOT |
---|
| 509 | the *Fit* button on the individual *FitPage*'s. |
---|
[ec392464] | 510 | |
---|
[6af2785] | 511 | Unlike in single fit mode, the results of batch fits are not returned to |
---|
| 512 | the *BatchPage*. Instead, a spreadsheet-like :ref:`Grid_Window` will appear. |
---|
[ec392464] | 513 | |
---|
[6af2785] | 514 | If you want to visually check a graph of a particular fit, click on the name of |
---|
| 515 | a *Data set* in the *Grid Window* and then click the *View Fits* button. The |
---|
| 516 | data and the model fit will be displayed. If you select mutliple data sets they |
---|
| 517 | will all appear on one graph. |
---|
[ec392464] | 518 | |
---|
[6af2785] | 519 | .. image:: view_button.bmp |
---|
[ec392464] | 520 | |
---|
[6af2785] | 521 | *NB: In theory, returning to the BatchPage and changing the name of the I(Q)* |
---|
| 522 | *data source should also work, but at the moment whilst this does change the* |
---|
| 523 | *data set displayed it always superimposes the 'theory' corresponding to the* |
---|
| 524 | *starting parameters.* |
---|
[ec392464] | 525 | |
---|
[6af2785] | 526 | If you select a 'Chi2' value and click the *View Fits* button a graph of the |
---|
| 527 | residuals for that data set is displayed. Again, if you select multiple 'Chi2' |
---|
[f9250dc] | 528 | values then all the residuals data will appear on one graph. Also see |
---|
| 529 | :ref:`Assessing_Fit_Quality`. |
---|
[ec392464] | 530 | |
---|
[6af2785] | 531 | Chain Fitting |
---|
| 532 | ^^^^^^^^^^^^^ |
---|
[ec392464] | 533 | |
---|
[6af2785] | 534 | By default, the *same* parameter values copied from the initial single fit into |
---|
| 535 | the *BatchPage* will be used as the starting parameters for all batch fits. It |
---|
| 536 | is, however, possible to get *SasView* to use the results of a fit to a preceding |
---|
| 537 | data set as the starting parameters for the next fit in the sequence. This |
---|
| 538 | variation of batch fitting is called *Chain Fitting*, and will considerably speed |
---|
| 539 | up model-fitting if you have lots of very similar data sets where a few parameters |
---|
| 540 | are gradually changing. Do not use chain fitting on disparate data sets. |
---|
[ec392464] | 541 | |
---|
[6af2785] | 542 | To use chain fitting, select *Chain Fitting* under *Fitting* in the menu bar. It |
---|
| 543 | toggles on/off, so selecting it again will switch back to normal batch fitting. |
---|
[ec392464] | 544 | |
---|
[6af2785] | 545 | .. _Grid_Window: |
---|
[ec392464] | 546 | |
---|
[6af2785] | 547 | Grid Window |
---|
| 548 | ^^^^^^^^^^^ |
---|
[ec392464] | 549 | |
---|
[6af2785] | 550 | The *Grid Window* provides an easy way to view the results from batch fitting. |
---|
| 551 | It will be displayed automatically when a batch fit completes, but may be |
---|
| 552 | opened at any time by selecting *Show Grid Window* under *View* in the menu |
---|
| 553 | bar. |
---|
[ec392464] | 554 | |
---|
[6af2785] | 555 | .. image:: restore_batch_window.bmp |
---|
[ec392464] | 556 | |
---|
[6af2785] | 557 | Once a batch fit is completed, all model parameters are displayed but *not* |
---|
| 558 | their uncertainties. To view the uncertainties, click on a given column then |
---|
| 559 | go to *Edit* in the menu bar, select *Insert Column Before* and choose the |
---|
| 560 | required data from the list. An empty column can be inserted in the same way. |
---|
[ec392464] | 561 | |
---|
[6af2785] | 562 | To remove a column from the grid, click on the column header and choose |
---|
| 563 | *Remove Column* under *Edit* in the menu bar. The same functionality also |
---|
| 564 | allows you to re-order columns. |
---|
[ec392464] | 565 | |
---|
[6af2785] | 566 | *NB: You cannot insert/remove/re-order the rows in the Grid Window.* |
---|
[ec392464] | 567 | |
---|
[6af2785] | 568 | All of the above functions are also available by right-clicking on a column |
---|
| 569 | label. |
---|
[ec392464] | 570 | |
---|
[6af2785] | 571 | .. image:: edit_menu.bmp |
---|
[ec392464] | 572 | |
---|
[6af2785] | 573 | *NB: If there is an existing Grid Window and another batch fit is performed,* |
---|
| 574 | *an additional 'Table' tab will be added to the Grid Window.* |
---|
[ec392464] | 575 | |
---|
[6af2785] | 576 | The parameter values in the *currently selected* table of the *Grid Window* |
---|
| 577 | can be output to a CSV file by choosing *Save As* under *File* in the (*Grid* |
---|
| 578 | *Window*) menu bar. The default filename includes the date and time that the |
---|
| 579 | batch fit was performed. |
---|
[ec392464] | 580 | |
---|
[6af2785] | 581 | Saved CSV files can be reloaded by choosing *Open* under *File* in the *Grid* |
---|
| 582 | *Window* menu bar. The loaded parameters will appear in a new table tab. |
---|
[ec392464] | 583 | |
---|
[6af2785] | 584 | .. image:: file_menu.bmp |
---|
[ec392464] | 585 | |
---|
[6af2785] | 586 | *NB: Saving the Grid Window does not save any experimental data, residuals* |
---|
| 587 | *or actual model fits. Consequently if you reload a saved CSV file the* |
---|
| 588 | *ability to View Fits will be lost.* |
---|
[ec392464] | 589 | |
---|
[6af2785] | 590 | Parameter Plots |
---|
| 591 | ^^^^^^^^^^^^^^^ |
---|
[ec392464] | 592 | |
---|
[6af2785] | 593 | Any column of *numeric* parameter values can be plotted against another using |
---|
| 594 | the *Grid Window*. Simply select one column at the time and click the *Add* |
---|
| 595 | button next to the required *X/Y-axis Selection Range* text box. When both |
---|
| 596 | the X and Y axis boxes have been completed, click the *Plot* button. |
---|
[ec392464] | 597 | |
---|
[6af2785] | 598 | When the *Add* button is clicked, *SasView* also automatically completes the |
---|
| 599 | *X/Y-axis Label* text box with the heading from Row 1 of the selected table, |
---|
| 600 | but different labels and units can be entered manually. |
---|
[ec392464] | 601 | |
---|
| 602 | .. image:: plot_button.bmp |
---|
| 603 | |
---|
[6af2785] | 604 | The *X/Y-axis Selection Range* can be edited manually. The text control box |
---|
| 605 | recognises the operators +, -, \*, /, or 'pow', and allows the following |
---|
| 606 | types of expression : |
---|
| 607 | |
---|
| 608 | 1) if an axis label range is a function of 1 or more *columns*, write |
---|
| 609 | this type of expression |
---|
[ec392464] | 610 | |
---|
[6af2785] | 611 | constant1 * column_name1 [minimum row index : maximum row index] |
---|
| 612 | operator constant2 * column_name2 [minimum row index : maximum row index] |
---|
[ec392464] | 613 | |
---|
[6af2785] | 614 | Example: radius [2 : 5] -3 * scale [2 : 5] |
---|
[ec392464] | 615 | |
---|
[6af2785] | 616 | 2) if only some *values* of a given column are needed but the range between |
---|
| 617 | the first row and the last row used is not continuous, write this type of |
---|
| 618 | expression |
---|
[ec392464] | 619 | |
---|
[6af2785] | 620 | column_name1 [minimum row index1 : maximum row index1] , column_name1 |
---|
| 621 | [minimum row index2 : maximum row index2] |
---|
[ec392464] | 622 | |
---|
[6af2785] | 623 | Example: radius [2 : 5] , radius [10 : 25] |
---|
[ec392464] | 624 | |
---|
| 625 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
[6af2785] | 626 | |
---|
[3e1c9e5] | 627 | .. note:: This help document was last changed by Steve King, 10Oct2016 |
---|