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