source: sasview/src/sas/perspectives/fitting/media/fitting_help.rst @ 5e880fe1

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 5e880fe1 was a0637de, checked in by smk78, 10 years ago

Work in progress

  • Property mode set to 100644
File size: 16.2 KB
RevLine 
[ec392464]1.. fitting_help.rst
2
3.. This is a port of the original SasView html help file to ReSTructured text
4.. by S King, ISIS, during SasView CodeCamp-III in Feb 2015.
5
6.. |beta| unicode:: U+03B2
7.. |gamma| unicode:: U+03B3
8.. |mu| unicode:: U+03BC
9.. |sigma| unicode:: U+03C3
10.. |phi| unicode:: U+03C6
11.. |theta| unicode:: U+03B8
[98b30b4]12.. |chi| unicode:: U+03C7
13
14.. |inlineimage004| image:: sm_image004.gif
15.. |inlineimage005| image:: sm_image005.gif
16.. |inlineimage008| image:: sm_image008.gif
17.. |inlineimage009| image:: sm_image009.gif
18.. |inlineimage010| image:: sm_image010.gif
19.. |inlineimage011| image:: sm_image011.gif
20.. |inlineimage012| image:: sm_image012.gif
21.. |inlineimage018| image:: sm_image018.gif
22.. |inlineimage019| image:: sm_image019.gif
23
[ec392464]24
25Fitting Perspective
26===================
27
[a0637de]28Preparing_to_fit_data_
[ec392464]29
30Single_Fit_
31
32Simultaneous_Fitting_
33
34Batch_Fitting_
35
36Model_Selection_
37
38Model_Category_Manager_
39
40Model_Functions_
41
42Custom_Model_Editor_
43
[ce62e75]44Key_Combinations_
45
46Status_Bar_Help_
47
[ec392464]48.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
49
[a0637de]50.. _Preparing_to_fit_data:
[ec392464]51
[a0637de]52Preparing to fit data
53---------------------
54
55To fit some data you must first load some data, activate one or more data sets,
56then send those data sets to the fitting perspective.
57
58Instructions on how to do this are in the User Documentation section *Loading*
59*Data*.
60
61SasView can fit data in one of three ways:
62
63*  in *Single* fit mode
64*  in *Simultaneous* fit mode
65*  in *Batch* fit mode
[ec392464]66
[a0637de]67These modes of operation are described below.
[ec392464]68
69.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
70
71.. _Single_Fit:
72
73Single Fit
74----------
75
76One of two fit-engines can be chosen from the Fitting menu bar. The Simple Fit-
77engine uses Scipy's leasqr and the Complex Fit-Engine is a custom optimizer
[98b30b4]78that provides a better chance to find the global minimum of the |chi| 2 but that
[ec392464]79requires longer computation time. In order to set a data to a control panel
80(FitPage), see the "DataLoader Help". Once a data set to the FiPage, select a
81model from the combo box. The default parameters of the model will be display.
82Set initial parameters if need. Check and uncheck parameters to fit/fix. Click
83the *'Fit'*  button. When the fitting is finished, the resultant parameter
84values will be displayed with the errors. If a error is missing, it generally
85means that the corresponding parameter is not very depending on the model. The
86chisq/Npt_fit and the plot associated with the fit operation will be also
87updated.
88
89.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
90
91..  _Simultaneous_Fitting:
92
93Simultaneous Fitting
94--------------------
95
96This fitting option enables to set a number of the constraints between the
97parameters of fitting(s). It requires one or more FitPages with a data and a
98model set for the fitting, and performs multiple fittings given by the
99FitPage(s). The Complex (ParkMC) FitEngine will be used automatically.
100
101Simultaneous Fit without Constraint
102
103Assuming some FitPages are already set up, check the checkboxes of the
104model_data rows to fit. And click the 'Fit' button. The results will return to
105each FitPages.
106
107Note that the chi2/Npts returned is the sum of the chi2/Npts of each fits. If
108one needs the chi2 value only for a page, click the 'Compute' button in the
109FitPage to recalculate.
110
111Simultaneous Fit with Constraint
112
113Enter constraint in the text control next to *constraint fit*  button.
114Constraint should be of type model1 parameter name = f(model2 parameter name)
115for example, M0.radius=2*M1.radius. Many constraints can be entered for a
116single fit. Each of them should be separated by a newline charater or ";"
117The easy setup can generate many constraint inputs easily when the selected
118two models are the same type.
119
120Note that the chi2/Npts returned is the sum of the chi2/Npts of each fits.
121If one needs the chi2 value only for one fit, click the 'Compute' button in
122the FitPage to recalculate.
123
124.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
125
126..  _Batch_Fitting:
127
128Batch Fitting
129-------------
130
131Batch_Fit_
132
133Batch_Window_
134
135Edit_Grid_
136
137Save_Grid_
138
139Open_Batch_Results_
140
141Plot_
142
143View_Column_Cell_
144
145.. _Batch_Fit:
146
147Batch Fit
148---------
149
150Create a *Batch Page* by selecting the *Batch* radio button on the DataExplorer
151(see figure below) and for a new control page select 'New FitPage' in the
152Fitting menubar.
153
154.. image:: batch_button_area.bmp
155
156Figure 1: MenuBar:
157
158Load Data to the DataExplorer if not already loaded.
159
160Select one or more data sets by checking the check boxes, and then make sure
161that "Fitting" is selected in the dropdown menu next to the "Send To" button.
162Once ready, click the 'Send To' button to set data to a BatchPage. If already
163an empty batch page exists, it will be set there. Otherwise it will create a
164new Batch Page. Set up the model and the parameter values as same as a single
165fitting (see Single Fit help) <Single_Fit_>. Then use 'Fit' button to
166perform the fitting.
167
168Unlike a single fit, the results of the fittings will not return to the
169BatchPage'. Instead, a Grid window will be provided once the fitting is
170completed. The Grid window is also accessible from the 'View' menu
171(see Figure 2).
172
173Note that only one model is used for all the data. The initial parameter
174values given in the control page will be used all the data fittings. If one
175wants the FitEngine to use the initial values from the results of the
176previous data fitting (if any), choose the 'Chain Fitting' option in the
177Fitting menubar, which will speed up the fitting especially when you have
178lots of, and similar, data sets.
179
180.. _Batch_Window:
181
182Batch Window
183------------
184Batch Window provides an easy way to view the fit results, i.e., plot data,
185fits, and residuals. Batch window will be automatically shown after a batch
186fit is finished.
187
188Once closed, it can be opened anytime from the "View" menubar item (see
189Figure 2).
190
191.. image:: restore_batch_window.bmp
192
193Figure 2: Edit Menu:
194
195.. _Edit_Grid:
196
197Edit Grid
198---------
199
200Once a batch fit is completed, all fitted and fixed model parameters are
201displayed to the current sheet of the batch window except the errors of the
202parameters. To view the errors, click on a given column then under *Edit* 
203menubar item, and insert the desired parameter by selecting a menu item with
204the appropriated label. Empty column can be inserted in the same way. A
205column value can be customized by editing an existing empty column.
206
207To Remove column from the grid, select it, choose edit menu, and click the
208*'remove'*  menu item. Any removed column should reinserted whenever needed.
209
210All above options are also available when right clicking on a given column
211label(see Figure 3).
212
213*Note:*  A column always needs to be selected in order to remove or insert a
214column in the grid.
215
216.. image:: edit_menu.bmp
217
218Figure 3: Edit Menu:
219
220.. _Save_Grid:
221
222Save Grid
223---------
224To save the current page on the batch window, select the *'File'*  menubar
225item(see Figure 4), then choose the *'Save as'*  menu item to save it as a
226.csv file.
227
228*Note:* The grid doesn't save the data array, fits, and the array residuals.
229As a result, the 'View (fit) Results' functionality will be lost when
230reloading the saved file.
231
232Warning! To ensure accuracy of saved fit results, it is recommended to save
233the current grid before modifying it .
234
235.. _Open_Batch_Results:
236
237Open Batch Results
238------------------
239
240Any *csv*  file can be opened in the grid by selecting the *'Open'*  under
241the *'File'*  menu in the Grid Window(see Figure 4). All columns in the file
242will be displayed but insertion will not available. Insertion will be
243available only when at least one column will be removed from the grid.
244
245.. image:: file_menu.bmp
246
247Figure 4: MenuBar:
248
249.. _Plot:
250
251Plot
252----
253
254To *plot*  a column versus another, select one column at the time, click the
255*'Add'*  button next to the text control of X/Y -axis *Selection Range*  to
256plot the value of this column on the X/Y axis. Alternatively, all available
257range can be selected by clicking the column letter (eg. B). Repeat the same
258procedure the next axis. Finally, click the *'Plot'*  button. When clicking
259on *Add*  button, the grid will automatically fill the axis label, but
260different labels and units can be entered in the correct controls before
261clicking on the plot button.
262
263*X/Y -Axis Selection Range* can be edited manually. These text controls
264allow the following types of expression (operation can be + - * /, or pow)
265 
2661) if the current axis label range is a function of 1 or more columns, write
267this type of expression
268
269constant1  * column_name1 [minimum row index :  maximum  row index] operator
270constant2 * column_name2 [minimum row index :  maximum  row index]
271
272Example: radius [2 : 5] -3 * scale [2 : 5]
273
2742) if only some values of a given column are need but the range between the
275first row and the last row used is not continuous, write the following
276expression in the text control
277
278column_name1 [minimum row index1 :  maximum  row index1] , column_name1
279[minimum row index2 :  maximum  row index2]
280
281Example : radius [2 : 5] , radius [10 : 25]
282
283Note: Both text controls ( X and Y-axis Selection Ranges) need to be filled
284with valid entries for plotting to work. The dY-bar is optional (see Figure 5).
285
286.. image:: plot_button.bmp
287
288Figure 5: Plotting
289
290.. _View_Column_Cell:
291
292View Column/Cell(s)
293-------------------
294
295Select 1 or more cells from the same column, click the 'View Fits' button to
296display available curves.
297
298For example, select the cells of the  'Chi2'  column, then click the  'View Fits' 
299button. The plots generates will represent the residuals  plots.
300 
301If you select any cells of the 'Data' column and click the 'View Fits' button.
302It generates both  data and fits in the graph (see Figure 6).
303
304Alternatively, just click the column letter (eg. B) to choose all the
305available data sets, then simply click the 'View Fits' button to plot the
306data and fits.
307
308.. image:: view_button.bmp
309
310Figure 6: View Fits
311
312.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
313
314..  _Model_Selection:
315
316Model_Type_
317
318Change_Model_Parameters_
319
320Write_your_Own_Model_
321
322.. _Model_Type:
323
324Model Type
325----------
326
327Models are grouped into three classes
328
329*  *Shapes* 
330*  *Shape-Independent* 
331*  *Uncategorised*
332*  *Customized Models* 
333*  *Structure Factor*
334
335.. _Change_Model_Parameters:
336
337Change Model Parameters
338-----------------------
339
340To visualize model in a different window, from menu click on *Model*. Select
341a type of model and then the name of your model.A new window will appear with
342the plot of your model with default values. Change model's parameters on
343*model view*  tab and view the plotted model with its new parameters.
344
345.. _Write_your_Own_Model:
346
347Write your Own Model
348--------------------
349
350The custom model editors are provided from 'Fitting' menu in the menu bar.
351See 'Custom model editor' in the side menu on left. Advanced users can write
352your own model and save it (in .py format) into *plugin_models*  directory in
353.sasview of your home directory (eg., username\.sasview>\plugin_models). Your
354plugin model will be added into "<>Customized Models" on the next model
355selection.
356
357.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
358
359..  _Model_Category_Manager:
360
361Model Category Manager
362----------------------
363
364Our SAS models are, by default, classified into 5 categories; shapes,
365shape-independent, structure factor, and customized models, where these
366categories (except the customized models) can be reassigned, added, and
367removed using 'Category Manager'. Each models can also be enabled(shown)/
368disabled(hidden) from the category that they belong. The Category Manager
369panel is accessible from the model category 'Modify' button in the fitting
370panel or the 'View/Category Manager' menu in the menu bar (Fig. 1).
371
3721) Enable/Disable models: Check/uncheck the check boxes to enable/disable the
373models (Fig. 2).
374
3752) Change category: Highlight a model in the list by left-clicking and click
376the 'Modify' button. In the 'Change Category' panel, one can create/use a
377category for the model, then click the 'Add' button. In order to delete a
378category, select a category name and click the 'Remove Selected' button
379(Fig. 3).
380
3813) To apply the changes made, hit the OK button. Otherwise, click the 'Cancel'
382button (Fig. 2).
383
384.. image:: cat_fig0.bmp
385
386Fig.1
387
388.. image:: cat_fig1.bmp
389
390Fig.2
391
392.. image:: cat_fig2.bmp
393
394Fig.3
395
396.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
397
398..  _Model_Functions:
399
400Model Functions
401---------------
402
[a0637de]403See *Model Documentation*.
[ec392464]404
405.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
406
407..  _Custom_Model_Editor:
408
409Custom Model Editor
410-------------------
411
412Description_
413
414New_
415
416Sum_Multi_p1_p2_
417
418Advanced_
419
420Delete_
421
422.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
423
424.. _Description:
425
426Description
427-----------
428
429This menu (Fitting/Edit Custom Model in the menu bar) interface is to provide
430you an easy way to write your own custom models. The changes in a model
431function are effective after it is re-selected from the combo-box menu.
432
433.. image:: edit_model_menu.bmp
434
435.. _New:
436
437New
438---
439
440This option is used to make a new model. A model code generated by this option
441can be viewed and further modified by the 'Advanced' option below.
442
443.. image:: new_model.bmp
444
445.. _Sum_Multi_p1_p2:
446
447Sum|Multi(p1,p2)
448----------------
449
450This option create a new sum (or multiplication) model. Fill up the (sum
451model function) name and the description. The description will show up on
452details button in the application. Then select the p1 or p2 model for the
453sum/multi model, select an operator as necessary and click the Apply button
454for activation. Hit the 'Close' button when it's done.
455
456.. image:: sum_model.bmp
457
458.. _Advanced:
459
460Advanced
461--------
462
463The menu option shows all the files in the plugin_models folder. You can edit,
464modify, and save it. It is recommended to modify only the lines with arrow
465(-------). In the end of edit, 'Compile' and 'Run' from the menu bar to
466activate or to see the model working properly.
467
468.. _Delete:
469
470Delete
471------
472
473The menu option is to delete the custom models. Just select the file name to
474delete.
475
476.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
477
478.. _Key_Combinations:
479
480Key Combinations
481----------------
482
483Copy_Paste_
484
485Bookmark_
486
487Graph_Context_Menu_
488
489FTolerance_
490
491.. _Copy_Paste:
492
493Copy & Paste
494------------
495
496To copy the parameter values in a Fit(Model) panel to the clipboard:
497
498*Ctrl(Cmd on MAC) + Left(Mouse)Click*  on the panel.
499
500To paste the parameter values to a Fit(Model)panel from the clipboard:
501
502*Ctrl(Cmd on MAC) + Shift + Left(Mouse)Click*  on the panel.
503
504If this operation is successful, it will say so in the info line at the
505bottom of the SasView window.
506
507.. _Bookmark:
508
509Bookmark
510--------
511
512Bookmark of a fit-panel or model-panel status:
513
514*(Mouse)Right-Click*  and select the bookmark in the popup list.
515
516.. _Graph_Context_Menu:
517
518Graph Context Menu
519------------------
520
521To get the graph context menu to print, copy, save data, (2D)average, etc.:
522
523*Locate the mouse point on the plot to highlight and *(Mouse) Right Click*
524to bring up the full menu.
525
526.. _FTolerance: 
527
528FTolerance (SciPy)
529------------------
530
531To change the ftol value of the Scipy FitEngine (leastsq):
532
533First, make sure that the Fit panel has data and a model selected.
534
535*Ctrl(Cmd on MAC) + Shift + Alt + Right(Mouse)Click*  on the panel.
536
537Then, set up the value in the dialog panel.
538
539If this operation is successful, the new ftol value will be displayed in the
540info line at the bottom of the SV window.Note that increasing the ftol value
[98b30b4]541may cause for the fitting to terminate with higher |chi| sq.
[ec392464]542
543.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
544
545.. _Status_Bar_Help:
546
547Status Bar Help
548---------------
549
550Message_Warning_Hint_
551
552Console_
553
554.. _Message_Warning_Hint:
555
556Message/Warning/Hint
557--------------------
558
559The status bar located at the bottom of the application frame, displays
560messages, hints, warnings and errors.
561
562.. _Console:
563
564Console
565-------
566
567Select *light bulb/info icon*  button in the status bar at the bottom of the
568application window to display available history. During a long task, the
569console can also help users to understand the status in progressing.
[ce62e75]570
571.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
Note: See TracBrowser for help on using the repository browser.