24 | | - model documentation. The .py starts with an r (for raw) and three sets of quotes to start the doc string and ends with a second set of 3 quotes. This is where the FULL documentation for the model goes (to be picked up by sphinx). Paste the model documentation from the appropriate section of model_functions.rst (found at [https://github.com/SasView/sasview/blob/master/src/sas/models/media/model_functions.rst src/sas/models/media/model_functions.rst]) here. For example, for the !BarBellModel, search for !BarBellModel in the rst file then copy everything after the *2.x.x. !ModelNameModel!**. Edit the result as follows: |
25 | | - the *2.x.x.x Model!** section with its brief description of the model becomes the model title; it feels odd that the documentation string does not start with name and brief description but it is automatically added by the model loader |
26 | | - replace *2.x.x.x. Definition!** with Definition followed by a line of 10 dashes. |
27 | | - wherever possible try to replace images of math functions with Latex. you can use the live demo Mathjax page (http://www.mathjax.org/) to make sure the equation looks as expected. also a lot of the Latex code can be taken from (or edited) from the PDF document created by Paul Kienzle: http://sasview.org/attachment/wiki/SasModels%20Work%20Package/Equations.docx.pdf. |
28 | | - remove the table of parameters which will get autogenerated |
29 | | - copy the figures from the sasview/src/sas/models/media/img subdirectory to the sasmodels/sasmodels/models/img subdirectory |
30 | | - figure captions should be indented relative to the ..image:: tag. This allows us to for example change the font of the caption through CSS. |
31 | | - remove the figure number since this will be generated automatically for the caption. |
| 26 | - **MODEL DOCUMENTATION** |
| 27 | - **doc string**. The .py starts with an r (for raw) and three sets of quotes to start the doc string and ends with a second set of 3 quotes. This is where the FULL documentation for the model goes (to be picked up by Sphinx). Paste the model documentation from the appropriate section of model_functions.rst (found at [https://github.com/SasView/sasview/blob/master/src/sas/models/media/model_functions.rst src/sas/models/media/model_functions.rst]) here. DO NOT use the old html documentation. For example, for the !BarBellModel, search for !BarBellModel in the rst file then copy everything after the *2.x.x. !ModelNameModel!**. Then edit the result as follows: |
| 28 | - the *2.x.x.x Model!** section with its brief description of the model becomes the model title; it feels odd that the documentation string does not start with name and brief description but it is automatically added by the model loader. |
| 29 | - replace *2.x.x.x. Definition!** with just Definition followed by 10 dashes on the line below. |
| 30 | - wherever possible, try to replace images of math functions with Latex equivalents. You can use the live demo Mathjax page ([http://www.mathjax.org/]) to make sure the equation looks as expected. Also a lot of the Latex code can be taken from (or edited) from the PDF document created by Paul Kienzle: [http://sasview.org/attachment/wiki/SasModels%20Work%20Package/Equations.docx.pdf]. |
| 31 | - remove the table of parameters which will get autogenerated. |
| 32 | - copy non-math figures from the sasview/src/sas/models/media/img subdirectory to the sasmodels/sasmodels/models/img subdirectory and rename them to something sensible. For example, image183.jpg became power_law_1d.jpg. |
| 33 | - figure captions should be indented relative to the ..image:: tag. This allows us to, for example, change the font of the caption through CSS. |
| 34 | - remove the figure number since this will be generated automatically. |
33 | | - name = "mymodel". This is the name of the model that is shown to the user. Use the name of the file as described above in 1. There will be less confusion if the model name matches the file name, but they could be different. |
34 | | - title = "short description". This is a new value to be used for tooltip for example. It can probably be pulled directly from the model_functions.rst file. |
35 | | - description = """doc string""". Cut and paste the self.description string from the !SasView model header in [https://github.com/SasView/sasview/tree/master/src/sas/models/include src/sas/models/include]. This gives a brief description of the equation and the parameters without the need to read the entire model documentation. Make sure the parameter names match the current model definition. |
36 | | - parameters = [["name", "units", default, [min,max], "type", "tooltip"],...]. This is where the parameters get defined. The syntax should be obvious from the default. Copy the parameters from the model header file [https://github.com/SasView/sasview/tree/master/src/sas/models/include src/sas/models/include] |
37 | | - PARAMETER NAMES: VERY IMPORTANT. We are trying to make the model parameter more consistent between models. So solvent sld for example should have exactly the same name in every model. Current list of new parameters is: |
38 | | - radius = radius |
39 | | - sld = scattering length density of particle |
40 | | - solvent_sld = scattering length density of matrix |
41 | | - cor_length = correlation length |
42 | | - exp = exponent (example: porod_exp) |
43 | | - peak_pos = q_peak or q0 etc |
44 | | - theta = axis_theta, phi = axis_phi |
45 | | - add more as you see them |
46 | | - NOTE: There is no need to specify 'scale' or 'background', these are implicit to all models. |
47 | | - lower and upper limits can be any number or -inf or inf |
48 | | - add limits where required; the sasview models don't usually define them |
49 | | - the limits will show up as the default limits for the fit, making it easy for example to force the radius to always be greater than zero. |
50 | | - type can take 3 values at this time: “”, “volume”, or “orientation” |
51 | | - "volume" parameters are passed to Iq(), Iqxy(), and form_volume(), and have polydispersity loops generated automatically |
| 36 | - **name = "mymodel".** This is the name of the model that is shown to the user. Use the name of the file as described above in 1. There will be less confusion if the model name matches the file name, but they could be different. |
| 37 | - **title = "short description".** This is a new string to be used for a tooltip, for example. It can probably be pulled directly from the model_functions.rst file. |
| 38 | - **description = """doc string""".** Cut and paste the self.description string from the (old) !SasView model header in [https://github.com/SasView/sasview/tree/master/src/sas/models/include src/sas/models/include]. This gives a brief description of the equation and the parameters without the need to read the entire model documentation. ''Make sure the parameter names match the current model definition.'' |
| 39 | - **PARAMETERS** |
| 40 | - **parameters = [["name", "units", default, [min,max], "type", "tooltip"],...].** This is where the parameters get defined. The syntax should be obvious from the default. Copy the parameters from the model header file [https://github.com/SasView/sasview/tree/master/src/sas/models/include src/sas/models/include]. |
| 41 | - ''the order of the parameters in the definition will be the order of the parameters in the user interface and the order of the parameters in Iq(), Iqxy() and form_volume().'' |
| 42 | - VERY IMPORTANT: We are trying to make the model parameters more consistent between models. So solvent_sld, for example, should have exactly the same name in every model. ''The current list of new parameters is:'' |
| 43 | - ''radius'' = radius |
| 44 | - ''sld'' = scattering length density of particle |
| 45 | - ''solvent_sld'' = scattering length density of matrix |
| 46 | - ''cor_length'' = correlation length |
| 47 | - ''exp'' = exponent (example: porod_exp) |
| 48 | - ''peak_pos'' = q_peak or q0 etc |
| 49 | - ''theta'' = axis_theta, phi = axis_phi |
| 50 | - add more as you generate them! |
| 51 | - **''NOTE: There is no need to specify 'scale' or 'background', these are implicit to all models.''** |
| 52 | - lower and upper limits can be any number, or -inf or inf. |
| 53 | - add limits where required the (old) sasview models don't usually define them. |
| 54 | - the limits will show up as the default limits for the fit making it easy, for example, to force the radius to always be greater than zero. |
| 55 | - "type" can take 3 values at this time: “”, “volume”, or “orientation”. |
| 56 | - "volume" parameters are passed to Iq(), Iqxy(), and form_volume(), and have polydispersity loops generated automatically. |
71 | | - the c file must contain the form_volume, Iq, Iqxy methods. These and any other functions defined (e.g. the _cyl() helper function) must be defined as doubles in the first lines of the file. |
72 | | - For certain models, such as those that can be multiplied by a structure factor, the ER attribute should be set to the Equivalent Radius (of a sphere). |
73 | | - For certain models, namely core shell type models, the VR attribute returns the volume ratio for the core-shell. |
74 | | - demo is a dictionary containing the value of each parameter as given in the rst documentation. Make sure to enter the appropriate values from that documentation. This will then be used to generate the example curve in said documentation. |
75 | | - include polydispersity parameters (e.g., radius_pd=0.2, radius_pd_n=9) so that you can compare the polydispersity calculations against those from sasview; use -mono on the compare.sh command line to see the direct calculation without polydispersity. |
76 | | - oldname is the name for this model used in !SasView. Make sure to put the correct original name. This is required for the transition to allow compatibility and to test that the models are equivalent. |
77 | | - oldpars is the name of the parameters as used in !SasView. For each parameter give the name of the parameter as used in the original !SasView code version of this model. Again this is required for the transition. |
78 | | - tests section (for unit test purposes) VERY IMPORTANT. Syntax: test is a list of lists. each list is one test and contains, in order, |
79 | | - a dictionary of parameter values. This can be {} using the default parameters, or filled with some parameters that will be different from the default ({‘radius’:10.0, ‘sld’:4}) unlisted parameters will be given the default values. |
80 | | - the input q value or tuple of qx, qy values |
81 | | - the output Iq or Iqxy expected of the model for the parameters and q value given |
82 | | - inputs and outputs can also be lists if you have several values to test for the same model parameters |
83 | | - for ER and VR, give the inputs as 'ER' and 'VR' respectively |
84 | | - include at least one test for each model. Please make sure that the answer value is correct (i.e. not a random number please) |
| 75 | - the c file must contain the form_volume, Iq, Iqxy methods. These and any other functions defined (e.g. the _cyl() helper function) must be defined as doubles in the first lines of the file. |
| 76 | - ''NOTE: for certain models, such as those that can be multiplied by a structure factor, the ER attribute should be set to the Equivalent Radius (of a sphere).'' |
| 77 | - ''NOTE: for certain models, namely core-shell type models, the VR attribute returns the volume ratio for the core-shell.'' |
| 78 | - **demo** is a dictionary containing the value of each parameter as given in the rst documentation. Make sure to enter the appropriate values from that documentation. This will then be used to generate the example curve in said documentation. |
| 79 | - include polydispersity parameters (e.g., radius_pd=0.2, radius_pd_n=9) so that you can compare the polydispersity calculations against those from sasview; use -mono on the compare.sh command line to see the direct calculation without polydispersity. |
| 80 | - **TRANSITION CHECKS** |
| 81 | - **oldname** is the name for this model used in !SasView. Make sure to put the correct original name. This is required for the transition to allow compatibility and to test that the models are equivalent. |
| 82 | - **oldpars** is the name of the parameters as used in !SasView. For each parameter give the name of the parameter as used in the original !SasView code version of this model. Again this is required for the transition. |
| 83 | - **UNIT TEST(S)** |
| 84 | - THESE ARE VERY IMPORTANT. Include at least one test for each model and PLEASE make sure that the answer value is correct (i.e. not a random number). |
| 85 | - **test** is a list of lists. Each list is one test and contains, in order: |
| 86 | - a dictionary of parameter values. This can be {} using the default parameters, or filled with some parameters that will be different from the default ({‘radius’:10.0, ‘sld’:4}). Unlisted parameters will be given the default values. |
| 87 | - the input q value or tuple of qx, qy values. |
| 88 | - the output Iq or Iqxy expected of the model for the parameters and q value given. |
| 89 | - inputs and outputs can also be lists if you have several values to test for the same model parameters. |
| 90 | - for ER and VR, give the inputs as 'ER' and 'VR' respectively. |