[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 | |
---|
[b64b87c] | 6 | Fitting |
---|
| 7 | ======= |
---|
[ec392464] | 8 | |
---|
[3e1c9e5] | 9 | .. note:: If some code blocks are not readable, expand the documentation window |
---|
| 10 | |
---|
[a6f3613] | 11 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 12 | |
---|
| 13 | Preparing to fit data |
---|
| 14 | --------------------- |
---|
| 15 | |
---|
| 16 | To fit some data you must first load some data, activate one or more data sets, |
---|
[b64b87c] | 17 | send those data sets to fitting, and select a model to fit to each data set. |
---|
[a6f3613] | 18 | |
---|
[f3377b8] | 19 | Instructions on how to load and activate data are in the section :ref:`Loading_data`. |
---|
[ec392464] | 20 | |
---|
[a6f3613] | 21 | SasView can fit data in one of three ways: |
---|
[ec392464] | 22 | |
---|
[a6f3613] | 23 | * in *Single* fit mode - individual data sets are fitted independently one-by-one |
---|
[ec392464] | 24 | |
---|
[5295cf5] | 25 | * in *Simultaneous* fit mode - multiple data sets are fitted simultaneously to |
---|
| 26 | the *same* model with/without constrained parameters (this might be useful, |
---|
| 27 | for example, if you have measured the same sample at different contrasts) |
---|
[ec392464] | 28 | |
---|
[5005ae0] | 29 | * in *Batch* fit mode - multiple data sets are fitted sequentially to the |
---|
| 30 | *same* model (this might be useful, for example, if you have performed |
---|
| 31 | a kinetic or time-resolved experiment and have *lots* of data sets!) |
---|
[a6f3613] | 32 | |
---|
| 33 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
[ec392464] | 34 | |
---|
[a6f3613] | 35 | Selecting a model |
---|
| 36 | ----------------- |
---|
[ec392464] | 37 | |
---|
[5295cf5] | 38 | The models in SasView are grouped into categories. By default these consist of: |
---|
[ec392464] | 39 | |
---|
[5295cf5] | 40 | * *Cylinder* - cylindrical shapes (disc, right cylinder, cylinder with endcaps |
---|
| 41 | etc) |
---|
| 42 | * *Ellipsoid* - ellipsoidal shapes (oblate,prolate, core shell, etc) |
---|
| 43 | * *Parellelepiped* - as the name implies |
---|
[dbc1f73] | 44 | * *Sphere* - spheroidal shapes (sphere, core multishell, vesicle, etc) |
---|
[5295cf5] | 45 | * *Lamellae* - lamellar shapes (lamellar, core shell lamellar, stacked |
---|
| 46 | lamellar, etc) |
---|
[5005ae0] | 47 | * *Shape-Independent* - models describing structure in terms of density |
---|
| 48 | correlation functions, fractals, peaks, power laws, etc |
---|
[5295cf5] | 49 | * *Paracrystal* - semi ordered structures (bcc, fcc, etc) |
---|
[a6f3613] | 50 | * *Structure Factor* - S(Q) models |
---|
[5295cf5] | 51 | * *Plugin Models* - User-created (custom/non-library) Python 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 | |
---|
[6d7b252b] | 63 | Product Models |
---|
| 64 | ^^^^^^^^^^^^^^ |
---|
| 65 | |
---|
[fa307dd] | 66 | S(Q) models can be combined with many models in the other categories to |
---|
| 67 | generate what SasView calls "product models". The combination can be done by |
---|
| 68 | one of two methods, but how they behave is slightly different. |
---|
| 69 | |
---|
| 70 | The first, most straightforward, method is simply to use the S(Q) drop-down in |
---|
| 71 | the FitPage: |
---|
| 72 | |
---|
[6d7b252b] | 73 | .. figure:: p_and_s_buttons.png |
---|
| 74 | |
---|
[fa307dd] | 75 | This example would then generate a product model with the following parameters: |
---|
| 76 | |
---|
| 77 | .. figure:: p_and_s_buttons_parameters.png |
---|
| 78 | |
---|
| 79 | The other method is to use the :ref:`Sum|Multi(p1,p2)` tool under Fitting > |
---|
| 80 | Plugin Model Operations: |
---|
| 81 | |
---|
| 82 | .. figure:: p_and_s_sum_model.png |
---|
| 83 | |
---|
| 84 | This creates a product model with the following parameters: |
---|
| 85 | |
---|
| 86 | .. figure:: p_and_s_sum_model_parameters.png |
---|
| 87 | |
---|
| 88 | As can be seen, the second method has produced a product model with an extra |
---|
| 89 | parameter: *radius_effective*. This is the radial distance determining the |
---|
| 90 | range of the $S(Q)$ interaction and may, or may not, be the same as the |
---|
| 91 | *radius*, in this example, depending on the concentration of the system. In |
---|
| 92 | other systems, *radius_effective* may depend on the particle form (shape). |
---|
| 93 | |
---|
| 94 | See :ref:`Product_Models` for more information. |
---|
[dbc1f73] | 95 | |
---|
[a6f3613] | 96 | Show 1D/2D |
---|
| 97 | ^^^^^^^^^^ |
---|
| 98 | |
---|
| 99 | Models are normally fitted to 1D (ie, I(Q) vs Q) data sets, but some models in |
---|
| 100 | SasView can also be fitted to 2D (ie, I(Qx,Qy) vs Qx vs Qy) data sets. |
---|
| 101 | |
---|
| 102 | *NB: Magnetic scattering can only be fitted in SasView in 2D.* |
---|
| 103 | |
---|
| 104 | To activate 2D fitting mode, click the *Show 2D* button on the *Fit Page*. To |
---|
| 105 | return to 1D fitting model, click the same button (which will now say *Show 1D*). |
---|
[ce62e75] | 106 | |
---|
[ec392464] | 107 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 108 | |
---|
[a6f3613] | 109 | .. _Category_Manager: |
---|
[a0637de] | 110 | |
---|
[a6f3613] | 111 | Category Manager |
---|
| 112 | ---------------- |
---|
| 113 | |
---|
[f3377b8] | 114 | To change the model categorizations, either choose *Category Manager* from the |
---|
| 115 | *View* option on the menubar, or click on the *Modify* button on the *Fit Page*. |
---|
[a6f3613] | 116 | |
---|
[6aad2e8] | 117 | .. image:: cat_fig0.png |
---|
[a6f3613] | 118 | |
---|
[5295cf5] | 119 | The categorization of all models except the user supplied Plugin Models can be |
---|
| 120 | reassigned, added to, and removed using *Category Manager*. Models can also be |
---|
| 121 | hidden from view in the drop-down menus. |
---|
[a6f3613] | 122 | |
---|
[6aad2e8] | 123 | .. image:: cat_fig1.png |
---|
[a6f3613] | 124 | |
---|
[f3377b8] | 125 | Changing category |
---|
| 126 | ^^^^^^^^^^^^^^^^^ |
---|
[a6f3613] | 127 | |
---|
[5295cf5] | 128 | To change category, highlight a model in the list by left-clicking on its entry |
---|
| 129 | and then click the *Modify* button. Use the *Change Category* panel that appears |
---|
| 130 | to make the required changes. |
---|
[a6f3613] | 131 | |
---|
[6aad2e8] | 132 | .. image:: cat_fig2.png |
---|
[a6f3613] | 133 | |
---|
[f3377b8] | 134 | To create a category for the selected model, click the *Add* button. In order |
---|
| 135 | to delete a category, select the category name and click the *Remove Selected* |
---|
| 136 | button. Then click *Done*. |
---|
[a6f3613] | 137 | |
---|
[f3377b8] | 138 | Showing/hiding models |
---|
| 139 | ^^^^^^^^^^^^^^^^^^^^^ |
---|
[a6f3613] | 140 | |
---|
[5295cf5] | 141 | Use the *Enable All / Disable All* buttons and the check boxes beside each model |
---|
| 142 | to select the models to show/hide. To apply the selection, click *Ok*. Otherwise |
---|
| 143 | click *Cancel*. |
---|
[a6f3613] | 144 | |
---|
[8570246] | 145 | *NB: It may be necessary to change to a different category and then back again* |
---|
[f3377b8] | 146 | *before any changes take effect.* |
---|
[a6f3613] | 147 | |
---|
| 148 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 149 | |
---|
[f3377b8] | 150 | Model Functions |
---|
| 151 | --------------- |
---|
[a6f3613] | 152 | |
---|
[5295cf5] | 153 | For a complete list of all the library models available in SasView, see |
---|
[dbc1f73] | 154 | the `Model Documentation <../../../sasgui/perspectives/fitting/models/index.html>`_ . |
---|
[a6f3613] | 155 | |
---|
[f3377b8] | 156 | It is also possible to add your own models. |
---|
[a6f3613] | 157 | |
---|
[f3377b8] | 158 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
[a6f3613] | 159 | |
---|
[b5846a10] | 160 | .. _Adding_your_own_models: |
---|
| 161 | |
---|
[3e1c9e5] | 162 | Adding your own Models |
---|
[f3377b8] | 163 | ---------------------- |
---|
[a6f3613] | 164 | |
---|
[3e1c9e5] | 165 | There are essentially three ways to generate new fitting models for SasView: |
---|
| 166 | |
---|
[5295cf5] | 167 | * Using the SasView :ref:`New_Plugin_Model` helper dialog (best for beginners |
---|
| 168 | and/or relatively simple models) |
---|
| 169 | * By copying/editing an existing model (this can include models generated by |
---|
[5005ae0] | 170 | the New Plugin Model* dialog) in the :ref:`Python_shell` or |
---|
[5295cf5] | 171 | :ref:`Advanced_Plugin_Editor` (suitable for all use cases) |
---|
| 172 | * By writing a model from scratch outside of SasView (only recommended for code |
---|
| 173 | monkeys!) |
---|
[3e1c9e5] | 174 | |
---|
| 175 | Please read the guidance on :ref:`Writing_a_Plugin` before proceeding. |
---|
[f3377b8] | 176 | |
---|
[3e1c9e5] | 177 | **To be found by SasView your model must reside in the *~\\.sasview\\plugin_models* folder.** |
---|
[f3377b8] | 178 | |
---|
[a6f3613] | 179 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 180 | |
---|
[3e1c9e5] | 181 | .. _Plugin_Model_Operations: |
---|
[f3377b8] | 182 | |
---|
[3e1c9e5] | 183 | Plugin Model Operations |
---|
| 184 | ----------------------- |
---|
[a6f3613] | 185 | |
---|
[3e1c9e5] | 186 | From the *Fitting* option in the menu bar, select *Plugin Model Operations* |
---|
[a6f3613] | 187 | |
---|
[82b0b05e] | 188 | .. image:: edit_model_menu.png |
---|
[a6f3613] | 189 | |
---|
[3e1c9e5] | 190 | and then one of the sub-options |
---|
[f3377b8] | 191 | |
---|
[3e1c9e5] | 192 | * *New Plugin Model* - to create a plugin model template with a helper dialog |
---|
| 193 | * *Sum|Multi(p1,p2)* - to create a plugin model by summing/multiplying *existing models* in the model library |
---|
| 194 | * *Advanced Plugin Editor* - to create/edit a plugin model in a Python shell |
---|
| 195 | * *Delete Plugin Models* - to delete a plugin model |
---|
| 196 | * *Load Plugin Models* - to (re-)load plugin models |
---|
[a6f3613] | 197 | |
---|
[3e1c9e5] | 198 | .. _New_Plugin_Model: |
---|
| 199 | |
---|
| 200 | New Plugin Model |
---|
| 201 | ^^^^^^^^^^^^^^^^ |
---|
[a6f3613] | 202 | |
---|
[5295cf5] | 203 | Relatively straightforward models can be programmed directly from the SasView |
---|
| 204 | GUI using the *New Plugin Model Function*. |
---|
[26c8be3] | 205 | |
---|
[6aad2e8] | 206 | .. image:: new_model.png |
---|
[a6f3613] | 207 | |
---|
[5005ae0] | 208 | When using this feature, be aware that even if your code has errors, including |
---|
| 209 | syntax errors, a model file is still generated. When you then correct the errors |
---|
| 210 | and click 'Apply' again to re-compile you will get an error informing you that |
---|
| 211 | the model already exists if the 'Overwrite' box is not checked. In this case you |
---|
| 212 | will need to supply a new model function name. By default the 'Overwrite' box is |
---|
[26c8be3] | 213 | *checked*\ . |
---|
[f3377b8] | 214 | |
---|
[26c8be3] | 215 | A model file generated by this option can be viewed and further modified using |
---|
| 216 | the :ref:`Advanced_Plugin_Editor` . |
---|
[05829fb] | 217 | |
---|
[8b89396] | 218 | Note that the New Plugin Model Feature currently does not allow for parameters |
---|
| 219 | to be polydisperse. However they can be edited in the Advanced Editor. |
---|
| 220 | |
---|
| 221 | |
---|
| 222 | **SasView version 4.2** made it possible to specify whether a plugin created |
---|
| 223 | with the *New Plugin Model* dialog is actually a form factor P(Q) or a structure |
---|
| 224 | factor S(Q). To do this, simply add one or other of the following lines under |
---|
| 225 | the *import* statements. |
---|
[f485ba0] | 226 | |
---|
| 227 | For a form factor:: |
---|
| 228 | |
---|
| 229 | form_factor = True |
---|
[5005ae0] | 230 | |
---|
[f485ba0] | 231 | or for a structure factor:: |
---|
| 232 | |
---|
| 233 | structure_factor = True |
---|
[5005ae0] | 234 | |
---|
[8b89396] | 235 | If the plugin is a structure factor it is *also* necessary to add two variables |
---|
| 236 | to the parameter list:: |
---|
[f485ba0] | 237 | |
---|
[5005ae0] | 238 | parameters = [ |
---|
[ca383a0] | 239 | ['radius_effective', '', 1, [0.0, numpy.inf], 'volume', ''], |
---|
| 240 | ['volfraction', '', 1, [0.0, 1.0], '', ''], |
---|
[e081946] | 241 | [...], |
---|
[f485ba0] | 242 | |
---|
| 243 | and to the declarations of the functions Iq and Iqxy::: |
---|
| 244 | |
---|
| 245 | def Iq(x , radius_effective, volfraction, ...): |
---|
| 246 | |
---|
| 247 | def Iqxy(x, y, radius_effective, volfraction, ...): |
---|
| 248 | |
---|
[5005ae0] | 249 | Such a plugin should then be available in the S(Q) drop-down box on a FitPage (once |
---|
[f485ba0] | 250 | a P(Q) model has been selected). |
---|
| 251 | |
---|
[fa307dd] | 252 | .. _Sum|Multi(p1,p2): |
---|
| 253 | |
---|
[a6f3613] | 254 | Sum|Multi(p1,p2) |
---|
| 255 | ^^^^^^^^^^^^^^^^ |
---|
| 256 | |
---|
[6aad2e8] | 257 | .. image:: sum_model.png |
---|
[a0637de] | 258 | |
---|
[5295cf5] | 259 | This option creates a custom Plugin Model of the form:: |
---|
[f3377b8] | 260 | |
---|
[5295cf5] | 261 | Plugin Model = scale_factor * {(scale_1 * model_1) +/- (scale_2 * model_2)} + background |
---|
[f3377b8] | 262 | |
---|
[3e1c9e5] | 263 | or:: |
---|
| 264 | |
---|
[f485ba0] | 265 | Plugin Model = scale_factor * (model1 * model2) + background |
---|
[3e1c9e5] | 266 | |
---|
| 267 | In the *Easy Sum/Multi Editor* give the new model a function name and brief |
---|
| 268 | description (to appear under the *Details* button on the *FitPage*). Then select |
---|
[f3377b8] | 269 | two existing models, as p1 and p2, and the required operator, '+' or '*' between |
---|
[f485ba0] | 270 | them. Finally, click the *Apply* button to generate and test the model and then click *Close*. |
---|
[f3377b8] | 271 | |
---|
[5005ae0] | 272 | Any changes to a plugin model generated in this way only become effective *after* it is re-selected |
---|
| 273 | from the plugin models drop-down menu on the FitPage. If the model is not listed you can force a |
---|
[f485ba0] | 274 | recompilation of the plugins by selecting *Fitting* > *Plugin Model Operations* > *Load Plugin Models*. |
---|
| 275 | |
---|
[5005ae0] | 276 | **SasView version 4.2** introduced a much simplified and more extensible structure for plugin models |
---|
| 277 | generated through the Easy Sum/Multi Editor. For example, the code for a combination of a sphere model |
---|
[f485ba0] | 278 | with a power law model now looks like this:: |
---|
| 279 | |
---|
| 280 | from sasmodels.core import load_model_info |
---|
| 281 | from sasmodels.sasview_model import make_model_from_info |
---|
[5005ae0] | 282 | |
---|
[f485ba0] | 283 | model_info = load_model_info('sphere+power_law') |
---|
[e081946] | 284 | model_info.name = 'MyPluginModel' |
---|
[f485ba0] | 285 | model_info.description = 'sphere + power_law' |
---|
| 286 | Model = make_model_from_info(model_info) |
---|
| 287 | |
---|
[5005ae0] | 288 | To change the models or operators contributing to this plugin it is only necessary to edit the string |
---|
| 289 | in the brackets after *load_model_info*, though it would also be a good idea to update the model name |
---|
[f485ba0] | 290 | and description too!!! |
---|
| 291 | |
---|
[5005ae0] | 292 | The model specification string can handle multiple models and combinations of operators (+ or *) which |
---|
| 293 | are processed according to normal conventions. Thus 'model1+model2*model3' would be valid and would |
---|
| 294 | multiply model2 by model3 before adding model1. In this example, parameters in the *FitPage* would be |
---|
| 295 | prefixed A (for model2), B (for model3) and C (for model1). Whilst this might appear a little |
---|
| 296 | confusing, unless you were creating a plugin model from multiple instances of the same model the parameter |
---|
[e081946] | 297 | assignments ought to be obvious when you load the plugin. |
---|
[f485ba0] | 298 | |
---|
[5005ae0] | 299 | If you need to include another plugin model in the model specification string, just prefix the name of |
---|
[e081946] | 300 | that model with *custom*. For instance:: |
---|
| 301 | |
---|
| 302 | sphere+custom.MyPluginModel |
---|
| 303 | |
---|
| 304 | To create a P(Q)*\S(Q) model use the @ symbol instead of * like this:: |
---|
| 305 | |
---|
| 306 | sphere@hardsphere |
---|
[5005ae0] | 307 | |
---|
| 308 | This streamlined approach to building complex plugin models from existing library models, or models |
---|
| 309 | available on the *Model Marketplace*, also permits the creation of P(Q)*\S(Q) plugin models, something |
---|
| 310 | that was not possible in earlier versions of SasView. |
---|
[f3377b8] | 311 | |
---|
[3e1c9e5] | 312 | .. _Advanced_Plugin_Editor: |
---|
[f3377b8] | 313 | |
---|
[3e1c9e5] | 314 | Advanced Plugin Editor |
---|
| 315 | ^^^^^^^^^^^^^^^^^^^^^^ |
---|
[ec392464] | 316 | |
---|
[3e1c9e5] | 317 | Selecting this option shows all the plugin models in the plugin model folder, on Windows this is |
---|
[f3377b8] | 318 | |
---|
[afb93df] | 319 | *C:\\Users\\{username}\\.sasview\\plugin_models* |
---|
[f3377b8] | 320 | |
---|
| 321 | You can edit, modify, and save the Python code in any of these models using the |
---|
[3e1c9e5] | 322 | *Advanced Plugin Model Editor*. Note that this is actually the same tool as the :ref:`Python_shell` . |
---|
[f3377b8] | 323 | |
---|
[afb93df] | 324 | For details of the SasView plugin model format see :ref:`Writing_a_Plugin` . |
---|
[05829fb] | 325 | |
---|
[afb93df] | 326 | .. 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] | 327 | |
---|
[3e1c9e5] | 328 | 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] | 329 | |
---|
[3e1c9e5] | 330 | .. image:: ../calculator/new_pycrust_example_2.png |
---|
| 331 | |
---|
| 332 | To use the model, go to the relevant *Fit Page*, select the *Plugin Models* |
---|
[f3377b8] | 333 | category and then select the model from the drop-down menu. |
---|
| 334 | |
---|
[3e1c9e5] | 335 | 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] | 336 | |
---|
[3e1c9e5] | 337 | Delete Plugin Models |
---|
| 338 | ^^^^^^^^^^^^^^^^^^^^ |
---|
[a6f3613] | 339 | |
---|
[3e1c9e5] | 340 | Simply highlight the plugin model to be removed. The operation is final!!! |
---|
[f3377b8] | 341 | |
---|
[5295cf5] | 342 | *NB: Models shipped with SasView cannot be removed in this way.* |
---|
[ec392464] | 343 | |
---|
[3e1c9e5] | 344 | Load Plugin Models |
---|
| 345 | ^^^^^^^^^^^^^^^^^^ |
---|
[afb93df] | 346 | |
---|
[5295cf5] | 347 | This option loads (or re-loads) all models present in the |
---|
| 348 | *~\\.sasview\\plugin_models* folder. |
---|
[afb93df] | 349 | |
---|
[ec392464] | 350 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 351 | |
---|
[4666660] | 352 | .. _Fitting_Options: |
---|
| 353 | |
---|
[f3377b8] | 354 | Fitting Options |
---|
| 355 | --------------- |
---|
[a6f3613] | 356 | |
---|
[f3377b8] | 357 | It is possible to specify which optimiser SasView should use to fit the data, and |
---|
| 358 | to modify some of the configurational parameters for each optimiser. |
---|
| 359 | |
---|
| 360 | From *Fitting* in the menu bar select *Fit Options*, then select one of the following |
---|
| 361 | optimisers: |
---|
[a6f3613] | 362 | |
---|
[f3377b8] | 363 | * DREAM |
---|
| 364 | * Levenberg-Marquardt |
---|
| 365 | * Quasi-Newton BFGS |
---|
| 366 | * Differential Evolution |
---|
| 367 | * Nelder-Mead Simplex |
---|
[a6f3613] | 368 | |
---|
[6af2785] | 369 | The DREAM optimiser is the most sophisticated, but may not necessarily be the best |
---|
| 370 | option for fitting simple models. If uncertain, try the Levenberg-Marquardt optimiser |
---|
| 371 | initially. |
---|
| 372 | |
---|
[f3377b8] | 373 | These optimisers form the *Bumps* package written by P Kienzle. For more information |
---|
[4666660] | 374 | on each optimiser, see the :ref:`Fitting_Documentation`. |
---|
[a6f3613] | 375 | |
---|
[f3377b8] | 376 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
[a6f3613] | 377 | |
---|
[b7ce5ad] | 378 | Fitting Integer Parameters |
---|
| 379 | -------------------------- |
---|
| 380 | |
---|
| 381 | Most of the parameters in SasView models will naturally take floating point (decimal) |
---|
| 382 | values, but there are some parameters which can only have integer values. Examples |
---|
| 383 | include, but are not limited to, the number of shells in a multilayer vesicle, the |
---|
| 384 | number of beads in a pearl necklace, the number of arms of a star polymer, and so on. |
---|
| 385 | Wherever possible/recognised, the integer nature of a parameter is specified in the |
---|
| 386 | respective model documentation and/or parameter table, so read the documentation |
---|
| 387 | carefully! |
---|
| 388 | |
---|
| 389 | Integer parameters must be fitted with care. |
---|
| 390 | |
---|
| 391 | Start with your best possible guess for the value of the parameter. And using |
---|
| 392 | *a priori* knowledge, fix as many of the other parameters as possible. |
---|
| 393 | |
---|
| 394 | The SasView optimizers treat integer parameters internally as floating point |
---|
| 395 | numbers, but the values presented to the user are truncated or rounded, as |
---|
| 396 | appropriate. |
---|
| 397 | |
---|
| 398 | In most instances integer parameters will probably be greater than zero. A good |
---|
| 399 | policy in such cases is to use a constraint to enforce this. |
---|
| 400 | |
---|
| 401 | Because an integer parameter should, by definition, only move in integer steps, |
---|
| 402 | problems may be encountered if the optimizer step size is too small. Similarly, |
---|
| 403 | be **very careful** about applying polydispersity to integer parameters. |
---|
| 404 | |
---|
| 405 | The Levenberg-Marquardt and Quasi-Newton BFGS (and other derivative-based) |
---|
| 406 | optimizers are probably best avoided for fitting models with integer parameters. |
---|
| 407 | |
---|
| 408 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 409 | |
---|
[5ac0a7a] | 410 | Fitting Limits |
---|
| 411 | -------------- |
---|
| 412 | |
---|
| 413 | By default, *SasView* will attempt to model fit the full range of the data; ie, |
---|
| 414 | across all *Q* values. If necessary, however, it is possible to specify only a |
---|
| 415 | sub-region of the data for fitting. |
---|
| 416 | |
---|
| 417 | In a *FitPage* or *BatchPage* change the *Q* values in the *Min* and/or *Max* |
---|
| 418 | text boxes. Vertical coloured bars will appear on the graph with the data and |
---|
| 419 | 'theory' indicating the current *Q* limits (red = *Qmin*, purple = *Qmax*). |
---|
| 420 | |
---|
| 421 | To return to including all data in the fit, click the *Reset* button. |
---|
| 422 | |
---|
| 423 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 424 | |
---|
| 425 | |
---|
[f3377b8] | 426 | Shortcuts |
---|
| 427 | --------- |
---|
[a6f3613] | 428 | |
---|
[f3377b8] | 429 | Copy/Paste Parameters |
---|
| 430 | ^^^^^^^^^^^^^^^^^^^^^ |
---|
[a6f3613] | 431 | |
---|
[f3377b8] | 432 | It is possible to copy the parameters from one *Fit Page* and to paste them into |
---|
| 433 | another *Fit Page* using the same model. |
---|
[a6f3613] | 434 | |
---|
[f3377b8] | 435 | To *copy* parameters, either: |
---|
[a6f3613] | 436 | |
---|
[f3377b8] | 437 | * Select *Edit -> Copy Params* from the menu bar, or |
---|
| 438 | * Use Ctrl(Cmd on Mac) + Left Mouse Click on the *Fit Page*. |
---|
[a6f3613] | 439 | |
---|
[f3377b8] | 440 | To *paste* parameters, either: |
---|
| 441 | |
---|
| 442 | * Select *Edit -> Paste Params* from the menu bar, or |
---|
| 443 | * Use Ctrl(Cmd on Mac) + Shift + Left-click on the *Fit Page*. |
---|
| 444 | |
---|
| 445 | If either operation is successful a message will appear in the info line at the |
---|
| 446 | bottom of the SasView window. |
---|
| 447 | |
---|
| 448 | Bookmark |
---|
| 449 | ^^^^^^^^ |
---|
[a6f3613] | 450 | |
---|
[1fda506] | 451 | To *Bookmark* a *Fit Page* either: |
---|
[a6f3613] | 452 | |
---|
[f3377b8] | 453 | * Select a *Fit Page* and then click on *Bookmark* in the tool bar, or |
---|
| 454 | * Right-click and select the *Bookmark* in the popup menu. |
---|
[a6f3613] | 455 | |
---|
| 456 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 457 | |
---|
[4666660] | 458 | .. _Status_bar: |
---|
| 459 | |
---|
[1fda506] | 460 | Status Bar & Console |
---|
| 461 | -------------------- |
---|
| 462 | |
---|
| 463 | The status bar is located at the bottom of the SasView window and displays |
---|
| 464 | messages, hints, warnings and errors. |
---|
| 465 | |
---|
| 466 | At the right-hand side of the status bar is a button marked *Console*. The *Console* |
---|
| 467 | displays available message history and some run-time traceback information. |
---|
| 468 | |
---|
| 469 | During a long task the *Console* can also be used to monitor the progress. |
---|
| 470 | |
---|
| 471 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 472 | |
---|
[6af2785] | 473 | .. _Single_Fit_Mode: |
---|
| 474 | |
---|
[a6f3613] | 475 | Single Fit Mode |
---|
| 476 | --------------- |
---|
[ec392464] | 477 | |
---|
[4666660] | 478 | *NB: Before proceeding, ensure that the Single Mode radio button at the bottom of* |
---|
| 479 | *the Data Explorer is checked (see the section* :ref:`Loading_data` *).* |
---|
| 480 | |
---|
[63d314b] | 481 | This mode fits one data set. |
---|
| 482 | |
---|
[b64b87c] | 483 | When data is sent to the fitting it is plotted in a graph window as markers. |
---|
[4666660] | 484 | |
---|
| 485 | If a graph does not appear, or a graph window appears but is empty, then the data |
---|
| 486 | has not loaded correctly. Check to see if there is a message in the :ref:`Status_Bar` |
---|
| 487 | or in the *Console* window. |
---|
| 488 | |
---|
| 489 | Assuming the data has loaded correctly, when a model is selected a green model |
---|
| 490 | calculation (or what SasView calls a 'Theory') line will appear in the earlier graph |
---|
| 491 | window, and a second graph window will appear displaying the residuals (the |
---|
| 492 | difference between the experimental data and the theory) at the same X-data values. |
---|
[f9250dc] | 493 | See :ref:`Assessing_Fit_Quality`. |
---|
[4666660] | 494 | |
---|
[a7c6f38] | 495 | The objective of model-fitting is to find a *physically-plausible* model, and |
---|
| 496 | set of model parameters, that generate a theory that reproduces the experimental |
---|
| 497 | data and minimizes the values of the residuals. |
---|
[4666660] | 498 | |
---|
| 499 | Change the default values of the model parameters by hand until the theory line |
---|
[a7c6f38] | 500 | starts to represent the experimental data. Then check the tick boxes alongside |
---|
[84ac3f1] | 501 | the 'background' and 'scale' parameters. Click the *Fit* button. SasView |
---|
[a7c6f38] | 502 | will optimise the values of the 'background' and 'scale' and also display the |
---|
| 503 | corresponding uncertainties on the optimised values. |
---|
[4666660] | 504 | |
---|
[a7c6f38] | 505 | .. note:: |
---|
[84ac3f1] | 506 | If the uncertainty on a fitted parameter is unrealistically large, or if it |
---|
| 507 | displays as NaN, the model is most likely a poor representation of the data, |
---|
| 508 | the parameter in question is highly correlated with one or more of the other |
---|
| 509 | fitted parameters, or the model is relatively insensitive to the value of |
---|
| 510 | that particular parameter. |
---|
[4666660] | 511 | |
---|
[47ace50] | 512 | In the bottom left corner of the *Fit Page* is a box displaying a normalised |
---|
| 513 | value of the statistical $\chi^2$ parameter (the reduced $\chi^2$, |
---|
| 514 | See :ref:`Assessing_Fit_Quality`) returned by the optimiser. |
---|
[4666660] | 515 | |
---|
| 516 | Now check the box for another model parameter and click *Fit* again. Repeat this |
---|
[84ac3f1] | 517 | process until all relevant parameters are checked and have been optimised. As |
---|
| 518 | the fit of the theory to the experimental data improves, the value of 'Reduced |
---|
| 519 | Chi2' will decrease. A good model fit should produce values of Reduced Chi2 |
---|
| 520 | close to one, and certainly << 100. See :ref:`Assessing_Fit_Quality`. |
---|
[4666660] | 521 | |
---|
| 522 | SasView has a number of different optimisers (see the section :ref:`Fitting_Options`). |
---|
| 523 | The DREAM optimiser is the most sophisticated, but may not necessarily be the best |
---|
| 524 | option for fitting simple models. If uncertain, try the Levenberg-Marquardt optimiser |
---|
| 525 | initially. |
---|
[ec392464] | 526 | |
---|
| 527 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 528 | |
---|
[a6f3613] | 529 | Simultaneous Fit Mode |
---|
| 530 | --------------------- |
---|
[ec392464] | 531 | |
---|
[63d314b] | 532 | *NB: Before proceeding, ensure that the Single Mode radio button at the bottom of* |
---|
| 533 | *the Data Explorer is checked (see the section* :ref:`Loading_data` *).* |
---|
[ec392464] | 534 | |
---|
[84ac3f1] | 535 | This mode is an extension of the :ref:`Single_Fit_Mode` that allows for some |
---|
| 536 | relatively extensive constraints between fitted parameters in a single *FitPage* |
---|
| 537 | or between several *FitPage*'s (eg, to constrain all fitted parameters to be the |
---|
| 538 | same in a contrast series of *FitPages* except for the solvent sld parameter, |
---|
[47ace50] | 539 | constrain the length to be twice that of the radius in a single *FitPage*, |
---|
[84ac3f1] | 540 | fix the radius of the sphere in one *FitPage* to be the same as the radius of |
---|
| 541 | the cylinder in a second *FitPage*, etc). |
---|
[63d314b] | 542 | |
---|
[b5846a10] | 543 | If the data to be fit are in multiple files, load each file, then select each file |
---|
| 544 | in the *Data Explorer*, and *Send To Fitting*. If multiple data sets are in one file, |
---|
| 545 | load that file, *Unselect All Data*, select just those data sets to be fitted, and |
---|
| 546 | *Send To Fitting*. Either way, the result should be that for *n* data sets you have |
---|
[6af2785] | 547 | 2\ *n* graphs (*n* of the data and model fit, and *n* of the resulting residuals). But |
---|
[f9250dc] | 548 | it may be helpful to minimise the residuals plots for clarity. Also see |
---|
| 549 | :ref:`Assessing_Fit_Quality`. |
---|
[b5846a10] | 550 | |
---|
[5295cf5] | 551 | *NB: If you need to use a custom Plugin Model, you must ensure that model is |
---|
| 552 | available first (see* :ref:`Adding_your_own_models` *).* |
---|
[b5846a10] | 553 | |
---|
[6af2785] | 554 | Method |
---|
| 555 | ^^^^^^ |
---|
| 556 | |
---|
[b5846a10] | 557 | Now go to each *FitPage* in turn and: |
---|
| 558 | |
---|
| 559 | Select the required category and model; |
---|
| 560 | |
---|
| 561 | Unselect all the model parameters; |
---|
| 562 | |
---|
| 563 | Enter some starting guesses for the parameters; |
---|
| 564 | |
---|
| 565 | Enter any parameter limits (recommended); |
---|
[63d314b] | 566 | |
---|
[b5846a10] | 567 | Select which parameters will refine (selecting all is generally a bad idea...); |
---|
[63d314b] | 568 | |
---|
[b5846a10] | 569 | When done, select *Constrained or Simultaneous Fit* under *Fitting* in the menu bar. |
---|
| 570 | |
---|
| 571 | In the *Const & Simul Fit* page that appears, select which data sets are to be |
---|
| 572 | simultaneously fitted (this will probably be all of them or you would not have loaded |
---|
| 573 | them in the first place!). |
---|
| 574 | |
---|
| 575 | To tie parameters between the data sets with constraints, check the 'yes' radio button |
---|
| 576 | next to *Add Constraint?* in the *Fit Constraints* box. |
---|
| 577 | |
---|
[84ac3f1] | 578 | To constrain all identically named parameters to fit *simultaneously* to the |
---|
| 579 | same value across all the *Fitpages* use the *Easy Setup* drop-down buttons in |
---|
| 580 | the *Const & Simul Fit* page. |
---|
[ec392464] | 581 | |
---|
[84ac3f1] | 582 | *NB: You can only constrain parameters that are set to refine.* |
---|
[b5846a10] | 583 | |
---|
[6af2785] | 584 | Constraints will generally be of the form |
---|
| 585 | |
---|
| 586 | Mi Parameter1 = Mj.Parameter1 |
---|
| 587 | |
---|
| 588 | however the text box after the '=' sign can be used to adjust this |
---|
| 589 | relationship; for example |
---|
| 590 | |
---|
| 591 | Mi Parameter1 = scalar \* Mj.Parameter1 |
---|
| 592 | |
---|
| 593 | A 'free-form' constraint box is also provided. |
---|
[b5846a10] | 594 | |
---|
| 595 | Many constraints can be entered for a single fit. |
---|
| 596 | |
---|
[84ac3f1] | 597 | When ready, click the *Fit* button on the *Const & Simul Fit* page, NOT the *Fit* |
---|
| 598 | button on the individual *FitPage*'s. |
---|
| 599 | |
---|
[b5846a10] | 600 | The results of the model-fitting will be returned to each of the individual |
---|
| 601 | *FitPage*'s. |
---|
[ec392464] | 602 | |
---|
[a7c6f38] | 603 | Note that the Reduced Chi2 value returned is the SUM of the Reduced Chi2 of |
---|
| 604 | each fit. To see the Reduced Chi2 value for a specific *FitPage*, click the |
---|
| 605 | *Compute* button at the bottom of that *FitPage* to recalculate. Note that in |
---|
[84ac3f1] | 606 | doing so the degrees of freedom will be set to Npts. |
---|
[a7c6f38] | 607 | See :ref:`Assessing_Fit_Quality`. Moreover in the case of constraints the |
---|
[84ac3f1] | 608 | degrees of freedom are less than one might think due to those constraints. |
---|
| 609 | |
---|
[ec392464] | 610 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 611 | |
---|
[e6c74e8] | 612 | .. _Batch_Fit_Mode: |
---|
| 613 | |
---|
[a6f3613] | 614 | Batch Fit Mode |
---|
| 615 | -------------- |
---|
[ec392464] | 616 | |
---|
[6af2785] | 617 | *NB: Before proceeding, ensure that the Single Mode radio button at the bottom of* |
---|
| 618 | *the Data Explorer is checked (see the section* :ref:`Loading_data` *). The Batch* |
---|
| 619 | *Mode button will be used later on!* |
---|
[63d314b] | 620 | |
---|
[6af2785] | 621 | This mode *sequentially* fits two or more data sets *to the same model*. Unlike in |
---|
| 622 | simultaneous fitting, in batch fitting it is not possible to constrain fit parameters |
---|
| 623 | between data sets. |
---|
[ec392464] | 624 | |
---|
[6af2785] | 625 | If the data to be fit are in multiple files, load each file in the *Data Explorer*. |
---|
| 626 | If multiple data sets are in one file, load just that file. *Unselect All Data*, then |
---|
| 627 | select a single initial data set to be fitted. Fit that selected data set as described |
---|
[5295cf5] | 628 | above under :ref:`Single_Fit_Mode`. |
---|
[ec392464] | 629 | |
---|
[5295cf5] | 630 | *NB: If you need to use a custom Plugin Model, you must ensure that model is |
---|
| 631 | available first (see* :ref:`Adding_your_own_models` *).* |
---|
[ec392464] | 632 | |
---|
[6af2785] | 633 | Method |
---|
| 634 | ^^^^^^ |
---|
[ec392464] | 635 | |
---|
[6af2785] | 636 | Now *Select All Data* in the *Data Explorer*, check the *Batch Mode* radio button |
---|
| 637 | at the bottom of that panel and *Send To Fitting*. A *BatchPage* will be created. |
---|
[ec392464] | 638 | |
---|
[6aad2e8] | 639 | .. image:: batch_button_area.png |
---|
[ec392464] | 640 | |
---|
[6af2785] | 641 | *NB: The Batch Page can also be created by checking the Batch Mode radio button* |
---|
| 642 | *and selecting New Fit Page under Fitting in the menu bar.* |
---|
[ec392464] | 643 | |
---|
[6af2785] | 644 | Using the drop-down menus in the *BatchPage*, now set up the *same* data set |
---|
| 645 | with the *same* model that you just fitted in single fit mode. A quick way to |
---|
| 646 | set the model parameter values is to just copy them from the earlier Single |
---|
| 647 | Fit. To do this, go back to the Single Fit *FitPage*, select *Copy Params* |
---|
| 648 | under *Edit* in the menu bar, then go back to the *BatchPage* and *Paste Params*. |
---|
[ec392464] | 649 | |
---|
[6af2785] | 650 | When ready, use the *Fit* button on the *BatchPage* to perform the fitting, NOT |
---|
| 651 | the *Fit* button on the individual *FitPage*'s. |
---|
[ec392464] | 652 | |
---|
[6af2785] | 653 | Unlike in single fit mode, the results of batch fits are not returned to |
---|
| 654 | the *BatchPage*. Instead, a spreadsheet-like :ref:`Grid_Window` will appear. |
---|
[ec392464] | 655 | |
---|
[6af2785] | 656 | If you want to visually check a graph of a particular fit, click on the name of |
---|
| 657 | a *Data set* in the *Grid Window* and then click the *View Fits* button. The |
---|
| 658 | data and the model fit will be displayed. If you select mutliple data sets they |
---|
| 659 | will all appear on one graph. |
---|
[ec392464] | 660 | |
---|
[6aad2e8] | 661 | .. image:: view_button.png |
---|
[ec392464] | 662 | |
---|
[6af2785] | 663 | *NB: In theory, returning to the BatchPage and changing the name of the I(Q)* |
---|
| 664 | *data source should also work, but at the moment whilst this does change the* |
---|
| 665 | *data set displayed it always superimposes the 'theory' corresponding to the* |
---|
| 666 | *starting parameters.* |
---|
[ec392464] | 667 | |
---|
[6af2785] | 668 | If you select a 'Chi2' value and click the *View Fits* button a graph of the |
---|
| 669 | residuals for that data set is displayed. Again, if you select multiple 'Chi2' |
---|
[f9250dc] | 670 | values then all the residuals data will appear on one graph. Also see |
---|
| 671 | :ref:`Assessing_Fit_Quality`. |
---|
[ec392464] | 672 | |
---|
[6af2785] | 673 | Chain Fitting |
---|
| 674 | ^^^^^^^^^^^^^ |
---|
[ec392464] | 675 | |
---|
[6af2785] | 676 | By default, the *same* parameter values copied from the initial single fit into |
---|
| 677 | the *BatchPage* will be used as the starting parameters for all batch fits. It |
---|
| 678 | is, however, possible to get *SasView* to use the results of a fit to a preceding |
---|
| 679 | data set as the starting parameters for the next fit in the sequence. This |
---|
| 680 | variation of batch fitting is called *Chain Fitting*, and will considerably speed |
---|
| 681 | up model-fitting if you have lots of very similar data sets where a few parameters |
---|
| 682 | are gradually changing. Do not use chain fitting on disparate data sets. |
---|
[ec392464] | 683 | |
---|
[6af2785] | 684 | To use chain fitting, select *Chain Fitting* under *Fitting* in the menu bar. It |
---|
| 685 | toggles on/off, so selecting it again will switch back to normal batch fitting. |
---|
[ec392464] | 686 | |
---|
[6af2785] | 687 | .. _Grid_Window: |
---|
[ec392464] | 688 | |
---|
[6af2785] | 689 | Grid Window |
---|
| 690 | ^^^^^^^^^^^ |
---|
[ec392464] | 691 | |
---|
[6af2785] | 692 | The *Grid Window* provides an easy way to view the results from batch fitting. |
---|
| 693 | It will be displayed automatically when a batch fit completes, but may be |
---|
| 694 | opened at any time by selecting *Show Grid Window* under *View* in the menu |
---|
| 695 | bar. |
---|
[ec392464] | 696 | |
---|
[6aad2e8] | 697 | .. image:: restore_batch_window.png |
---|
[ec392464] | 698 | |
---|
[6af2785] | 699 | Once a batch fit is completed, all model parameters are displayed but *not* |
---|
| 700 | their uncertainties. To view the uncertainties, click on a given column then |
---|
| 701 | go to *Edit* in the menu bar, select *Insert Column Before* and choose the |
---|
| 702 | required data from the list. An empty column can be inserted in the same way. |
---|
[ec392464] | 703 | |
---|
[6af2785] | 704 | To remove a column from the grid, click on the column header and choose |
---|
| 705 | *Remove Column* under *Edit* in the menu bar. The same functionality also |
---|
| 706 | allows you to re-order columns. |
---|
[ec392464] | 707 | |
---|
[6af2785] | 708 | *NB: You cannot insert/remove/re-order the rows in the Grid Window.* |
---|
[ec392464] | 709 | |
---|
[6af2785] | 710 | All of the above functions are also available by right-clicking on a column |
---|
| 711 | label. |
---|
[ec392464] | 712 | |
---|
[6aad2e8] | 713 | .. image:: edit_menu.png |
---|
[ec392464] | 714 | |
---|
[6af2785] | 715 | *NB: If there is an existing Grid Window and another batch fit is performed,* |
---|
| 716 | *an additional 'Table' tab will be added to the Grid Window.* |
---|
[ec392464] | 717 | |
---|
[6af2785] | 718 | The parameter values in the *currently selected* table of the *Grid Window* |
---|
| 719 | can be output to a CSV file by choosing *Save As* under *File* in the (*Grid* |
---|
| 720 | *Window*) menu bar. The default filename includes the date and time that the |
---|
| 721 | batch fit was performed. |
---|
[ec392464] | 722 | |
---|
[6af2785] | 723 | Saved CSV files can be reloaded by choosing *Open* under *File* in the *Grid* |
---|
| 724 | *Window* menu bar. The loaded parameters will appear in a new table tab. |
---|
[ec392464] | 725 | |
---|
[6aad2e8] | 726 | .. image:: file_menu.png |
---|
[ec392464] | 727 | |
---|
[6af2785] | 728 | *NB: Saving the Grid Window does not save any experimental data, residuals* |
---|
| 729 | *or actual model fits. Consequently if you reload a saved CSV file the* |
---|
| 730 | *ability to View Fits will be lost.* |
---|
[ec392464] | 731 | |
---|
[6af2785] | 732 | Parameter Plots |
---|
| 733 | ^^^^^^^^^^^^^^^ |
---|
[ec392464] | 734 | |
---|
[6af2785] | 735 | Any column of *numeric* parameter values can be plotted against another using |
---|
| 736 | the *Grid Window*. Simply select one column at the time and click the *Add* |
---|
| 737 | button next to the required *X/Y-axis Selection Range* text box. When both |
---|
| 738 | the X and Y axis boxes have been completed, click the *Plot* button. |
---|
[ec392464] | 739 | |
---|
[6af2785] | 740 | When the *Add* button is clicked, *SasView* also automatically completes the |
---|
| 741 | *X/Y-axis Label* text box with the heading from Row 1 of the selected table, |
---|
| 742 | but different labels and units can be entered manually. |
---|
[ec392464] | 743 | |
---|
[6aad2e8] | 744 | .. image:: plot_button.png |
---|
[ec392464] | 745 | |
---|
[6af2785] | 746 | The *X/Y-axis Selection Range* can be edited manually. The text control box |
---|
| 747 | recognises the operators +, -, \*, /, or 'pow', and allows the following |
---|
| 748 | types of expression : |
---|
[5005ae0] | 749 | |
---|
[6af2785] | 750 | 1) if an axis label range is a function of 1 or more *columns*, write |
---|
| 751 | this type of expression |
---|
[ec392464] | 752 | |
---|
[6af2785] | 753 | constant1 * column_name1 [minimum row index : maximum row index] |
---|
| 754 | operator constant2 * column_name2 [minimum row index : maximum row index] |
---|
[ec392464] | 755 | |
---|
[6af2785] | 756 | Example: radius [2 : 5] -3 * scale [2 : 5] |
---|
[ec392464] | 757 | |
---|
[6af2785] | 758 | 2) if only some *values* of a given column are needed but the range between |
---|
| 759 | the first row and the last row used is not continuous, write this type of |
---|
| 760 | expression |
---|
[ec392464] | 761 | |
---|
[6af2785] | 762 | column_name1 [minimum row index1 : maximum row index1] , column_name1 |
---|
| 763 | [minimum row index2 : maximum row index2] |
---|
[ec392464] | 764 | |
---|
[6af2785] | 765 | Example: radius [2 : 5] , radius [10 : 25] |
---|
[5005ae0] | 766 | |
---|
[9d93c37] | 767 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
| 768 | |
---|
| 769 | Combined Batch Fit Mode |
---|
| 770 | ----------------------- |
---|
| 771 | |
---|
[e6c74e8] | 772 | The purpose of the Combined Batch Fit is to allow running two or more batch |
---|
| 773 | fits in sequence without overwriting the output table of results. This may be |
---|
| 774 | of interest for example if one is fitting a series of data sets where there is |
---|
| 775 | a shape change occurring in the series that requires changing the model part |
---|
| 776 | way through the series; for example a sphere to rod transition. Indeed the |
---|
| 777 | regular batch mode does not allow for multiple models and requires all the |
---|
| 778 | files in the series to be fit with single model and set of parameters. While |
---|
| 779 | it is of course possible to just run part of the series as a batch fit using |
---|
| 780 | model one followed by running another batch fit on the rest of the series with |
---|
| 781 | model two (and/or model three etc), doing so will overwrite the table of |
---|
| 782 | outputs from the previous batch fit(s). This may not be desirable if one is |
---|
| 783 | interested in comparing the parameters: for example the sphere radius of set |
---|
[05b0bf6] | 784 | one and the cylinder radius of set two. |
---|
[e6c74e8] | 785 | |
---|
| 786 | Method |
---|
| 787 | ^^^^^^ |
---|
[9d93c37] | 788 | |
---|
[e6c74e8] | 789 | In order to use the *Combined Batch Fit*, first load all the data needed as |
---|
| 790 | described in :ref:`Loading_data`. Next start up two or more *BatchPage* fits |
---|
| 791 | following the instructions in :ref:`Batch_Fit_Mode` but **DO NOT PRESS FIT**. |
---|
| 792 | At this point the *Combine Batch Fit* menu item under the *Fitting menu* should |
---|
| 793 | be active (if there is one or no *BatchPage* the menu item will be greyed out |
---|
| 794 | and inactive). Clicking on *Combine Batch Fit* will bring up a new panel, |
---|
| 795 | similar to the *Const & Simult Fit* panel. In this case there will be a |
---|
| 796 | checkbox for each *BatchPage* instead of each *FitPage* that should be included |
---|
| 797 | in the fit. Once all are selected, click the Fit button on |
---|
| 798 | the *BatchPage* to run each batch fit in *sequence* |
---|
[9d93c37] | 799 | |
---|
| 800 | .. image:: combine_batch_page.png |
---|
| 801 | |
---|
[e6c74e8] | 802 | The batch table will then pop up at the end as for the case of the simple Batch |
---|
| 803 | Fitting with the following caveats: |
---|
[9d93c37] | 804 | |
---|
| 805 | .. note:: |
---|
| 806 | The order matters. The parameters in the table will be taken from the model |
---|
[e6c74e8] | 807 | used in the first *BatchPage* of the list. Any parameters from the |
---|
| 808 | second and later *BatchPage* s that have the same name as a parameter in the |
---|
| 809 | first will show up allowing for plotting of that parameter across the |
---|
| 810 | models. The other parameters will not be available in the grid. |
---|
[9d93c37] | 811 | .. note:: |
---|
| 812 | a corralary of the above is that currently models created as a sum|multiply |
---|
| 813 | model will not work as desired because the generated model parameters have a |
---|
| 814 | p#_ appended to the beginning and thus radius and p1_radius will not be |
---|
| 815 | recognized as the same parameter. |
---|
[5005ae0] | 816 | |
---|
[9d93c37] | 817 | .. image:: combine_batch_grid.png |
---|
| 818 | |
---|
[e6c74e8] | 819 | In the example shown above the data is a time series with a shifting peak. |
---|
| 820 | The first part of the series was fitted using the *broad_peak* model, while |
---|
| 821 | the rest of the data were fit using the *gaussian_peak* model. Unfortunately the |
---|
| 822 | time is not listed in the file but the file name contains the information. As |
---|
| 823 | described in :ref:`Grid_Window`, a column can be added manually, in this case |
---|
[5005ae0] | 824 | called time, and the peak position plotted against time. |
---|
[9d93c37] | 825 | |
---|
| 826 | .. image:: combine_batch_plot.png |
---|
| 827 | |
---|
[05b0bf6] | 828 | Note the discontinuity in the peak position. This reflects the fact that the |
---|
| 829 | Gaussian fit is a rather poor model for the data and is not actually |
---|
[e6c74e8] | 830 | finding the peak. |
---|
[ec392464] | 831 | |
---|
| 832 | .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ |
---|
[6af2785] | 833 | |
---|
[84ac3f1] | 834 | .*Document History* |
---|
| 835 | |
---|
| 836 | | 2017-09-10 Paul Butler |
---|
| 837 | | 2017-09-15 Steve King |
---|
| 838 | | 2018-03-05 Paul Butler |
---|