Changeset cd5e29b in sasview for src/sas/perspectives/fitting/media
- Timestamp:
- Sep 1, 2015 9:20:05 AM (9 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- f0d720b
- Parents:
- 40c5104 (diff), 600bea1 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Location:
- src/sas/perspectives/fitting/media
- Files:
-
- 5 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/perspectives/fitting/media/fitting_help.rst
r98b30b4 rff42a26 26 26 =================== 27 27 28 Load_a_File_ 29 30 Single_Fit_ 31 32 Simultaneous_Fitting_ 33 34 Batch_Fitting_ 35 36 Model_Selection_ 37 38 Model_Category_Manager_ 39 40 Model_Functions_ 41 42 Custom_Model_Editor_ 43 44 Polydispersity_Distributions_ 45 46 Smearing_Computation_ 47 48 Polarisation_Magnetic_Scattering_ 49 50 Key_Combinations_ 51 52 Status_Bar_Help_ 53 54 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 55 56 .. _Load_a_File: 57 58 Load a File 59 ----------- 60 61 From Menu go to *Data* -> *Load Data File(or Folder)* . Select a file/folder 62 from the menu bar and click on Open button. Data contained in the file will be 63 displayed. To cancel the loading click on *cancel* . In case a file can not be 64 loaded, an error message will be displayed on the statusbar. 65 66 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 67 68 .. _Single_Fit: 69 70 Single Fit 71 ---------- 72 73 One of two fit-engines can be chosen from the Fitting menu bar. The Simple Fit- 74 engine uses Scipy's leasqr and the Complex Fit-Engine is a custom optimizer 75 that provides a better chance to find the global minimum of the |chi| 2 but that 76 requires longer computation time. In order to set a data to a control panel 77 (FitPage), see the "DataLoader Help". Once a data set to the FiPage, select a 78 model from the combo box. The default parameters of the model will be display. 79 Set initial parameters if need. Check and uncheck parameters to fit/fix. Click 80 the *'Fit'* button. When the fitting is finished, the resultant parameter 81 values will be displayed with the errors. If a error is missing, it generally 82 means that the corresponding parameter is not very depending on the model. The 83 chisq/Npt_fit and the plot associated with the fit operation will be also 84 updated. 85 86 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 87 88 .. _Simultaneous_Fitting: 89 90 Simultaneous Fitting 91 -------------------- 92 93 This fitting option enables to set a number of the constraints between the 94 parameters of fitting(s). It requires one or more FitPages with a data and a 95 model set for the fitting, and performs multiple fittings given by the 96 FitPage(s). The Complex (ParkMC) FitEngine will be used automatically. 97 98 Simultaneous Fit without Constraint 99 100 Assuming some FitPages are already set up, check the checkboxes of the 101 model_data rows to fit. And click the 'Fit' button. The results will return to 102 each FitPages. 103 104 Note that the chi2/Npts returned is the sum of the chi2/Npts of each fits. If 105 one needs the chi2 value only for a page, click the 'Compute' button in the 106 FitPage to recalculate. 107 108 Simultaneous Fit with Constraint 109 110 Enter constraint in the text control next to *constraint fit* button. 111 Constraint should be of type model1 parameter name = f(model2 parameter name) 112 for example, M0.radius=2*M1.radius. Many constraints can be entered for a 113 single fit. Each of them should be separated by a newline charater or ";" 114 The easy setup can generate many constraint inputs easily when the selected 115 two models are the same type. 116 117 Note that the chi2/Npts returned is the sum of the chi2/Npts of each fits. 118 If one needs the chi2 value only for one fit, click the 'Compute' button in 119 the FitPage to recalculate. 120 121 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 122 123 .. _Batch_Fitting: 124 125 Batch Fitting 126 ------------- 127 128 Batch_Fit_ 129 130 Batch_Window_ 131 132 Edit_Grid_ 133 134 Save_Grid_ 135 136 Open_Batch_Results_ 137 138 Plot_ 139 140 View_Column_Cell_ 141 142 .. _Batch_Fit: 143 144 Batch Fit 145 --------- 146 147 Create a *Batch Page* by selecting the *Batch* radio button on the DataExplorer 148 (see figure below) and for a new control page select 'New FitPage' in the 149 Fitting menubar. 150 151 .. image:: batch_button_area.bmp 152 153 Figure 1: MenuBar: 154 155 Load Data to the DataExplorer if not already loaded. 156 157 Select one or more data sets by checking the check boxes, and then make sure 158 that "Fitting" is selected in the dropdown menu next to the "Send To" button. 159 Once ready, click the 'Send To' button to set data to a BatchPage. If already 160 an empty batch page exists, it will be set there. Otherwise it will create a 161 new Batch Page. Set up the model and the parameter values as same as a single 162 fitting (see Single Fit help) <Single_Fit_>. Then use 'Fit' button to 163 perform the fitting. 164 165 Unlike a single fit, the results of the fittings will not return to the 166 BatchPage'. Instead, a Grid window will be provided once the fitting is 167 completed. The Grid window is also accessible from the 'View' menu 168 (see Figure 2). 169 170 Note that only one model is used for all the data. The initial parameter 171 values given in the control page will be used all the data fittings. If one 172 wants the FitEngine to use the initial values from the results of the 173 previous data fitting (if any), choose the 'Chain Fitting' option in the 174 Fitting menubar, which will speed up the fitting especially when you have 175 lots of, and similar, data sets. 176 177 .. _Batch_Window: 178 179 Batch Window 180 ------------ 181 Batch Window provides an easy way to view the fit results, i.e., plot data, 182 fits, and residuals. Batch window will be automatically shown after a batch 183 fit is finished. 184 185 Once closed, it can be opened anytime from the "View" menubar item (see 186 Figure 2). 187 188 .. image:: restore_batch_window.bmp 189 190 Figure 2: Edit Menu: 191 192 .. _Edit_Grid: 193 194 Edit Grid 195 --------- 196 197 Once a batch fit is completed, all fitted and fixed model parameters are 198 displayed to the current sheet of the batch window except the errors of the 199 parameters. To view the errors, click on a given column then under *Edit* 200 menubar item, and insert the desired parameter by selecting a menu item with 201 the appropriated label. Empty column can be inserted in the same way. A 202 column value can be customized by editing an existing empty column. 203 204 To Remove column from the grid, select it, choose edit menu, and click the 205 *'remove'* menu item. Any removed column should reinserted whenever needed. 206 207 All above options are also available when right clicking on a given column 208 label(see Figure 3). 209 210 *Note:* A column always needs to be selected in order to remove or insert a 211 column in the grid. 212 213 .. image:: edit_menu.bmp 214 215 Figure 3: Edit Menu: 216 217 .. _Save_Grid: 218 219 Save Grid 220 --------- 221 To save the current page on the batch window, select the *'File'* menubar 222 item(see Figure 4), then choose the *'Save as'* menu item to save it as a 223 .csv file. 224 225 *Note:* The grid doesn't save the data array, fits, and the array residuals. 226 As a result, the 'View (fit) Results' functionality will be lost when 227 reloading the saved file. 228 229 Warning! To ensure accuracy of saved fit results, it is recommended to save 230 the current grid before modifying it . 231 232 .. _Open_Batch_Results: 233 234 Open Batch Results 235 ------------------ 236 237 Any *csv* file can be opened in the grid by selecting the *'Open'* under 238 the *'File'* menu in the Grid Window(see Figure 4). All columns in the file 239 will be displayed but insertion will not available. Insertion will be 240 available only when at least one column will be removed from the grid. 241 242 .. image:: file_menu.bmp 243 244 Figure 4: MenuBar: 245 246 .. _Plot: 247 248 Plot 249 ---- 250 251 To *plot* a column versus another, select one column at the time, click the 252 *'Add'* button next to the text control of X/Y -axis *Selection Range* to 253 plot the value of this column on the X/Y axis. Alternatively, all available 254 range can be selected by clicking the column letter (eg. B). Repeat the same 255 procedure the next axis. Finally, click the *'Plot'* button. When clicking 256 on *Add* button, the grid will automatically fill the axis label, but 257 different labels and units can be entered in the correct controls before 258 clicking on the plot button. 259 260 *X/Y -Axis Selection Range* can be edited manually. These text controls 261 allow the following types of expression (operation can be + - * /, or pow) 262 263 1) if the current axis label range is a function of 1 or more columns, write 264 this type of expression 265 266 constant1 * column_name1 [minimum row index : maximum row index] operator 267 constant2 * column_name2 [minimum row index : maximum row index] 268 269 Example: radius [2 : 5] -3 * scale [2 : 5] 270 271 2) if only some values of a given column are need but the range between the 272 first row and the last row used is not continuous, write the following 273 expression in the text control 274 275 column_name1 [minimum row index1 : maximum row index1] , column_name1 276 [minimum row index2 : maximum row index2] 277 278 Example : radius [2 : 5] , radius [10 : 25] 279 280 Note: Both text controls ( X and Y-axis Selection Ranges) need to be filled 281 with valid entries for plotting to work. The dY-bar is optional (see Figure 5). 282 283 .. image:: plot_button.bmp 284 285 Figure 5: Plotting 286 287 .. _View_Column_Cell: 288 289 View Column/Cell(s) 290 ------------------- 291 292 Select 1 or more cells from the same column, click the 'View Fits' button to 293 display available curves. 294 295 For example, select the cells of the 'Chi2' column, then click the 'View Fits' 296 button. The plots generates will represent the residuals plots. 297 298 If you select any cells of the 'Data' column and click the 'View Fits' button. 299 It generates both data and fits in the graph (see Figure 6). 300 301 Alternatively, just click the column letter (eg. B) to choose all the 302 available data sets, then simply click the 'View Fits' button to plot the 303 data and fits. 304 305 .. image:: view_button.bmp 306 307 Figure 6: View Fits 308 309 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 310 311 .. _Model_Selection: 312 313 Model_Type_ 314 315 Change_Model_Parameters_ 316 317 Write_your_Own_Model_ 318 319 .. _Model_Type: 320 321 Model Type 322 ---------- 323 324 Models are grouped into three classes 325 326 * *Shapes* 327 * *Shape-Independent* 328 * *Uncategorised* 329 * *Customized Models* 330 * *Structure Factor* 331 332 .. _Change_Model_Parameters: 333 334 Change Model Parameters 335 ----------------------- 336 337 To visualize model in a different window, from menu click on *Model*. Select 338 a type of model and then the name of your model.A new window will appear with 339 the plot of your model with default values. Change model's parameters on 340 *model view* tab and view the plotted model with its new parameters. 341 342 .. _Write_your_Own_Model: 343 344 Write your Own Model 345 -------------------- 346 347 The custom model editors are provided from 'Fitting' menu in the menu bar. 348 See 'Custom model editor' in the side menu on left. Advanced users can write 349 your own model and save it (in .py format) into *plugin_models* directory in 350 .sasview of your home directory (eg., username\.sasview>\plugin_models). Your 351 plugin model will be added into "<>Customized Models" on the next model 352 selection. 353 354 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 355 356 .. _Model_Category_Manager: 357 358 Model Category Manager 359 ---------------------- 360 361 Our SAS models are, by default, classified into 5 categories; shapes, 362 shape-independent, structure factor, and customized models, where these 363 categories (except the customized models) can be reassigned, added, and 364 removed using 'Category Manager'. Each models can also be enabled(shown)/ 365 disabled(hidden) from the category that they belong. The Category Manager 366 panel is accessible from the model category 'Modify' button in the fitting 367 panel or the 'View/Category Manager' menu in the menu bar (Fig. 1). 368 369 1) Enable/Disable models: Check/uncheck the check boxes to enable/disable the 370 models (Fig. 2). 371 372 2) Change category: Highlight a model in the list by left-clicking and click 373 the 'Modify' button. In the 'Change Category' panel, one can create/use a 374 category for the model, then click the 'Add' button. In order to delete a 375 category, select a category name and click the 'Remove Selected' button 376 (Fig. 3). 377 378 3) To apply the changes made, hit the OK button. Otherwise, click the 'Cancel' 379 button (Fig. 2). 28 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 29 30 Preparing to fit data 31 --------------------- 32 33 To fit some data you must first load some data, activate one or more data sets, 34 send those data sets to the fitting perspective, and select a model to fit to 35 each data set. 36 37 Instructions on how to load and activate data are in the section :ref:`Loading_data`. 38 39 SasView can fit data in one of three ways: 40 41 * in *Single* fit mode - individual data sets are fitted independently one-by-one 42 43 * in *Simultaneous* fit mode - multiple data sets are fitted simultaneously to the *same* model with/without constrained parameters (this might be useful, for example, if you have measured the same sample at different contrasts) 44 45 * in *Batch* fit mode - multiple data sets are fitted sequentially to the *same* model (this might be useful, for example, if you have performed a kinetic or time-resolved experiment and have *lots* of data sets!) 46 47 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 48 49 Selecting a model 50 ----------------- 51 52 By default, the models in SasView are grouped into five categories 53 54 * *Shapes* - models describing 'objects' (spheres, cylinders, etc) 55 * *Shape-Independent* - models describing structure in terms of density correlation functions, fractals, peaks, power laws, etc 56 * *Customized Models* - SasView- or User-created (non-library) Python models 57 * *Uncategorised* - other models (for reflectivity, etc) 58 * *Structure Factor* - S(Q) models 59 60 Use the *Category* drop-down menu to chose a category of model, then select 61 a model from the drop-down menu beneath. A graph of the chosen model, calculated 62 using default parameter values, will appear. The graph will update dynamically 63 as the parameter values are changed. 64 65 You can decide your own model categorizations using the :ref:`Category_Manager`. 66 67 Once you have selected a model you can read its help documentation by clicking 68 on the *Description* button to the right. 69 70 Show 1D/2D 71 ^^^^^^^^^^ 72 73 Models are normally fitted to 1D (ie, I(Q) vs Q) data sets, but some models in 74 SasView can also be fitted to 2D (ie, I(Qx,Qy) vs Qx vs Qy) data sets. 75 76 *NB: Magnetic scattering can only be fitted in SasView in 2D.* 77 78 To activate 2D fitting mode, click the *Show 2D* button on the *Fit Page*. To 79 return to 1D fitting model, click the same button (which will now say *Show 1D*). 80 81 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 82 83 .. _Category_Manager: 84 85 Category Manager 86 ---------------- 87 88 To change the model categorizations, either choose *Category Manager* from the 89 *View* option on the menubar, or click on the *Modify* button on the *Fit Page*. 380 90 381 91 .. image:: cat_fig0.bmp 382 92 383 Fig.1 93 The categorization of all models except the customized models can be reassigned, 94 added to, and removed using *Category Manager*. Models can also be hidden from view 95 in the drop-down menus. 384 96 385 97 .. image:: cat_fig1.bmp 386 98 387 Fig.2 99 Changing category 100 ^^^^^^^^^^^^^^^^^ 101 102 To change category, highlight a model in the list by left-clicking on its entry and 103 then click the *Modify* button. Use the *Change Category* panel that appears to make 104 the required changes. 388 105 389 106 .. image:: cat_fig2.bmp 390 107 391 Fig.3 392 393 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 394 395 .. _Model_Functions: 108 To create a category for the selected model, click the *Add* button. In order 109 to delete a category, select the category name and click the *Remove Selected* 110 button. Then click *Done*. 111 112 Showing/hiding models 113 ^^^^^^^^^^^^^^^^^^^^^ 114 115 Use the *Enable All / Disable All* buttons and the check boxes beside each model to 116 select the models to show/hide. To apply the selection, click *Ok*. Otherwise click 117 *Cancel*. 118 119 *NB: It may be necessary to change to a different category and then back again* 120 *before any changes take effect.* 121 122 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 396 123 397 124 Model Functions 398 125 --------------- 399 126 400 Model Documentation <models/model_functions> 401 402 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 403 404 .. _Custom_Model_Editor: 127 For a complete list of all the library models available in SasView, see the section 128 :ref:`SasView_model_functions`. 129 130 It is also possible to add your own models. 131 132 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 133 134 .. _Adding_your_own_models: 135 136 Adding your own models 137 ---------------------- 138 139 There are currently two ways to add your own models to SasView: 140 141 * Using the :ref:`Custom_Model_Editor` 142 * By :ref:`Writing_a_Plugin` 143 144 *NB: Because of the way these options are implemented, it is not possible for them* 145 *to use the polydispersity algorithms in SasView. Only models in the model library* 146 *can do this. At the time of writing (Release 3.1.0) work is in hand to make it* 147 *easier to add new models to the model library.* 148 149 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 150 151 .. _Custom_Model_Editor: 405 152 406 153 Custom Model Editor 407 154 ------------------- 408 155 409 Description_ 410 411 New_ 412 413 Sum_Multi_p1_p2_ 414 415 Advanced_ 416 417 Delete_ 418 419 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 420 421 .. _Description: 422 423 Description 424 ----------- 425 426 This menu (Fitting/Edit Custom Model in the menu bar) interface is to provide 427 you an easy way to write your own custom models. The changes in a model 428 function are effective after it is re-selected from the combo-box menu. 156 From the *Fitting* option in the menu bar, select *Edit Custom Model*. 429 157 430 158 .. image:: edit_model_menu.bmp 431 159 432 .. _New: 160 and then one of the options 161 162 * *New* - to create a new custom model template 163 * *Sum|Multi(p1,p2)* - to create a new model by summing/multiplying existing models in the model library 164 * *Advanced* - to edit a new custom model 165 * *Delete* - to delete a custom model 433 166 434 167 New 435 --- 436 437 This option is used to make a new model. A model code generated by this option 438 can be viewed and further modified by the 'Advanced' option below. 168 ^^^^ 439 169 440 170 .. image:: new_model.bmp 441 171 442 .. _Sum_Multi_p1_p2: 172 A model template generated by this option can be viewed and further modified using 173 the :ref:`Advanced` option. 443 174 444 175 Sum|Multi(p1,p2) 176 ^^^^^^^^^^^^^^^^ 177 178 .. image:: sum_model.bmp 179 180 This option creates a custom model of the form 181 182 Custom Model = scale_factor \* (model1 +/\* model2) 183 184 In the *Easy Sum/Multi Editor* give the new custom model a function name and brief 185 description (to appear under the *Details* button on the *Fit Page*). Then select 186 two existing models, as p1 and p2, and the required operator, '+' or '*' between 187 them. Finally, click the *Apply* button to generate the model and then click *Close*. 188 189 *NB: Any changes to a custom model generated in this way only become effective after* 190 *it is re-selected from the model drop-down menu on the Fit Page.* 191 192 .. _Advanced: 193 194 Advanced 195 ^^^^^^^^ 196 197 Selecting this option shows all the custom models in the plugin model folder 198 199 *C:\\Users\\[username]\\.sasview\\plugin_models* - (on Windows) 200 201 You can edit, modify, and save the Python code in any of these models using the 202 *Advanced Custom Model Editor*. 203 204 *NB: Unless you are confident about what you are doing, it is recommended that you* 205 *only modify lines denoted with the ## <----- comments!* 206 207 When editing is complete, select *Run -> Compile* from the *Model Editor* menu bar. An 208 *Info* box will appear with the results of the compilation and model unit tests. The 209 model will only be usable if the tests 'pass'. 210 211 To use the model, go to the relevant *Fit Page*, select the *Customized Models* 212 category and then select the model from the drop-down menu. 213 214 *NB: Any changes to a custom model generated in this way only become effective after* 215 *it is re-selected from the model drop-down menu on the Fit Page.* 216 217 Delete 218 ^^^^^^ 219 220 Simply highlight the custom model to be removed. This operation is final! 221 222 *NB: Custom models shipped with SasView cannot be removed in this way.* 223 224 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 225 226 .. _Writing_a_Plugin: 227 228 Writing a Plugin 445 229 ---------------- 446 230 447 This option create a new sum (or multiplication) model. Fill up the (sum 448 model function) name and the description. The description will show up on 449 details button in the application. Then select the p1 or p2 model for the 450 sum/multi model, select an operator as necessary and click the Apply button 451 for activation. Hit the 'Close' button when it's done. 452 453 .. image:: sum_model.bmp 454 455 .. _Advanced: 456 457 Advanced 458 -------- 459 460 The menu option shows all the files in the plugin_models folder. You can edit, 461 modify, and save it. It is recommended to modify only the lines with arrow 462 (-------). In the end of edit, 'Compile' and 'Run' from the menu bar to 463 activate or to see the model working properly. 464 465 .. _Delete: 466 467 Delete 468 ------ 469 470 The menu option is to delete the custom models. Just select the file name to 471 delete. 472 473 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 474 475 .. _Polydispersity_Distributions: 476 477 Polydispersity Distributions 478 ---------------------------- 479 480 Calculates the form factor for a polydisperse and/or angular population of 481 particles with uniform scattering length density. The resultant form factor 482 is normalized by the average particle volume such that 483 484 P(q) = scale*\<F*F\>/Vol + bkg 485 486 where F is the scattering amplitude and the\<\>denote an average over the size 487 distribution. Users should use PD (polydispersity: this definition is 488 different from the typical definition in polymer science) for a size 489 distribution and Sigma for an angular distribution (see below). 490 491 Note that this computation is very time intensive thus applying polydispersion/ 492 angular distrubtion for more than one paramters or increasing Npts values 493 might need extensive patience to complete the computation. Also note that 494 even though it is time consuming, it is safer to have larger values of Npts 495 and Nsigmas. 496 497 The following five distribution functions are provided 498 499 * *Rectangular_Distribution_* 500 * *Array_Distribution_* 501 * *Gaussian_Distribution_* 502 * *Lognormal_Distribution_* 503 * *Schulz_Distribution_* 504 505 .. _Rectangular_Distribution: 506 507 Rectangular Distribution 508 ------------------------ 509 510 .. image:: pd_image001.png 511 512 The xmean is the mean of the distribution, w is the half-width, and Norm is a 513 normalization factor which is determined during the numerical calculation. 514 Note that the Sigma and the half width *w* are different. 515 516 The standard deviation is 517 518 .. image:: pd_image002.png 519 520 The PD (polydispersity) is 521 522 .. image:: pd_image003.png 523 524 .. image:: pd_image004.jpg 525 526 .. _Array_Distribution: 527 528 Array Distribution 529 ------------------ 530 531 This distribution is to be given by users as a txt file where the array 532 should be defined by two columns in the order of x and f(x) values. The f(x) 533 will be normalized by SasView during the computation. 534 535 Example of an array in the file 536 537 30 0.1 538 32 0.3 539 35 0.4 540 36 0.5 541 37 0.6 542 39 0.7 543 41 0.9 544 545 We use only these array values in the computation, therefore the mean value 546 given in the control panel, for example ââ¬Ëradius = 60ââ¬â¢, will be ignored. 547 548 .. _Gaussian_Distribution: 549 550 Gaussian Distribution 231 Advanced users can write their own model in Python and save it to the the SasView 232 *plugin_models* folder 233 234 *C:\\Users\\[username]\\.sasview\\plugin_models* - (on Windows) 235 236 in .py format. The next time SasView is started it will compile the plugin and add 237 it to the list of *Customized Models*. 238 239 It is recommended that existing plugin models be used as templates. 240 241 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 242 243 .. _Fitting_Options: 244 245 Fitting Options 246 --------------- 247 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: 253 254 * DREAM 255 * Levenberg-Marquardt 256 * Quasi-Newton BFGS 257 * Differential Evolution 258 * Nelder-Mead Simplex 259 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 264 These optimisers form the *Bumps* package written by P Kienzle. For more information 265 on each optimiser, see the :ref:`Fitting_Documentation`. 266 267 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 268 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 285 Shortcuts 286 --------- 287 288 Copy/Paste Parameters 289 ^^^^^^^^^^^^^^^^^^^^^ 290 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. 293 294 To *copy* parameters, either: 295 296 * Select *Edit -> Copy Params* from the menu bar, or 297 * Use Ctrl(Cmd on Mac) + Left Mouse Click on the *Fit Page*. 298 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 ^^^^^^^^ 309 310 To *Bookmark* a *Fit Page* either: 311 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. 314 315 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 316 317 .. _Status_bar: 318 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 332 .. _Single_Fit_Mode: 333 334 Single Fit Mode 335 --------------- 336 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 340 This mode fits one data set. 341 342 When data is sent to the fitting perspective it is plotted in a graph window as 343 markers. 344 345 If a graph does not appear, or a graph window appears but is empty, then the data 346 has not loaded correctly. Check to see if there is a message in the :ref:`Status_Bar` 347 or in the *Console* window. 348 349 Assuming the data has loaded correctly, when a model is selected a green model 350 calculation (or what SasView calls a 'Theory') line will appear in the earlier graph 351 window, and a second graph window will appear displaying the residuals (the 352 difference between the experimental data and the theory) at the same X-data values. 353 See :ref:`Assessing_Fit_Quality`. 354 355 The objective of model-fitting is to find a *physically-plausible* model, and set 356 of model parameters, that generate a theory that reproduces the experimental data 357 and gives residual values as close to zero as possible. 358 359 Change the default values of the model parameters by hand until the theory line 360 starts to represent the experimental data. Then uncheck the tick boxes alongside 361 all parameters *except* the 'background' and the 'scale'. Click the *Fit* button. 362 SasView will optimise the values of the 'background' and 'scale' and also display 363 the corresponding uncertainties on the optimised values. 364 365 *NB: If no uncertainty is shown it generally means that the model is not very* 366 *dependent on the corresponding parameter (or that one or more parameters are* 367 *'correlated').* 368 369 In the bottom left corner of the *Fit Page* is a box displaying the normalised value 370 of the statistical |chi|\ :sup:`2` parameter returned by the optimiser. 371 372 Now check the box for another model parameter and click *Fit* again. Repeat this 373 process until most or all parameters are checked and have been optimised. As the 374 fit of the theory to the experimental data improves the value of 'chi2/Npts' will 375 decrease. A good model fit should easily produce values of 'chi2/Npts' that are 376 close to zero, and certainly <100. See :ref:`Assessing_Fit_Quality`. 377 378 SasView has a number of different optimisers (see the section :ref:`Fitting_Options`). 379 The DREAM optimiser is the most sophisticated, but may not necessarily be the best 380 option for fitting simple models. If uncertain, try the Levenberg-Marquardt optimiser 381 initially. 382 383 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 384 385 Simultaneous Fit Mode 551 386 --------------------- 552 387 553 .. image:: pd_image005.png 554 555 The xmean is the mean of the distribution and Norm is a normalization factor 556 which is determined during the numerical calculation. 557 558 The PD (polydispersity) is 559 560 .. image:: pd_image003.png 561 562 .. image:: pd_image006.jpg 563 564 .. _Lognormal_Distribution: 565 566 Lognormal Distribution 567 ---------------------- 568 569 .. image:: pd_image007.png 570 571 The /mu/=ln(xmed), xmed is the median value of the distribution, and Norm is a 572 normalization factor which will be determined during the numerical calculation. 573 The median value is the value given in the size parameter in the control panel, 574 for example, ââ¬Åradius = 60ââ¬ï¿œ. 575 576 The PD (polydispersity) is given by /sigma/ 577 578 .. image:: pd_image008.png 579 580 For the angular distribution 581 582 .. image:: pd_image009.png 583 584 The mean value is given by xmean=exp(/mu/+p2/2). The peak value is given by 585 xpeak=exp(/mu/-p2). 586 587 .. image:: pd_image010.jpg 588 589 This distribution function spreads more and the peak shifts to the left as the 590 p increases, requiring higher values of Nsigmas and Npts. 591 592 .. _Schulz_Distribution: 593 594 Schulz Distribution 595 ------------------- 596 597 .. image:: pd_image011.png 598 599 The xmean is the mean of the distribution and Norm is a normalization factor 600 which is determined during the numerical calculation. 601 602 The z = 1/p2ââ¬â 1. 603 604 The PD (polydispersity) is 605 606 .. image:: pd_image012.png 607 608 Note that the higher PD (polydispersity) might need higher values of Npts and 609 Nsigmas. For example, at PD = 0.7 and radisus = 60 A, Npts >= 160, and 610 Nsigmas >= 15 at least. 611 612 .. image:: pd_image013.jpg 613 614 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 615 616 .. _Smearing_Computation: 617 618 Smearing Computation 619 -------------------- 620 621 Slit_Smearing_ 622 623 Pinhole_Smearing_ 624 625 2D_Smearing_ 626 627 .. _Slit_Smearing: 628 629 Slit Smearing 630 ------------- 631 632 The sit smeared scattering intensity for SAS is defined by 633 634 .. image:: sm_image002.gif 635 636 where Norm = 637 638 .. image:: sm_image003.gif 639 640 Equation 1 641 642 The functions |inlineimage004| and |inlineimage005| 643 refer to the slit width weighting function and the slit height weighting 644 determined at the q point, respectively. Here, we assumes that the weighting 645 function is described by a rectangular function, i.e., 646 647 .. image:: sm_image006.gif 648 649 Equation 2 650 651 and 652 653 .. image:: sm_image007.gif 654 655 Equation 3 656 657 so that |inlineimage008| |inlineimage009| for |inlineimage010| and u. 658 659 The |inlineimage011| and |inlineimage012| stand for 660 the slit height (FWHM/2) and the slit width (FWHM/2) in the q space. Now the 661 integral of Equation 1 is simplified to 662 663 .. image:: sm_image013.gif 664 665 Equation 4 666 667 Numerical Implementation of Equation 4 668 -------------------------------------- 669 670 Case 1 671 ------ 672 673 For |inlineimage012| = 0 and |inlineimage011| = constant. 674 675 .. image:: sm_image016.gif 676 677 For discrete q values, at the q values from the data points and at the q 678 values extended up to qN= qi + |inlineimage011| the smeared 679 intensity can be calculated approximately 680 681 .. image:: sm_image017.gif 682 683 Equation 5 684 685 |inlineimage018| = 0 for *Is* in *j* < *i* or *j* > N-1*. 686 687 Case 2 688 ------ 689 690 For |inlineimage012| = constant and |inlineimage011| = 0. 691 692 Similarly to Case 1, we get 693 694 |inlineimage019| for qp= qi- |inlineimage012| and qN= qi+ |inlineimage012|. |inlineimage018| = 0 695 for *Is* in *j* < *p* or *j* > *N-1*. 696 697 Case 3 698 ------ 699 700 For |inlineimage011| = constant and 701 |inlineimage011| = constant. 702 703 In this case, the best way is to perform the integration, Equation 1, 704 numerically for both slit height and width. However, the numerical integration 705 is not correct enough unless given a large number of iteration, say at least 706 10000 by 10000 for each element of the matrix, W, which will take minutes and 707 minutes to finish the calculation for a set of typical SAS data. An 708 alternative way which is correct for slit width << slit hight, is used in 709 SasView. This method is a mixed method that combines method 1 with the 710 numerical integration for the slit width. 711 712 .. image:: sm_image020.gif 713 714 Equation 7 715 716 for qp= qi- |inlineimage012| and 717 qN= qi+ |inlineimage012|. |inlineimage018| = 0 for 718 *Is* in *j* < *p* or *j* > *N-1*. 719 720 .. _Pinhole_Smearing: 721 722 Pinhole Smearing 723 ---------------- 724 725 The pinhole smearing computation is done similar to the case above except 726 that the weight function used is the Gaussian function, so that the Equation 6 727 for this case becomes 728 729 .. image:: sm_image021.gif 730 731 Equation 8 732 733 For all the cases above, the weighting matrix *W* is calculated when the 734 smearing is called at the first time, and it includes the ~ 60 q values 735 (finely binned evenly) below (\>0) and above the q range of data in order 736 to cover all data points of the smearing computation for a given model and 737 for a given slit size. The *Norm* factor is found numerically with the 738 weighting matrix, and considered on *Is* computation. 739 740 .. _2D_Smearing: 741 742 2D Smearing 743 ----------- 744 745 The 2D smearing computation is done similar to the 1D pinhole smearing above 746 except that the weight function used was the 2D elliptical Gaussian function 747 748 .. image:: sm_image022.gif 749 750 Equation 9 751 752 In Equation 9, x0 = qcos/theta/ and y0 = qsin/theta/, and the primed axes 753 are in the coordinate rotated by an angle /theta/ around the z-axis (below) 754 so that xââ¬â¢0= x0cos/theta/+y0sin/theta/ and yââ¬â¢0= -x0sin/theta/+y0cos/theta/. 755 756 Note that the rotation angle is zero for x-y symmetric elliptical Gaussian 757 distribution. The A is a normalization factor. 758 759 .. image:: sm_image023.gif 760 761 Now we consider a numerical integration where each bins in /theta/ and R are 762 *evenly* (this is to simplify the equation below) distributed by /delta//theta/ 763 and /delta/R, respectively, and it is assumed that I(xââ¬â¢, yââ¬â¢) is constant 764 within the bins which in turn becomes 765 766 .. image:: sm_image024.gif 767 768 Equation 10 769 770 Since we have found the weighting factor on each bin points, it is convenient 771 to transform xââ¬â¢-yââ¬â¢ back to x-y coordinate (rotating it by -/theta/ around z 772 axis). Then, for the polar symmetric smear 773 774 .. image:: sm_image025.gif 775 776 Equation 11 777 778 where 779 780 .. image:: sm_image026.gif 781 782 while for the x-y symmetric smear 783 784 .. image:: sm_image027.gif 785 786 Equation 12 787 788 where 789 790 .. image:: sm_image028.gif 791 792 Here, the current version of the SasView uses Equation 11 for 2D smearing 793 assuming that all the Gaussian weighting functions are aligned in the polar 794 coordinate. 795 796 In the control panel, the higher accuracy indicates more and finer binnng 797 points so that it costs more in time. 798 799 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 800 801 .. _Polarisation_Magnetic_Scattering: 802 803 Polarisation/Magnetic Scattering 804 -------------------------------- 805 806 Magnetic scattering is implemented in five (2D) models 807 808 * *SphereModel* 809 * *CoreShellModel* 810 * *CoreMultiShellModel* 811 * *CylinderModel* 812 * *ParallelepipedModel* 813 814 In general, the scattering length density (SLD) in each regions where the 815 SLD (=/beta/) is uniform, is a combination of the nuclear and magnetic SLDs and 816 depends on the spin states of the neutrons as follows. For magnetic scattering, 817 only the magnetization component, *M*perp, perpendicular to the scattering 818 vector *Q* contributes to the the magnetic scattering length. 819 820 .. image:: mag_vector.bmp 821 822 The magnetic scattering length density is then 823 824 .. image:: dm_eq.gif 825 826 where /gamma/ = -1.913 the gyromagnetic ratio, /mu/B is the Bohr magneton, r0 827 is the classical radius of electron, and */sigma/* is the Pauli spin. For 828 polarised neutron, the magnetic scattering is depending on the spin states. 829 830 Let's consider that the incident neutrons are polarized parallel (+)/ 831 anti-parallel (-) to the x' axis (See both Figures above). The possible 832 out-coming states then are + and - states for both incident states 833 834 Non-spin flips: (+ +) and (- -) 835 Spin flips: (+ -) and (- +) 836 837 .. image:: M_angles_pic.bmp 838 839 Now, let's assume that the angles of the *Q* vector and the spin-axis (x') 840 against x-axis are /phi/ and /theta/up, respectively (See Figure above). Then, 841 depending upon the polarisation (spin) state of neutrons, the scattering length 842 densities, including the nuclear scattering length density (/beta/N) are given 843 as, for non-spin-flips 844 845 .. image:: sld1.gif 846 847 for spin-flips 848 849 .. image:: sld2.gif 850 851 where 852 853 .. image:: mxp.gif 854 855 .. image:: myp.gif 856 857 .. image:: mzp.gif 858 859 .. image:: mqx.gif 860 861 .. image:: mqy.gif 862 863 Here, the M0x, M0y and M0z are the x, y and z components of the magnetization 864 vector given in the xyz lab frame. The angles of the magnetization, /theta/M 865 and /phi/M as defined in the Figure (above) 866 867 .. image:: m0x_eq.gif 868 869 .. image:: m0y_eq.gif 870 871 .. image:: m0z_eq.gif 872 873 The user input parameters are M0_sld = DMM0, Up_theta = /theta/up, 874 M_theta = /theta/M, and M_phi = /phi/M. The 'Up_frac_i' and 'Up_frac_f' are 875 the ratio 876 877 (spin up)/(spin up + spin down) 878 879 neutrons before the sample and at the analyzer, respectively. 880 881 *Note:* The values of the 'Up_frac_i' and 'Up_frac_f' must be in the range 882 between 0 and 1. 883 884 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 885 886 .. _Key_Combinations: 887 888 Key Combinations 889 ---------------- 890 891 Copy_Paste_ 892 893 Bookmark_ 894 895 Graph_Context_Menu_ 896 897 FTolerance_ 898 899 .. _Copy_Paste: 900 901 Copy & Paste 902 ------------ 903 904 To copy the parameter values in a Fit(Model) panel to the clipboard: 905 906 *Ctrl(Cmd on MAC) + Left(Mouse)Click* on the panel. 907 908 To paste the parameter values to a Fit(Model)panel from the clipboard: 909 910 *Ctrl(Cmd on MAC) + Shift + Left(Mouse)Click* on the panel. 911 912 If this operation is successful, it will say so in the info line at the 913 bottom of the SasView window. 914 915 .. _Bookmark: 916 917 Bookmark 918 -------- 919 920 Bookmark of a fit-panel or model-panel status: 921 922 *(Mouse)Right-Click* and select the bookmark in the popup list. 923 924 .. _Graph_Context_Menu: 925 926 Graph Context Menu 927 ------------------ 928 929 To get the graph context menu to print, copy, save data, (2D)average, etc.: 930 931 *Locate the mouse point on the plot to highlight and *(Mouse) Right Click* 932 to bring up the full menu. 933 934 .. _FTolerance: 935 936 FTolerance (SciPy) 937 ------------------ 938 939 To change the ftol value of the Scipy FitEngine (leastsq): 940 941 First, make sure that the Fit panel has data and a model selected. 942 943 *Ctrl(Cmd on MAC) + Shift + Alt + Right(Mouse)Click* on the panel. 944 945 Then, set up the value in the dialog panel. 946 947 If this operation is successful, the new ftol value will be displayed in the 948 info line at the bottom of the SV window.Note that increasing the ftol value 949 may cause for the fitting to terminate with higher |chi| sq. 950 951 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 952 953 .. _Status_Bar_Help: 954 955 Status Bar Help 956 --------------- 957 958 Message_Warning_Hint_ 959 960 Console_ 961 962 .. _Message_Warning_Hint: 963 964 Message/Warning/Hint 965 -------------------- 966 967 The status bar located at the bottom of the application frame, displays 968 messages, hints, warnings and errors. 969 970 .. _Console: 971 972 Console 973 ------- 974 975 Select *light bulb/info icon* button in the status bar at the bottom of the 976 application window to display available history. During a long task, the 977 console can also help users to understand the status in progressing. 388 *NB: Before proceeding, ensure that the Single Mode radio button at the bottom of* 389 *the Data Explorer is checked (see the section* :ref:`Loading_data` *).* 390 391 This mode is an extension of the :ref:`Single_Fit_Mode` that fits two or more data 392 sets *to the same model* simultaneously. If necessary it is possible to constrain 393 fit parameters between data sets (eg, to fix a background level, or radius, etc). 394 395 If the data to be fit are in multiple files, load each file, then select each file 396 in the *Data Explorer*, and *Send To Fitting*. If multiple data sets are in one file, 397 load that file, *Unselect All Data*, select just those data sets to be fitted, and 398 *Send To Fitting*. Either way, the result should be that for *n* data sets you have 399 2\ *n* graphs (*n* of the data and model fit, and *n* of the resulting residuals). But 400 it may be helpful to minimise the residuals plots for clarity. Also see 401 :ref:`Assessing_Fit_Quality`. 402 403 *NB: If you need to use a customized model, you must ensure that model is available* 404 *first (see* :ref:`Adding_your_own_models` *).* 405 406 Method 407 ^^^^^^ 408 409 Now go to each *FitPage* in turn and: 410 411 Select the required category and model; 412 413 Unselect all the model parameters; 414 415 Enter some starting guesses for the parameters; 416 417 Enter any parameter limits (recommended); 418 419 Select which parameters will refine (selecting all is generally a bad idea...); 420 421 When done, select *Constrained or Simultaneous Fit* under *Fitting* in the menu bar. 422 423 In the *Const & Simul Fit* page that appears, select which data sets are to be 424 simultaneously fitted (this will probably be all of them or you would not have loaded 425 them in the first place!). 426 427 To tie parameters between the data sets with constraints, check the 'yes' radio button 428 next to *Add Constraint?* in the *Fit Constraints* box. 429 430 *NB: You can only constrain parameters that are set to refine.* 431 432 When ready, click the *Fit* button on the *Const & Simul Fit* page, NOT the *Fit* 433 button on the individual *FitPage*'s. 434 435 Simultaneous Fits without Constraints 436 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 437 438 The results of the model-fitting will be returned to each of the individual 439 *FitPage*'s. 440 441 Note that the chi2/Npts value returned is the SUM of the chi2/Npts of each fit. To 442 see the chi2/Npts value for a specific *FitPage*, click the *Compute* button at the 443 bottom of that *FitPage* to recalculate. Also see :ref:`Assessing_Fit_Quality`. 444 445 Simultaneous Fits with Constraints 446 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 447 448 Use the *Easy Setup* drop-down buttons in the *Const & Simul Fit* page to set 449 up constraints between *FitPage*'s. 450 451 Constraints will generally be of the form 452 453 Mi Parameter1 = Mj.Parameter1 454 455 however the text box after the '=' sign can be used to adjust this 456 relationship; for example 457 458 Mi Parameter1 = scalar \* Mj.Parameter1 459 460 A 'free-form' constraint box is also provided. 461 462 Many constraints can be entered for a single fit. 463 464 The results of the model-fitting will be returned to each of the individual 465 *FitPage*'s. 466 467 Note that the chi2/Npts value returned is the SUM of the chi2/Npts of each fit. To 468 see the chi2/Npts value for a specific *FitPage*, click the *Compute* button at the 469 bottom of that *FitPage* to recalculate. Also see :ref:`Assessing_Fit_Quality`. 470 471 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 472 473 Batch Fit Mode 474 -------------- 475 476 *NB: Before proceeding, ensure that the Single Mode radio button at the bottom of* 477 *the Data Explorer is checked (see the section* :ref:`Loading_data` *). The Batch* 478 *Mode button will be used later on!* 479 480 This mode *sequentially* fits two or more data sets *to the same model*. Unlike in 481 simultaneous fitting, in batch fitting it is not possible to constrain fit parameters 482 between data sets. 483 484 If the data to be fit are in multiple files, load each file in the *Data Explorer*. 485 If multiple data sets are in one file, load just that file. *Unselect All Data*, then 486 select a single initial data set to be fitted. Fit that selected data set as described 487 above under :ref:`Single_Fit_Mode` . 488 489 *NB: If you need to use a customized model, you must ensure that model is available* 490 *first (see* :ref:`Adding_your_own_models` *).* 491 492 Method 493 ^^^^^^ 494 495 Now *Select All Data* in the *Data Explorer*, check the *Batch Mode* radio button 496 at the bottom of that panel and *Send To Fitting*. A *BatchPage* will be created. 497 498 .. image:: batch_button_area.bmp 499 500 *NB: The Batch Page can also be created by checking the Batch Mode radio button* 501 *and selecting New Fit Page under Fitting in the menu bar.* 502 503 Using the drop-down menus in the *BatchPage*, now set up the *same* data set 504 with the *same* model that you just fitted in single fit mode. A quick way to 505 set the model parameter values is to just copy them from the earlier Single 506 Fit. To do this, go back to the Single Fit *FitPage*, select *Copy Params* 507 under *Edit* in the menu bar, then go back to the *BatchPage* and *Paste Params*. 508 509 When ready, use the *Fit* button on the *BatchPage* to perform the fitting, NOT 510 the *Fit* button on the individual *FitPage*'s. 511 512 Unlike in single fit mode, the results of batch fits are not returned to 513 the *BatchPage*. Instead, a spreadsheet-like :ref:`Grid_Window` will appear. 514 515 If you want to visually check a graph of a particular fit, click on the name of 516 a *Data set* in the *Grid Window* and then click the *View Fits* button. The 517 data and the model fit will be displayed. If you select mutliple data sets they 518 will all appear on one graph. 519 520 .. image:: view_button.bmp 521 522 *NB: In theory, returning to the BatchPage and changing the name of the I(Q)* 523 *data source should also work, but at the moment whilst this does change the* 524 *data set displayed it always superimposes the 'theory' corresponding to the* 525 *starting parameters.* 526 527 If you select a 'Chi2' value and click the *View Fits* button a graph of the 528 residuals for that data set is displayed. Again, if you select multiple 'Chi2' 529 values then all the residuals data will appear on one graph. Also see 530 :ref:`Assessing_Fit_Quality`. 531 532 Chain Fitting 533 ^^^^^^^^^^^^^ 534 535 By default, the *same* parameter values copied from the initial single fit into 536 the *BatchPage* will be used as the starting parameters for all batch fits. It 537 is, however, possible to get *SasView* to use the results of a fit to a preceding 538 data set as the starting parameters for the next fit in the sequence. This 539 variation of batch fitting is called *Chain Fitting*, and will considerably speed 540 up model-fitting if you have lots of very similar data sets where a few parameters 541 are gradually changing. Do not use chain fitting on disparate data sets. 542 543 To use chain fitting, select *Chain Fitting* under *Fitting* in the menu bar. It 544 toggles on/off, so selecting it again will switch back to normal batch fitting. 545 546 .. _Grid_Window: 547 548 Grid Window 549 ^^^^^^^^^^^ 550 551 The *Grid Window* provides an easy way to view the results from batch fitting. 552 It will be displayed automatically when a batch fit completes, but may be 553 opened at any time by selecting *Show Grid Window* under *View* in the menu 554 bar. 555 556 .. image:: restore_batch_window.bmp 557 558 Once a batch fit is completed, all model parameters are displayed but *not* 559 their uncertainties. To view the uncertainties, click on a given column then 560 go to *Edit* in the menu bar, select *Insert Column Before* and choose the 561 required data from the list. An empty column can be inserted in the same way. 562 563 To remove a column from the grid, click on the column header and choose 564 *Remove Column* under *Edit* in the menu bar. The same functionality also 565 allows you to re-order columns. 566 567 *NB: You cannot insert/remove/re-order the rows in the Grid Window.* 568 569 All of the above functions are also available by right-clicking on a column 570 label. 571 572 .. image:: edit_menu.bmp 573 574 *NB: If there is an existing Grid Window and another batch fit is performed,* 575 *an additional 'Table' tab will be added to the Grid Window.* 576 577 The parameter values in the *currently selected* table of the *Grid Window* 578 can be output to a CSV file by choosing *Save As* under *File* in the (*Grid* 579 *Window*) menu bar. The default filename includes the date and time that the 580 batch fit was performed. 581 582 Saved CSV files can be reloaded by choosing *Open* under *File* in the *Grid* 583 *Window* menu bar. The loaded parameters will appear in a new table tab. 584 585 .. image:: file_menu.bmp 586 587 *NB: Saving the Grid Window does not save any experimental data, residuals* 588 *or actual model fits. Consequently if you reload a saved CSV file the* 589 *ability to View Fits will be lost.* 590 591 Parameter Plots 592 ^^^^^^^^^^^^^^^ 593 594 Any column of *numeric* parameter values can be plotted against another using 595 the *Grid Window*. Simply select one column at the time and click the *Add* 596 button next to the required *X/Y-axis Selection Range* text box. When both 597 the X and Y axis boxes have been completed, click the *Plot* button. 598 599 When the *Add* button is clicked, *SasView* also automatically completes the 600 *X/Y-axis Label* text box with the heading from Row 1 of the selected table, 601 but different labels and units can be entered manually. 602 603 .. image:: plot_button.bmp 604 605 The *X/Y-axis Selection Range* can be edited manually. The text control box 606 recognises the operators +, -, \*, /, or 'pow', and allows the following 607 types of expression : 608 609 1) if an axis label range is a function of 1 or more *columns*, write 610 this type of expression 611 612 constant1 * column_name1 [minimum row index : maximum row index] 613 operator constant2 * column_name2 [minimum row index : maximum row index] 614 615 Example: radius [2 : 5] -3 * scale [2 : 5] 616 617 2) if only some *values* of a given column are needed but the range between 618 the first row and the last row used is not continuous, write this type of 619 expression 620 621 column_name1 [minimum row index1 : maximum row index1] , column_name1 622 [minimum row index2 : maximum row index2] 623 624 Example: radius [2 : 5] , radius [10 : 25] 625 626 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 627 628 .. note:: This help document was last changed by Steve King, 04Jun2015
Note: See TracChangeset
for help on using the changeset viewer.