Changeset 9687d58 in sasview for src/sas/sasgui/perspectives/fitting/media
- Timestamp:
- Apr 10, 2017 4:01:46 AM (8 years ago)
- Branches:
- 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
- Children:
- 6c8fb2c
- Parents:
- 9208346 (diff), c6f3aec (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/sasgui/perspectives/fitting/media
- Files:
-
- 1 added
- 1 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/fitting/media/fitting.rst
rf237c05 r46dfee9 3 3 Fitting Documentation 4 4 ===================== 5 6 .. note:: In Windows use [Alt]-[Cursor left] to return to the previous page 5 7 6 8 .. toctree:: … … 18 20 19 21 Information on the SasView Optimisers <optimizer.rst> 20 21 Writing a Plugin <plugin.rst> 22 23 Converting SANS to SESANS for Fitting <../../../sans_to_sesans> 24 25 Fitting SESANS Data <../../../sesans_fitting.rst> 26 27 Writing a Plugin Model <plugin.rst> 28 29 Computations with a GPU <../../../gpu_computations> 30 -
src/sas/sasgui/perspectives/fitting/media/fitting_help.rst
rf237c05 r9687d58 18 18 ======= 19 19 20 .. note:: If some code blocks are not readable, expand the documentation window 21 20 22 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 21 23 … … 32 34 * in *Single* fit mode - individual data sets are fitted independently one-by-one 33 35 34 * in *Simultaneous* fit mode - multiple data sets are fitted simultaneously to the *same* model with/without constrained parameters (this might be useful, for example, if you have measured the same sample at different contrasts) 36 * in *Simultaneous* fit mode - multiple data sets are fitted simultaneously to 37 the *same* model with/without constrained parameters (this might be useful, 38 for example, if you have measured the same sample at different contrasts) 35 39 36 40 * 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!) … … 41 45 ----------------- 42 46 43 By default, the models in SasView are grouped into five categories 44 45 * *Shapes* - models describing 'objects' (spheres, cylinders, etc) 47 The models in SasView are grouped into categories. By default these consist of: 48 49 * *Cylinder* - cylindrical shapes (disc, right cylinder, cylinder with endcaps 50 etc) 51 * *Ellipsoid* - ellipsoidal shapes (oblate,prolate, core shell, etc) 52 * *Parellelepiped* - as the name implies 53 * *Sphere* - sheroidal shapes (sphere, core multishell, vesicle, etc) 54 * *Lamellae* - lamellar shapes (lamellar, core shell lamellar, stacked 55 lamellar, etc) 46 56 * *Shape-Independent* - models describing structure in terms of density correlation functions, fractals, peaks, power laws, etc 47 * *Customized Models* - SasView- or User-created (non-library) Python models 48 * *Uncategorised* - other models (for reflectivity, etc) 57 * *Paracrystal* - semi ordered structures (bcc, fcc, etc) 49 58 * *Structure Factor* - S(Q) models 59 * *Plugin Models* - User-created (custom/non-library) Python models 50 60 51 61 Use the *Category* drop-down menu to chose a category of model, then select … … 82 92 .. image:: cat_fig0.bmp 83 93 84 The categorization of all models except the customized models can be reassigned,85 added to, and removed using *Category Manager*. Models can also be hidden from view 86 in the drop-down menus.94 The categorization of all models except the user supplied Plugin Models can be 95 reassigned, added to, and removed using *Category Manager*. Models can also be 96 hidden from view in the drop-down menus. 87 97 88 98 .. image:: cat_fig1.bmp … … 91 101 ^^^^^^^^^^^^^^^^^ 92 102 93 To change category, highlight a model in the list by left-clicking on its entry and94 then click the *Modify* button. Use the *Change Category* panel that appears to make 95 t he required changes.103 To change category, highlight a model in the list by left-clicking on its entry 104 and then click the *Modify* button. Use the *Change Category* panel that appears 105 to make the required changes. 96 106 97 107 .. image:: cat_fig2.bmp … … 104 114 ^^^^^^^^^^^^^^^^^^^^^ 105 115 106 Use the *Enable All / Disable All* buttons and the check boxes beside each model to107 select the models to show/hide. To apply the selection, click *Ok*. Otherwise click 108 *Cancel*.116 Use the *Enable All / Disable All* buttons and the check boxes beside each model 117 to select the models to show/hide. To apply the selection, click *Ok*. Otherwise 118 click *Cancel*. 109 119 110 120 *NB: It may be necessary to change to a different category and then back again* … … 116 126 --------------- 117 127 118 For a complete list of all the library models available in SasView, see the Model Documentation. 128 For a complete list of all the library models available in SasView, see 129 the `Model Documentation <../../../index.html>`_ . 119 130 120 131 It is also possible to add your own models. … … 124 135 .. _Adding_your_own_models: 125 136 126 Adding your own models137 Adding your own Models 127 138 ---------------------- 128 139 129 There are currently two ways to add your own models to SasView: 130 131 * Using the :ref:`Custom_Model_Editor` 132 * By :ref:`Writing_a_Plugin` 133 134 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 135 136 .. _Custom_Model_Editor: 137 138 Custom Model Editor 139 ------------------- 140 141 From the *Fitting* option in the menu bar, select *Edit Custom Model*. 142 143 .. image:: edit_model_menu.bmp 144 145 and then one of the options 146 147 * *New* - to create a new custom model template 148 * *Sum|Multi(p1,p2)* - to create a new model by summing/multiplying existing models in the model library 149 * *Advanced* - to edit a new custom model 150 * *Delete* - to delete a custom model 151 152 New 153 ^^^^ 140 There are essentially three ways to generate new fitting models for SasView: 141 142 * Using the SasView :ref:`New_Plugin_Model` helper dialog (best for beginners 143 and/or relatively simple models) 144 * By copying/editing an existing model (this can include models generated by 145 the New Plugin Model* dialog) in the :ref:`Python_shell` or 146 :ref:`Advanced_Plugin_Editor` (suitable for all use cases) 147 * By writing a model from scratch outside of SasView (only recommended for code 148 monkeys!) 149 150 Please read the guidance on :ref:`Writing_a_Plugin` before proceeding. 151 152 **To be found by SasView your model must reside in the *~\\.sasview\\plugin_models* folder.** 153 154 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 155 156 .. _Plugin_Model_Operations: 157 158 Plugin Model Operations 159 ----------------------- 160 161 From the *Fitting* option in the menu bar, select *Plugin Model Operations* 162 163 .. image:: edit_model_menu.png 164 165 and then one of the sub-options 166 167 * *New Plugin Model* - to create a plugin model template with a helper dialog 168 * *Sum|Multi(p1,p2)* - to create a plugin model by summing/multiplying *existing models* in the model library 169 * *Advanced Plugin Editor* - to create/edit a plugin model in a Python shell 170 * *Delete Plugin Models* - to delete a plugin model 171 * *Load Plugin Models* - to (re-)load plugin models 172 173 .. _New_Plugin_Model: 174 175 New Plugin Model 176 ^^^^^^^^^^^^^^^^ 177 178 Relatively straightforward models can be programmed directly from the SasView 179 GUI using the *New Plugin Model Function*. 154 180 155 181 .. image:: new_model.bmp 156 182 157 A model template generated by this option can be viewed and further modified using 158 the :ref:`Advanced` option. 159 160 *NB: "Fit Parameters" has been split into two sections, those which can be 161 polydisperse (shape and orientation parameters) and those which are not 162 (scattering length densities, for example).* 183 When using this feature, be aware that even if your code has errors, including 184 syntax errors, a model file is still generated. When you then correct the errors 185 and click 'Apply' again to re-compile you will get an error informing you that 186 the model already exists if the 'Overwrite' box is not checked. In this case you 187 will need to supply a new model function name. By default the 'Overwrite' box is 188 *checked*\ . 189 190 Also note that the 'Fit Parameters' have been split into two sections: those 191 which can be polydisperse (shape and orientation parameters) and those which are 192 not (eg, scattering length densities). 193 194 A model file generated by this option can be viewed and further modified using 195 the :ref:`Advanced_Plugin_Editor` . 163 196 164 197 Sum|Multi(p1,p2) … … 167 200 .. image:: sum_model.bmp 168 201 169 This option creates a custom model of the form 170 171 Custom Model = scale_factor \* (model1 +/\* model2) 172 173 In the *Easy Sum/Multi Editor* give the new custom model a function name and brief 174 description (to appear under the *Details* button on the *Fit Page*). Then select 202 This option creates a custom Plugin Model of the form:: 203 204 Plugin Model = scale_factor * {(scale_1 * model_1) +/- (scale_2 * model_2)} + background 205 206 or:: 207 208 Plugin Model = scale_factor * model_1 /* model_2 + background 209 210 In the *Easy Sum/Multi Editor* give the new model a function name and brief 211 description (to appear under the *Details* button on the *FitPage*). Then select 175 212 two existing models, as p1 and p2, and the required operator, '+' or '*' between 176 213 them. Finally, click the *Apply* button to generate the model and then click *Close*. 177 214 178 *NB: Any changes to a custom model generated in this way only become effective after* 179 *it is re-selected from the model drop-down menu on the Fit Page.* 180 181 .. _Advanced: 182 183 Advanced 184 ^^^^^^^^ 185 186 Selecting this option shows all the custom models in the plugin model folder 187 188 *C:\\Users\\[username]\\.sasview\\plugin_models* - (on Windows) 215 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. 216 217 .. _Advanced_Plugin_Editor: 218 219 Advanced Plugin Editor 220 ^^^^^^^^^^^^^^^^^^^^^^ 221 222 Selecting this option shows all the plugin models in the plugin model folder, on Windows this is 223 224 *C:\\Users\\{username}\\.sasview\\plugin_models* 189 225 190 226 You can edit, modify, and save the Python code in any of these models using the 191 *Advanced Custom Model Editor*. 192 193 See :ref:`Writing_a_Plugin` for details on the plugin format. 194 195 *NB: Sum/Product models are still using the SasView 3.x model format. Unless 196 you are confident about what you are doing, it is recommended that you 197 only modify lines denoted with the ## <----- comments!* 198 199 When editing is complete, select *Run -> Compile* from the *Model Editor* menu bar. An 200 *Info* box will appear with the results of the compilation and model unit tests. The 201 model will only be usable if the tests 'pass'. 202 203 To use the model, go to the relevant *Fit Page*, select the *Customized Models* 227 *Advanced Plugin Model Editor*. Note that this is actually the same tool as the :ref:`Python_shell` . 228 229 For details of the SasView plugin model format see :ref:`Writing_a_Plugin` . 230 231 .. 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! 232 233 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'. 234 235 .. image:: ../calculator/new_pycrust_example_2.png 236 237 To use the model, go to the relevant *Fit Page*, select the *Plugin Models* 204 238 category and then select the model from the drop-down menu. 205 239 206 *NB: Any changes to a custom model generated in this way only become effective after* 207 *it is re-selected from the model drop-down menu on the Fit Page.* 208 209 Delete 210 ^^^^^^ 211 212 Simply highlight the custom model to be removed. This operation is final! 213 214 *NB: Custom models shipped with SasView cannot be removed in this way.* 215 216 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 217 218 .. _Writing_a_Plugin: 219 220 Writing a Plugin 221 ---------------- 222 223 Advanced users can write their own model in Python and save it to the the SasView 224 *plugin_models* folder 225 226 *C:\\Users\\[username]\\.sasview\\plugin_models* - (on Windows) 227 228 in .py format. The next time SasView is started it will compile the plugin and add 229 it to the list of *Customized Models*. 230 231 It is recommended that existing plugin models be used as templates. 240 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. 241 242 Delete Plugin Models 243 ^^^^^^^^^^^^^^^^^^^^ 244 245 Simply highlight the plugin model to be removed. The operation is final!!! 246 247 *NB: Models shipped with SasView cannot be removed in this way.* 248 249 Load Plugin Models 250 ^^^^^^^^^^^^^^^^^^ 251 252 This option loads (or re-loads) all models present in the 253 *~\\.sasview\\plugin_models* folder. 232 254 233 255 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ … … 392 414 :ref:`Assessing_Fit_Quality`. 393 415 394 *NB: If you need to use a custom ized model, you must ensure that model is available*395 *first (see* :ref:`Adding_your_own_models` *).*416 *NB: If you need to use a custom Plugin Model, you must ensure that model is 417 available first (see* :ref:`Adding_your_own_models` *).* 396 418 397 419 Method … … 476 498 If multiple data sets are in one file, load just that file. *Unselect All Data*, then 477 499 select a single initial data set to be fitted. Fit that selected data set as described 478 above under :ref:`Single_Fit_Mode` 479 480 *NB: If you need to use a custom ized model, you must ensure that model is available*481 *first (see* :ref:`Adding_your_own_models` *).*500 above under :ref:`Single_Fit_Mode`. 501 502 *NB: If you need to use a custom Plugin Model, you must ensure that model is 503 available first (see* :ref:`Adding_your_own_models` *).* 482 504 483 505 Method … … 617 639 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 618 640 619 .. note:: This help document was last changed by Steve King, 04Jun2015641 .. note:: This help document was last changed by Steve King, 10Oct2016 -
src/sas/sasgui/perspectives/fitting/media/plugin.rst
rf237c05 r9687d58 1 1 .. _Writing_a_Plugin: 2 2 3 Writing a Plugin 4 ================ 5 6 Users can write their own models and save it to the the SasView 7 *plugin_models* folder 8 9 *C:\\Users\\[username]\\.sasview\\plugin_models* - (on Windows) 10 11 The next time SasView is started it will compile the plugin and add 12 it to the list of *Customized Models*. It is recommended that an 13 existing model be used as a template. 14 15 This page was originally written by our MOST experienced developers, 16 but has subsequently been edited by our LEAST experienced developer who felt 17 some instructions could have been clearer, and learnt one or two things that 18 were missing altogether! But they succeeded in converting a model that passed 19 testing, so there is no reason why you should not be able to do the same. 20 21 SasView has three ways of writing models: 22 23 - As a pure python model : Example - 3 Writing a Plugin Model 4 ====================== 5 6 .. note:: If some code blocks are not readable, expand the documentation window 7 8 Introduction 9 ^^^^^^^^^^^^ 10 11 There are essentially three ways to generate new fitting models for SasView: 12 13 * Using the SasView :ref:`New_Plugin_Model` helper dialog (best for beginners 14 and/or relatively simple models) 15 * By copying/editing an existing model (this can include models generated by 16 the *New Plugin Model* dialog) in the :ref:`Python_shell` or 17 :ref:`Advanced_Plugin_Editor` as described below (suitable for all use cases) 18 * By writing a model from scratch outside of SasView (only recommended for 19 code monkeys!) 20 21 Overview 22 ^^^^^^^^ 23 24 If you write your own model and save it to the the SasView *plugin_models* folder 25 26 *C:\\Users\\{username}\\.sasview\\plugin_models* (on Windows) 27 28 the next time SasView is started it will compile the plugin and add 29 it to the list of *Plugin Models* in a FitPage. 30 31 SasView models can be of three types: 32 33 - A pure python model : Example - 24 34 `broadpeak.py <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/broad_peak.py>`_ 25 - A s apython model with embedded C : Example -35 - A python model with embedded C : Example - 26 36 `sphere.py <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/sphere.py>`_ 27 - A s apython wrapper with separate C code : Example -37 - A python wrapper with separate C code : Example - 28 38 `cylinder.py <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/cylinder.py>`_, 29 39 `cylinder.c <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/cylinder.c>`_ 30 40 31 Many models are available for download from the 32 `model marketplace <http://marketplace.sasview.org/>`_. 33 34 The builtin modules are available in the *sasmodels-data/models* subdirectory 35 of the sasview distribution. On Windows, this will be something like 36 *C:\Program Files (x86)\SasView\models*. On MacOSX, these will be within 41 The built-in modules are available in the *sasmodels-data\\models* subdirectory 42 of your SasView installation folder. On Windows, this will be something like 43 *C:\\Program Files (x86)\\SasView\\sasmodels-data\\models*. On Mac OSX, these will be within 37 44 the application bundle as 38 45 */Applications/SasView 4.0.app/Contents/Resources/sasmodels-data/models*. 39 46 47 Other models are available for download from our 48 `Model Marketplace <http://marketplace.sasview.org/>`_. You can contribute your own models to the 49 Marketplace aswell. 50 40 51 Create New Model Files 41 52 ^^^^^^^^^^^^^^^^^^^^^^ 42 53 43 In the *~ /.sasview/plugin_models* directory, copy the appropriate files44 ( using the examples above as templates) to mymodel.py (and mymodel.c, etc)54 In the *~\\.sasview\\plugin_models* directory, copy the appropriate files 55 (we recommend using the examples above as templates) to mymodel.py (and mymodel.c, etc) 45 56 as required, where "mymodel" is the name for the model you are creating. 46 57 47 58 *Please follow these naming rules:* 48 59 49 - No capitalization and thus no CamelCase .50 - If necessary use underscore to separate (i.e. barbell not BarBell or60 - No capitalization and thus no CamelCase 61 - If necessary use underscore to separate words (i.e. barbell not BarBell or 51 62 broad_peak not BroadPeak) 52 - Do n't include âmodelâin the name (i.e. barbell not BarBellModel)63 - Do not include "model" in the name (i.e. barbell not BarBellModel) 53 64 54 65 55 66 Edit New Model Files 56 67 ^^^^^^^^^^^^^^^^^^^^ 68 69 Model Contents 70 .............. 57 71 58 72 The model interface definition is in the .py file. This file contains: … … 65 79 - without spaces (use underscores to separate words instead) 66 80 - without any capitalization or CamelCase 67 - without incorporating the word 'model'81 - without incorporating the word "model" 68 82 - examples: *barbell* **not** *BarBell*; *broad_peak* **not** *BroadPeak*; 69 83 *barbell* **not** *BarBellModel* … … 72 86 - this is the **title** string in the *.py* file 73 87 - this is a one or two line description of the model, which will appear 74 at the start of the model documentation and as a tooltip in the GUI88 at the start of the model documentation and as a tooltip in the SasView GUI 75 89 76 90 - a **short discription**: 77 91 - this is the **description** string in the *.py* file 78 92 - this is a medium length description which appears when you click 79 *Description* on the model fit page93 *Description* on the model FitPage 80 94 81 95 - a **parameter table**: … … 85 99 - this is ReStructuredText enclosed between the r""" and """ delimiters 86 100 at the top of the *.py* file 101 - what you write here is abstracted into the SasView help documentation 102 - this is what other users will refer to when they want to know what your model does; 103 so please be helpful! 87 104 88 105 - a **definition** of the model: … … 97 114 98 115 - a **plot** of the function, with a **figure caption**: 99 - this is automatically generated from thedefault parameters116 - this is automatically generated from your default parameters 100 117 101 118 - at least one **reference**: … … 107 124 - the *.py* file should also contain a comment identifying *who* 108 125 converted/created the model file 126 127 Models that do not conform to these requirements will *never* be incorporated 128 into the built-in library. 109 129 110 130 More complete documentation for the sasmodels package can be found at … … 170 190 171 191 The model should include a **formula** written using LaTeX markup. 172 The above example uses the *math* command to make a displayed equation. You192 The example above uses the *math* command to make a displayed equation. You 173 193 can also use *\$formula\$* for an inline formula. This is handy for defining 174 194 the relationship between the model parameters and formula variables, such 175 195 as the phrase "\$r\$ is the radius" used above. The live demo MathJax 176 196 page `<http://www.mathjax.org/>`_ is handy for checking that the equations 177 will look like you expect.197 will look like you intend. 178 198 179 199 Math layout uses the `amsmath <http://www.ams.org/publications/authors/tex/amslatex>`_ … … 207 227 208 228 name = "sphere" # optional: defaults to the filename without .py 229 209 230 title = "Spheres with uniform scattering length density" 231 210 232 description = """\ 211 233 P(q)=(scale/V)*[3V(sld-sld_solvent)*(sin(qr)-qr cos(qr)) … … 216 238 sld_solvent: the SLD of the solvent 217 239 """ 240 218 241 category = "shape:sphere" 242 219 243 single = True # optional: defaults to True 244 220 245 opencl = False # optional: defaults to False 246 221 247 structure_factor = False # optional: defaults to False 222 248 … … 229 255 **title = "short description"** is short description of the model which 230 256 is included after the model name in the automatically generated documentation. 231 The title can also be used for a tooltip , for example.257 The title can also be used for a tooltip. 232 258 233 259 **description = """doc string"""** is a longer description of the model. It 234 shows up when you press the "Description" button of the SasView fit page.260 shows up when you press the "Description" button of the SasView FitPage. 235 261 It should give a brief description of the equation and the parameters 236 262 without the need to read the entire model documentation. The triple quotes 237 263 allow you to write the description over multiple lines. Keep the lines 238 264 short since the GUI will wrap each one separately if they are too long. 239 **Make sure the parameter names in the description match the model definition .**265 **Make sure the parameter names in the description match the model definition!** 240 266 241 267 **category = "shape:sphere"** defines where the model will appear in the 242 268 model documentation. In this example, the model will appear alphabetically 243 in the list of spheroid models .269 in the list of spheroid models in the *Shape* category. 244 270 245 271 **single = True** indicates that the model can be run using single … … 275 301 ["radius", "Ang", 50, [0, inf], "volume", "Sphere radius"], 276 302 ] 277 # pylint: disable=bad-whitespace, line-too-long303 # pylint: enable=bad-whitespace, line-too-long 278 304 279 305 **parameters = [["name", "units", default, [min,max], "type", "tooltip"],...]** 280 defines the parameters form the model. 281 282 - **the order of the parameters in the definition will be the order of 283 the parameters in the user interface and the order of the parameters 284 in Iq(), Iqxy() and form_volume().** 285 286 - **scale and background parameters are implicit to all models, so 287 they do not need to be included in the parameter table** 288 289 - **"name"** is the name of the parameter shown on the fit screen 306 defines the parameters that form the model. 307 308 **Note: The order of the parameters in the definition will be the order of the 309 parameters in the user interface and the order of the parameters in Iq(), 310 Iqxy() and form_volume(). And** *scale* **and** *background* **parameters are 311 implicit to all models, so they do not need to be included in the parameter table.** 312 313 - **"name"** is the name of the parameter shown on the FitPage. 290 314 291 315 - parameter names should follow the mathematical convention; e.g., 292 *radius_core* not *core_radius*, or *sld_solvent* not *solvent_sld* 316 *radius_core* not *core_radius*, or *sld_solvent* not *solvent_sld*. 317 293 318 - model parameter names should be consistent between different models, 294 319 so *sld_solvent*, for example, should have exactly the same name 295 in every model 320 in every model. 321 296 322 - to see all the parameter names currently in use, type the following in the 297 323 python shell/editor under the Tools menu:: … … 301 327 302 328 *re-use* as many as possible!!! 329 303 330 - use "name[n]" for multiplicity parameters, where *n* is the name of 304 331 the parameter defining the number of shells/layers/segments, etc. … … 306 333 - **"units"** are displayed along with the parameter name 307 334 308 - every parameter should have units; use "None" if there are no units 335 - every parameter should have units; use "None" if there are no units. 336 309 337 - **sld's should be given in units of 1e-6/Ang^2, and not simply 310 338 1/Ang^2 to be consistent with the builtin models. Adjust your formulas 311 339 appropriately.** 340 312 341 - fancy units markup is available for some units, including:: 313 342 … … 322 351 and using negative exponents instead of the / operator, though 323 352 the unit name should use the / operator for consistency. 324 - p ost a message to the sasview developers list with the changes325 326 - **default** is the initial value for the parameter 353 - please post a message to the SasView developers mailing list with your changes. 354 355 - **default** is the initial value for the parameter. 327 356 328 357 - **the parameter default values are used to auto-generate a plot of 329 358 the model function in the documentation.** 330 359 331 - **[min, max]** are the lower and upper limits on the parameter 332 333 - lower and upper limits can be any number, or -inf or inf. 360 - **[min, max]** are the lower and upper limits on the parameter. 361 362 - lower and upper limits can be any number, or *-inf* or *inf*. 363 334 364 - the limits will show up as the default limits for the fit making it easy, 335 365 for example, to force the radius to always be greater than zero. 336 366 337 - **"type"** can be one of: "", "sld", "volume", or "orientation" 367 - these are hard limits defining the valid range of parameter values; 368 polydisperity distributions will be truncated at the limits. 369 370 - **"type"** can be one of: "", "sld", "volume", or "orientation". 338 371 339 372 - "sld" parameters can have magnetic moments when fitting magnetic models; 340 373 depending on the spin polarization of the beam and the $q$ value being 341 374 examined, the effective sld for that material will be used to compute the 342 scattered intensity 375 scattered intensity. 376 343 377 - "volume" parameters are passed to Iq(), Iqxy(), and form_volume(), and 344 378 have polydispersity loops generated automatically. 379 345 380 - "orientation" parameters are only passed to Iqxy(), and have angular 346 381 dispersion. … … 380 415 ............. 381 416 382 For pure python models, define the Iq funtion::417 For pure python models, define the *Iq* function:: 383 418 384 419 import numpy as np … … 391 426 The parameters *par1, par2, ...* are the list of non-orientation parameters 392 427 to the model in the order that they appear in the parameter table. 393 **Note that the autogenerated model file uses *x* rather than *q*.**428 **Note that the autogenerated model file uses** *x* **rather than** *q*. 394 429 395 430 The *.py* file should import trigonometric and exponential functions from 396 numpy rather tha tfrom math. This lets us evaluate the model for the whole431 numpy rather than from math. This lets us evaluate the model for the whole 397 432 range of $q$ values at once rather than looping over each $q$ separately in 398 433 python. With $q$ as a vector, you cannot use if statements, but must instead … … 430 465 list includes the *volume* parameters in order. This is used for a weighted 431 466 volume normalization so that scattering is on an absolute scale. If 432 *form_volume* is not defin ded, then the default *form_volume = 1.0* will be467 *form_volume* is not defined, then the default *form_volume = 1.0* will be 433 468 used. 434 469 … … 436 471 ................. 437 472 438 Like pure python models, inline C models need define an *Iq* function::473 Like pure python models, inline C models need to define an *Iq* function:: 439 474 440 475 Iq = """ … … 451 486 } 452 487 453 The C model operates on a single $q$ value at a time. The code will be454 run in parallel across different $q$ values, either on the graphics card455 or the processor.456 457 Rather than returning NAN from Iq, you must define the *INVALID(v)*. The458 *v* parameter lets you access all the parameters in the model using459 *v.par1*, *v.par2*, etc. For example::460 461 #define INVALID(v) (v.bell_radius < v.radius)462 463 488 *Iqxy* is similar to *Iq*, except it uses parameters *qx, qy* instead of *q*, 464 and it includes orientation parameters. As in python models, *form_volume* 465 includes only the volume parameters. *Iqxy* will default to 466 *Iq(sqrt(qx**2 + qy**2), par1, ...)* and *form_volume* will default to 1.0. 467 468 The C code follows the C99 standard, including the usual math functions, 469 as defined in 470 `OpenCL <https://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/mathFunctions.html>`_. 471 472 The standard constants and functions include the following:: 473 474 M_PI = pi 475 M_PI_2 = pi/2 476 M_PI_4 = pi/4 477 M_E = e 478 M_SQRT1_2 = 1/sqrt(2) 479 NAN = NaN 480 INFINITY = 1/0 481 erf(x) = error function 482 erfc(x) = 1-erf(x) 483 expm1(x) = exp(x) - 1 484 tgamma(x) = gamma function 485 486 Some non-standard constants and functions are also provided:: 487 488 M_PI_180 = pi/180 489 M_4PI_3 = 4pi/3 490 square(x) = x*x 491 cube(x) = x*x*x 492 sinc(x) = sin(x)/x, with sin(0)/0 -> 1 493 SINCOS(x, s, c) sets s=sin(angle) and c=cos(angle) 494 powr(x, y) = x^y for x >= 0 495 pown(x, n) = x^n for n integer 496 497 **source=['lib/fn.c', ...]** includes the listed C source files in the 489 and it includes orientation parameters. 490 491 *form_volume* defines the volume of the shape. As in python models, it 492 includes only the volume parameters. 493 494 *Iqxy* will default to *Iq(sqrt(qx**2 + qy**2), par1, ...)* and 495 *form_volume* will default to 1.0. 496 497 **source=['fn.c', ...]** includes the listed C source files in the 498 498 program before *Iq* and *Iqxy* are defined. This allows you to extend the 499 library of available C functions. Additional special functions and 500 scattering calculations are defined in 501 `sasmodels/models/lib <https://github.com/SasView/sasmodels/tree/master/sasmodels/models/lib>`_, 502 including:: 503 504 sph_j1c(x) = 3 j1(x)/x = 3 (sin(x) - x cos(x))/x^3 [spherical bessel function] 505 sas_J1c(x) = 2 J1(x)/x [bessel function of the first kind] 506 sas_gamma(x) = gamma function [tgamma is unstable below 1] 507 sas_erf(x) = error function [erf is broken on some Intel OpenCL drivers] 508 sas_erfc(x) = 1-erf(x) 509 sas_J0(x) = J0(x) 510 sas_J1(x) = J1(x) 511 sas_JN(x) = JN(x) 512 Si(x) = integral sin(z)/z from 0 to x 513 Gauss76Wt = gaussian quadrature weights for 76 point integral 514 Gauss76Z = gaussian quadrature values for 76 point integral 515 516 These functions have been tuned to be fast and numerically stable down 517 to $q=0$ even in single precision. In some cases they work around bugs 518 which appear on some platforms but not others. 499 library of C functions available to your model. 519 500 520 501 Models are defined using double precision declarations for the 521 parameters and return values. Declarations and constants will be converted 522 to float or long double depending on the precision requested. 502 parameters and return values. When a model is run using single 503 precision or long double precision, each variable is converted 504 to the target type, depending on the precision requested. 505 523 506 **Floating point constants must include the decimal point.** This allows us 524 507 to convert values such as 1.0 (double precision) to 1.0f (single precision) … … 529 512 use the builtin constant M_PI rather than 4*atan(1); it is faster and smaller! 530 513 531 FLOAT_SIZE is the number of bytes in the converted variables. If your 532 algorithm depends on precision (which is not uncommon for numerical 533 algorithms), use the following:: 534 535 #if FLOAT_SIZE>4 536 ... code for double precision ... 537 #else 538 ... code for single precision ... 539 #endif 540 541 A value defined as SAS_DOUBLE will stay double precision; this should 542 not be used since some graphics card don't support double precision. 543 514 The C model operates on a single $q$ value at a time. The code will be 515 run in parallel across different $q$ values, either on the graphics card 516 or the processor. 517 518 Rather than returning NAN from Iq, you must define the *INVALID(v)*. The 519 *v* parameter lets you access all the parameters in the model using 520 *v.par1*, *v.par2*, etc. For example:: 521 522 #define INVALID(v) (v.bell_radius < v.radius) 523 524 Special Functions 525 ................. 526 527 The C code follows the C99 standard, with the usual math functions, 528 as defined in 529 `OpenCL <https://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/mathFunctions.html>`_. 530 This includes the following: 531 532 M_PI, M_PI_2, M_PI_4, M_SQRT1_2, M_E: 533 $\pi$, $\pi/2$, $\pi/4$, $1/\sqrt{2}$ and Euler's constant $e$ 534 exp, log, pow(x,y), expm1, sqrt: 535 Power functions $e^x$, $\ln x$, $x^y$, $e^x - 1$, $\sqrt{x}$. 536 The function expm1(x) is accurate across all $x$, including $x$ 537 very close to zero. 538 sin, cos, tan, asin, acos, atan: 539 Trigonometry functions and inverses, operating on radians. 540 sinh, cos, tanh, asinh, acosh, atanh: 541 Hyperbolic trigonometry functions. 542 atan2(y,x): 543 Angle from the $x$\ -axis to the point $(x,y)$, which is equal to 544 $\tan^{-1}(y/x)$ corrected for quadrant. That is, if $x$ and $y$ are 545 both negative, then atan2(y,x) returns a value in quadrant III where 546 atan(y/x) would return a value in quadrant I. Similarly for 547 quadrants II and IV when $x$ and $y$ have opposite sign. 548 fmin(x,y), fmax(x,y), trunc, rint: 549 Floating point functions. rint(x) returns the nearest integer. 550 NAN: 551 NaN, Not a Number, $0/0$. Use isnan(x) to test for NaN. Note that 552 you cannot use :code:`x == NAN` to test for NaN values since that 553 will always return false. NAN does not equal NAN! 554 INFINITY: 555 $\infty, 1/0$. Use isinf(x) to test for infinity, or isfinite(x) 556 to test for finite and not NaN. 557 erf, erfc, tgamma, lgamma: **do not use** 558 Special functions that should be part of the standard, but are missing 559 or inaccurate on some platforms. Use sas_erf, sas_erfc and sas_gamma 560 instead (see below). Note: lgamma(x) has not yet been tested. 561 562 Some non-standard constants and functions are also provided: 563 564 M_PI_180, M_4PI_3: 565 $\frac{\pi}{180}$, $\frac{4\pi}{3}$ 566 SINCOS(x, s, c): 567 Macro which sets s=sin(x) and c=cos(x). The variables *c* and *s* 568 must be declared first. 569 square(x): 570 $x^2$ 571 cube(x): 572 $x^3$ 573 sas_sinx_x(x): 574 $\sin(x)/x$, with limit $\sin(0)/0 = 1$. 575 powr(x, y): 576 $x^y$ for $x \ge 0$; this is faster than general $x^y$ on some GPUs. 577 pown(x, n): 578 $x^n$ for $n$ integer; this is faster than general $x^n$ on some GPUs. 579 FLOAT_SIZE: 580 The number of bytes in a floating point value. Even though all 581 variables are declared double, they may be converted to single 582 precision float before running. If your algorithm depends on 583 precision (which is not uncommon for numerical algorithms), use 584 the following:: 585 586 #if FLOAT_SIZE>4 587 ... code for double precision ... 588 #else 589 ... code for single precision ... 590 #endif 591 SAS_DOUBLE: 592 A replacement for :code:`double` so that the declared variable will 593 stay double precision; this should generally not be used since some 594 graphics cards do not support double precision. There is no provision 595 for forcing a constant to stay double precision. 596 597 The following special functions and scattering calculations are defined in 598 `sasmodels/models/lib <https://github.com/SasView/sasmodels/tree/master/sasmodels/models/lib>`_. 599 These functions have been tuned to be fast and numerically stable down 600 to $q=0$ even in single precision. In some cases they work around bugs 601 which appear on some platforms but not others, so use them where needed. 602 Add the files listed in :code:`source = ["lib/file.c", ...]` to your *model.py* 603 file in the order given, otherwise these functions will not be available. 604 605 polevl(x, c, n): 606 Polynomial evaluation $p(x) = \sum_{i=0}^n c_i x^i$ using Horner's 607 method so it is faster and more accurate. 608 609 $c = \{c_n, c_{n-1}, \ldots, c_0 \}$ is the table of coefficients, 610 sorted from highest to lowest. 611 612 :code:`source = ["lib/polevl.c", ...]` (`link to code <https://github.com/SasView/sasmodels/tree/master/sasmodels/models/lib/polevl.c>`_) 613 614 p1evl(x, c, n): 615 Evaluation of normalized polynomial $p(x) = x^n + \sum_{i=0}^{n-1} c_i x^i$ 616 using Horner's method so it is faster and more accurate. 617 618 $c = \{c_{n-1}, c_{n-2} \ldots, c_0 \}$ is the table of coefficients, 619 sorted from highest to lowest. 620 621 :code:`source = ["lib/polevl.c", ...]` 622 (`link to code <https://github.com/SasView/sasmodels/tree/master/sasmodels/models/lib/polevl.c>`_) 623 624 sas_gamma(x): 625 Gamma function $\text{sas_gamma}(x) = \Gamma(x)$. 626 627 The standard math function, tgamma(x) is unstable for $x < 1$ 628 on some platforms. 629 630 :code:`source = ["lib/sasgamma.c", ...]` 631 (`link to code <https://github.com/SasView/sasmodels/tree/master/sasmodels/models/lib/sas_gamma.c>`_) 632 633 sas_erf(x), sas_erfc(x): 634 Error function 635 $\text{sas_erf}(x) = \frac{2}{\sqrt\pi}\int_0^x e^{-t^2}\,dt$ 636 and complementary error function 637 $\text{sas_erfc}(x) = \frac{2}{\sqrt\pi}\int_x^{\infty} e^{-t^2}\,dt$. 638 639 The standard math functions erf(x) and erfc(x) are slower and broken 640 on some platforms. 641 642 :code:`source = ["lib/polevl.c", "lib/sas_erf.c", ...]` 643 (`link to error functions' code <https://github.com/SasView/sasmodels/tree/master/sasmodels/models/lib/sas_erf.c>`_) 644 645 sas_J0(x): 646 Bessel function of the first kind $\text{sas_J0}(x)=J_0(x)$ where 647 $J_0(x) = \frac{1}{\pi}\int_0^\pi \cos(x\sin(\tau))\,d\tau$. 648 649 The standard math function j0(x) is not available on all platforms. 650 651 :code:`source = ["lib/polevl.c", "lib/sas_J0.c", ...]` 652 (`link to Bessel function's code <https://github.com/SasView/sasmodels/tree/master/sasmodels/models/lib/sas_J0.c>`_) 653 654 sas_J1(x): 655 Bessel function of the first kind $\text{sas_J1}(x)=J_1(x)$ where 656 $J_1(x) = \frac{1}{\pi}\int_0^\pi \cos(\tau - x\sin(\tau))\,d\tau$. 657 658 The standard math function j1(x) is not available on all platforms. 659 660 :code:`source = ["lib/polevl.c", "lib/sas_J1.c", ...]` 661 (`link to Bessel function's code <https://github.com/SasView/sasmodels/tree/master/sasmodels/models/lib/sas_J1.c>`_) 662 663 sas_JN(n, x): 664 Bessel function of the first kind and integer order $n$: 665 $\text{sas_JN}(n, x)=J_n(x)$ where 666 $J_n(x) = \frac{1}{\pi}\int_0^\pi \cos(n\tau - x\sin(\tau))\,d\tau$. 667 If $n$ = 0 or 1, it uses sas_J0(x) or sas_J1(x), respectively. 668 669 The standard math function jn(n, x) is not available on all platforms. 670 671 :code:`source = ["lib/polevl.c", "lib/sas_J0.c", "lib/sas_J1.c", "lib/sas_JN.c", ...]` 672 (`link to Bessel function's code <https://github.com/SasView/sasmodels/tree/master/sasmodels/models/lib/sas_JN.c>`_) 673 674 sas_Si(x): 675 Sine integral $\text{Si}(x) = \int_0^x \tfrac{\sin t}{t}\,dt$. 676 677 This function uses Taylor series for small and large arguments: 678 679 For large arguments, 680 681 .. math:: 682 683 \text{Si}(x) \sim \frac{\pi}{2} 684 - \frac{\cos(x)}{x}\left(1 - \frac{2!}{x^2} + \frac{4!}{x^4} - \frac{6!}{x^6} \right) 685 - \frac{\sin(x)}{x}\left(\frac{1}{x} - \frac{3!}{x^3} + \frac{5!}{x^5} - \frac{7!}{x^7}\right) 686 687 For small arguments, 688 689 .. math:: 690 691 \text{Si}(x) \sim x 692 - \frac{x^3}{3\times 3!} + \frac{x^5}{5 \times 5!} - \frac{x^7}{7 \times 7!} 693 + \frac{x^9}{9\times 9!} - \frac{x^{11}}{11\times 11!} 694 695 :code:`source = ["lib/Si.c", ...]` 696 (`link to code <https://github.com/SasView/sasmodels/tree/master/sasmodels/models/lib/Si.c>`_) 697 698 sas_3j1x_x(x): 699 Spherical Bessel form 700 $\text{sph_j1c}(x) = 3 j_1(x)/x = 3 (\sin(x) - x \cos(x))/x^3$, 701 with a limiting value of 1 at $x=0$, where $j_1(x)$ is the spherical 702 Bessel function of the first kind and first order. 703 704 This function uses a Taylor series for small $x$ for numerical accuracy. 705 706 :code:`source = ["lib/sas_3j1x_x.c", ...]` 707 (`link to code <https://github.com/SasView/sasmodels/tree/master/sasmodels/models/lib/sas_3j1x_x.c>`_) 708 709 710 sas_2J1x_x(x): 711 Bessel form $\text{sas_J1c}(x) = 2 J_1(x)/x$, with a limiting value 712 of 1 at $x=0$, where $J_1(x)$ is the Bessel function of first kind 713 and first order. 714 715 :code:`source = ["lib/polevl.c", "lib/sas_J1.c", ...]` 716 (`link to Bessel form's code <https://github.com/SasView/sasmodels/tree/master/sasmodels/models/lib/sas_J1.c>`_) 717 718 719 Gauss76Z[i], Gauss76Wt[i]: 720 Points $z_i$ and weights $w_i$ for 76-point Gaussian quadrature, respectively, 721 computing $\int_{-1}^1 f(z)\,dz \approx \sum_{i=1}^{76} w_i\,f(z_i)$. 722 723 Similar arrays are available in :code:`gauss20.c` for 20-point 724 quadrature and in :code:`gauss150.c` for 150-point quadrature. 725 726 :code:`source = ["lib/gauss76.c", ...]` 727 (`link to code <https://github.com/SasView/sasmodels/tree/master/sasmodels/models/lib/gauss76.c>`_) 728 729 730 731 Problems with C models 732 ...................... 733 734 The graphics processor (GPU) in your computer is a specialized computer tuned 735 for certain kinds of problems. This leads to strange restrictions that you 736 need to be aware of. Your code may work fine on some platforms or for some 737 models, but then return bad values on other platforms. Some examples of 738 particular problems: 739 740 **(1) Code is too complex, or uses too much memory.** GPU devices only have a 741 limited amount of memory available for each processor. If you run programs 742 which take too much memory, then rather than running multiple values in parallel 743 as it usually does, the GPU may only run a single version of the code at a 744 time, making it slower than running on the CPU. It may fail to run on 745 some platforms, or worse, cause the screen to go blank or the system to reboot. 746 747 **(2) Code takes too long.** Because GPU devices are used for the computer 748 display, the OpenCL drivers are very careful about the amount of time they 749 will allow any code to run. For example, on OS X, the model will stop running 750 after 5 seconds regardless of whether the computation is complete. You may end up 751 with only some of your 2D array defined, with the rest containing random 752 data. Or it may cause the screen to go blank or the system to reboot. 753 754 **(3) Memory is not aligned**. The GPU hardware is specialized to operate on 755 multiple values simultaneously. To keep the GPU simple the values in memory 756 must be aligned with the different GPU compute engines. Not following these 757 rules can lead to unexpected values being loaded into memory, and wrong answers 758 computed. The conclusion from a very long and strange debugging session was 759 that any arrays that you declare in your model should be a multiple of four. 760 For example:: 761 762 double Iq(q, p1, p2, ...) 763 { 764 double vector[8]; // Only going to use seven slots, but declare 8 765 ... 766 } 767 768 The first step when your model is behaving strangely is to set **single=False**. 769 This automatically restricts the model to only run on the CPU, or on high-end 770 GPU cards. There can still be problems even on high-end cards, so you can force 771 the model off the GPU by setting **opencl=False**. This runs the model 772 as a normal C program without any GPU restrictions so you know that 773 strange results are probably from your code rather than the environment. Once 774 the code is debugged, you can compare your output to the output on the GPU. 775 776 Although it can be difficult to get your model to work on the GPU, the reward 777 can be a model that runs 1000x faster on a good card. Even your laptop may 778 show a 50x improvement or more over the equivalent pure python model. 544 779 545 780 External C Models … … 548 783 External C models are very much like embedded C models, except that 549 784 *Iq*, *Iqxy* and *form_volume* are defined in an external source file 550 loaded using the *source=[...]* method. You need to supply the function785 loaded using the *source=[...]* statement. You need to supply the function 551 786 declarations for each of these that you need instead of building them 552 787 automatically from the parameter table. … … 557 792 Form Factors 558 793 ............ 559 560 ::561 562 def ER(radius, thickness):563 """Effective radius of a core-shell sphere."""564 return radius + thickness565 794 566 795 Away from the dilute limit you can estimate scattering including … … 572 801 form averaged over all the polydispersity values. 573 802 574 Consider the *core_shell_sphere*, which has a simple effective radius 803 :: 804 805 def ER(radius, thickness): 806 """Effective radius of a core-shell sphere.""" 807 return radius + thickness 808 809 Now consider the *core_shell_sphere*, which has a simple effective radius 575 810 equal to the radius of the core plus the thickness of the shell, as 576 811 shown above. Given polydispersity over *(r1, r2, ..., rm)* in radius and … … 597 832 one return value for each point in the mesh grid. 598 833 599 *NOTE: we may be removing or modifying this feature soon. * As of this600 writing, core-shell sphere returns (1., 1.) for *VR*, giving a volume601 ratio of 1.0. 834 *NOTE: we may be removing or modifying this feature soon. As of the 835 time of writing, core-shell sphere returns (1., 1.) for VR, giving a volume 836 ratio of 1.0.* 602 837 603 838 Unit Tests … … 624 859 - a dictionary of parameter values. This can be {} using the default 625 860 parameters, or filled with some parameters that will be different 626 from the default, such as { âradiusâ:10.0, âsldâ:4}. Unlisted parameters861 from the default, such as {ââ¬Ëradiusââ¬â¢:10.0, ââ¬Ësldââ¬â¢:4}. Unlisted parameters 627 862 will be given the default values. 628 863 - the input $q$ value or tuple of $(q_x, q_y)$ values. … … 640 875 ^^^^^^^^^^^^^^^^^^^ 641 876 642 If you are editing your model from the SasView GUI, you can test it 643 by selecting *Run -> Compile* from the *Model Editor* menu bar. An 644 *Info* box will appear with the results of the compilation and a 645 check that the model runs. 877 Minimal Testing 878 ............... 879 880 Either open the :ref:`Python_shell` (*Tools* > *Python Shell/Editor*) or the :ref:`Advanced_Plugin_Editor` (*Fitting* > *Plugin Model Operations* > *Advanced 881 Plugin Editor*), load your model, and then select *Run > Check Model* from the 882 menu bar. 883 884 An *Info* box will appear with the results of the compilation and a check that 885 the model runs. 886 887 Recommended Testing 888 ................... 646 889 647 890 If the model compiles and runs, you can next run the unit tests that 648 you have added using the **test =** values. Switch to the *Shell* tab891 you have added using the **test =** values. Switch to the *Shell* tab 649 892 and type the following:: 650 893 … … 686 929 For the random models, 687 930 688 - sld will be in(-0.5,10.5),689 - angles ( theta, phi, psi) will be in(-180,180),690 - angular dispersion will be in (0,45),691 - polydispersity will be in (0,1)692 - other values will be in (0, 2*v) where vis the value of the parameter in demo.693 694 Dispersion parameters n, sigma and typewill be unchanged from demo so that931 - *sld* will be in the range (-0.5,10.5), 932 - angles (*theta, phi, psi*) will be in the range (-180,180), 933 - angular dispersion will be in the range (0,45), 934 - polydispersity will be in the range (0,1) 935 - other values will be in the range (0, 2\ *v*), where *v* is the value of the parameter in demo. 936 937 Dispersion parameters *n*\, *sigma* and *type* will be unchanged from demo so that 695 938 run times are predictable. 696 939 … … 701 944 702 945 703 Clean Lint 704 ^^^^^^^^^^ 705 706 **NB: For now we are not providing pylint with SasView; unless you have a707 SasView development environment available, you can ignore this section.**946 Clean Lint - (Developer Version Only) 947 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 948 949 **NB: For now we are not providing pylint with the installer version of SasView; 950 so unless you have a SasView build environment available, you can ignore this section!** 708 951 709 952 Run the lint check with:: … … 717 960 for standard model functions *Iq*, *Iqxy*, etc. 718 961 719 We will have delinting sessions at the SasView code camps, where we can962 We will have delinting sessions at the SasView Code Camps, where we can 720 963 decide on standards for model files, parameter names, etc. 721 964 722 For now, you can tell pylint to ignore things. For example, to align you 965 For now, you can tell pylint to ignore things. For example, to align your 723 966 parameters in blocks:: 724 967 … … 738 981 Don't put in too many pylint statements, though, since they make the code ugly. 739 982 740 Check The Docs 741 ^^^^^^^^^^^^^^ 983 Check The Docs - (Developer Version Only) 984 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 742 985 743 986 You can get a rough idea of how the documentation will look using the … … 756 999 - `amsmath <http://www.ams.org/publications/authors/tex/amslatex>`_ 757 1000 758 Finally 759 ^^^^^^^ 1001 There is also a neat online WYSIWYG ReStructuredText editor at http://rst.ninjs.org\ . 1002 1003 Share Your Model! 1004 ^^^^^^^^^^^^^^^^^ 760 1005 761 1006 Once compare and the unit test(s) pass properly and everything is done, 762 1007 consider adding your model to the 763 `model marketplace <http://marketplace.sasview.org/>`_. 764 1008 `Model Marketplace <http://marketplace.sasview.org/>`_ so that others may use it! 1009 1010 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 1011 1012 .. note:: This help document was last changed by Steve King, 25Oct2016 -
src/sas/sasgui/perspectives/fitting/media/sm_help.rst
r7805458 r27aabc1 20 20 ================== 21 21 22 Sometimes it will be necessary to correct reduced experimental data for the 23 physical effects of the instrumental geometry in use. This process is called 24 *desmearing*. However, calculated/simulated data - which by definition will be 25 perfect/exact - can be *smeared* to make it more representative of what might 26 actually be measured experimentally. 27 28 SasView provides the following three smearing algorithms: 22 Sometimes the instrumental geometry used to acquire the experimental data has 23 an impact on the clarity of features in the reduced scattering curve. For 24 example, peaks or fringes might be slightly broadened. This is known as 25 *Q resolution smearing*. To compensate for this effect one can either try and 26 remove the resolution contribution - a process called *desmearing* - or add the 27 resolution contribution into a model calculation/simulation (which by definition 28 will be exact) to make it more representative of what has been measured 29 experimentally - a process called *smearing*. SasView will do the latter. 30 31 Both smearing and desmearing rely on functions to describe the resolution 32 effect. SasView provides three smearing algorithms: 29 33 30 34 * *Slit Smearing* 31 35 * *Pinhole Smearing* 32 36 * *2D Smearing* 37 38 SasView also has an option to use Q resolution data (estimated at the time of 39 data reduction) supplied in a reduced data file: the *Use dQ data* radio button. 40 41 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 42 43 dQ Smearing 44 ----------- 45 46 If this option is checked, SasView will assume that the supplied dQ values 47 represent the standard deviations of Gaussian functions. 33 48 34 49 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
Note: See TracChangeset
for help on using the changeset viewer.