Changeset 9087214 in sasview for src/sas/sasgui/perspectives
- Timestamp:
- Oct 11, 2016 11:09:47 AM (8 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, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 4581ac9, 7949dcf7
- Parents:
- 392056d (diff), 46dfee9 (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
- Files:
-
- 9 added
- 1 deleted
- 14 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/calculator/gen_scatter_panel.py
rd0248bd r0f7c930 181 181 self.hint_sizer = wx.BoxSizer(wx.HORIZONTAL) 182 182 self.qrange_sizer = wx.BoxSizer(wx.HORIZONTAL) 183 self.button_sizer = wx.BoxSizer(wx.HORIZONTAL) 183 self.button_sizer = wx.BoxSizer(wx.VERTICAL) 184 self.button_sizer1 = wx.BoxSizer(wx.HORIZONTAL) 185 self.button_sizer2 = wx.BoxSizer(wx.HORIZONTAL) 184 186 185 187 def _layout_data_name(self): … … 392 394 self.bt_close.SetToolTipString("Close this window") 393 395 394 self.button_sizer .AddMany([(self.time_text, 0, wx.LEFT, 20),395 (self.orient_combo , 0, wx.LEFT, 20) ,396 (self.bt_compute, 0, wx.LEFT, 20),396 self.button_sizer1.AddMany([(self.bt_compute, 0, wx.LEFT, 20), 397 (self.orient_combo , 0, wx.LEFT, 20)]) 398 self.button_sizer2.AddMany([(self.time_text , 0, wx.LEFT, 20), 397 399 (self.bt_help, 0, wx.LEFT, 20), 398 (self.bt_close, 0, wx.LEFT, 5)]) 400 (self.bt_close, 0, wx.LEFT, 20)]) 401 self.button_sizer.AddMany([(self.button_sizer1 , 0, wx.BOTTOM|wx.LEFT, 10), 402 (self.button_sizer2 , 0, wx.LEFT, 10)]) 399 403 400 404 def estimate_ctime(self): … … 600 604 raise 601 605 self.orient_combo.Show(is_pdbdata) 602 self.button_sizer.Layout() 606 #self.button_sizer.Layout() 607 self.FitInside() 603 608 self._set_sld_data_helper(True) 604 609 except: -
src/sas/sasgui/perspectives/calculator/media/python_shell_help.rst
rd85c194 rafb93df 3 3 .. This is a port of the original SasView html help file to ReSTructured text 4 4 .. by S King, ISIS, during SasView CodeCamp-III in Feb 2015. 5 .. Text revised during Code Camp V in Oct 2016. 5 6 6 Python Shell Tool 7 ================= 7 .. _Python_shell: 8 9 Python Shell-Editor Tool 10 ======================== 8 11 9 12 Description 10 13 ----------- 11 14 12 This is a Python shell/editor (PyCrust) provided with WxPython. An editing 13 notebook will show up when a Python file is created/loaded with the *New* or 14 *Open* options on the menu. 15 This is a Python shell/editor provided with WxPython. 15 16 16 *Run* enables the editor to compile and run the Python code. 17 For the help about Python, visit the website http://docs.python.org/tutorial/ 17 18 18 For the details about the Python, visit the website http://docs.python.org/tutorial/ 19 .. note:: This shell/editor has its own help, but the Help() and Credits() calls do not work on Macs. 19 20 20 The NumPy, SciPy, and Matplotlib, etc, libraries are shipped with SasView. 21 However, some functionality may not work. 21 The NumPy, SciPy, and Matplotlib, etc, libraries are shipped with SasView and so functions from these can be imported into the shell/editor, however, some functionality may not work. 22 22 23 PyCrust has its own Help. 23 .. image:: new_pycrust_example.png 24 :align: center 24 25 25 *NOTE! The Help() and Credits() calls do not work on Macs.* 26 When a Python file, for example a fitting model, is created or loaded with the *New* or *Open* options from the menu, a new tab opens with an editing notebook. 26 27 27 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 28 .. image:: new_pycrust_example_2.png 29 :align: center 28 30 29 Example 30 ------- 31 If a Python (.py) model has a linked C (.c) subroutine *in the same folder* then the shell/editor will open both! However input focus is usually transferred to the tab with the .c file. 31 32 32 An example calling the Matplotlib plotting gallery: 33 34 .. image:: pycrust_example.png 33 To compile a model, select *Run* > *Check Model* from the shell/editor menu. If the model contains a unit test (which it should!!!) then this will also run and a popup window will report the success/failure of the test. 35 34 36 35 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 37 36 38 .. note:: This help document was last changed by Steve King, 1 9Feb201537 .. note:: This help document was last changed by Steve King, 10Oct2015 -
src/sas/sasgui/perspectives/calculator/model_editor.py
r9501661 rec72ceb 70 70 71 71 This Dialog pops up for the user when they press 'Sum|Multi(p1,p2)' under 72 ' Edit Custom Model' under 'Fitting' menu. This is currently called as72 'Plugin Model Operations' under 'Fitting' menu. This is currently called as 73 73 a Modal Dialog. 74 74 -
src/sas/sasgui/perspectives/calculator/pyconsole.py
r0912b405 rd472e86 103 103 window_name = "Custom Model Editor" 104 104 ## Name to appear on the window title bar 105 window_caption = " CustomModel Editor"105 window_caption = "Plugin Model Editor" 106 106 ## Flag to tell the AUI manager to put this panel in the center pane 107 107 CENTER_PANE = False … … 110 110 size=(PANEL_WIDTH, PANEL_HEIGHT)): 111 111 self.config = None 112 112 113 editor.EditorNotebookFrame.__init__(self, parent=parent, 113 title=title, size=size, 114 filename=filename) 114 title=title, size=size) 115 115 self.parent = parent 116 116 self._manager = manager … … 126 126 self.dataDir = dataDir 127 127 self.Centre() 128 129 # See if there is a corresponding C file 130 if filename != None: 131 c_filename = os.path.splitext(filename)[0] + ".c" 132 if os.path.isfile(c_filename): 133 self.bufferCreate(c_filename) 134 135 # If not, just open the requested .py, if any. 136 # Needs to be after the C file so the tab focus is correct. 137 if os.path.isfile(filename): 138 self.bufferCreate(filename) 128 139 129 140 self.Bind(wx.EVT_MENU, self.OnNewFile, id=wx.ID_NEW) -
src/sas/sasgui/perspectives/corfunc/media/corfunc_help.rst
rda456fb r1404cce 10 10 11 11 This performs a correlation function analysis of one-dimensional 12 SANS data, or generates a model-independent volume fraction profile from a 13 one-dimensional SANS pattern of an adsorbed layer. 14 15 The correlation function analysis is performed in 3 stages: 12 SAXS/SANS data, or generates a model-independent volume fraction 13 profile from the SANS from an adsorbed polymer/surfactant layer. 14 15 A correlation function may be interpreted in terms of an imaginary rod moving 16 through the structure of the material. Î\ :sub:`1D`\ (R) is the probability that 17 a rod of length R moving through the material has equal electron/neutron scattering 18 length density at either end. Hence a frequently occurring spacing within a structure 19 manifests itself as a peak. 20 21 A volume fraction profile :math:`\Phi`\ (z) describes how the density of polymer segments/surfactant molecules varies with distance from an (assumed locally flat) interface. 22 23 Both functions are returned in *real space*. 24 25 The analysis is performed in 3 stages: 16 26 17 27 * Extrapolation of the scattering curve to :math:`Q = 0` and 18 28 :math:`Q = \infty` 19 * Fourier/Hilbert Transform of the extrapolated data to give the correlation 20 function/volume fraction profile 21 * Interpretation of the 1D correlation function based on an ideal lamellar 22 morphology 29 * Smoothed merging of the two extrapolations into the original data 30 * Fourier / Hilbert Transform of the smoothed data to give the correlation 31 function / volume fraction profile, respectively 32 * (Optional) Interpretation of the 1D correlation function based on an ideal 33 lamellar morphology 23 34 24 35 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ … … 28 39 29 40 To :math:`Q = 0` 30 ^^^^^^^^^^^^^^^^ 41 ................ 31 42 32 43 The data are extrapolated to Q = 0 by fitting a Guinier model to the data 33 points in the lower Q range. 44 points in the low-Q range. 45 34 46 The equation used is: 35 47 36 48 .. math:: 37 I(Q) = e^{A+Bq^2}49 I(Q) = Ae^{Bq^2} 38 50 39 51 The Guinier model assumes that the small angle scattering arises from particles … … 41 53 particles. This has dubious applicability to polymer systems. However, the 42 54 correlation function is affected by the Guinier back-extrapolation to the 43 greatest extent at large values of R and so the back-extrapolationonly has a44 small effect on the analysis.55 greatest extent at large values of R and so only has a 56 small effect on the final analysis. 45 57 46 58 To :math:`Q = \infty` 47 ^^^^^^^^^^^^^^^^^^^^^ 59 ..................... 48 60 49 61 The data are extrapolated to Q = :math:`\infty` by fitting a Porod model to 50 the data points in the upperQ range.62 the data points in the high-Q range. 51 63 52 64 The equation used is: 53 65 54 66 .. math:: 55 I(Q) = Bg + KQ^{-4}e^{-Q^2\sigma^2} 56 57 Where :math:`Bg` is the Bonart thermal background, :math:`K` is the Porod 58 constant, and :math:`\sigma > 0` describes the electron (or neutron scattering 59 length) density profile at the interface between crystalline and amorphous 60 regions (see figure 1). 67 I(Q) = K Q^{-4}e^{-Q^2\sigma^2} + Bg 68 69 Where :math:`Bg` is the background, :math:`K` is the Porod 70 constant, and :math:`\sigma` (which must be > 0) describes the width of the electron or neutron scattering length density profile at the interface between the crystalline and amorphous 71 regions as shown below. 61 72 62 73 .. figure:: fig1.gif 63 74 :align: center 64 75 65 **Figure 1** The value of :math:`\sigma` is a measure of the electron 66 density profile at the interface between crystalline and amorphous regions. 67 76 68 77 Smoothing 69 ^^^^^^^^^ 70 71 The extrapolated data set consists of the Guinier back-extrapolation up to the 72 highest Q value of the lower Q range, the original scattering data up to the 73 highest value in the upper Q range, and the Porod tail-fit beyond this. The 74 joins between the original data and the Guinier/Porod fits are smoothed using 75 the algorithm below, to avoid the formation of ripples in the transformed data. 78 --------- 79 80 The extrapolated data set consists of the Guinier back-extrapolation from Q~0 81 up to the lowest Q value in the original data, then the original scattering data, and the Porod tail-fit beyond this. The joins between the original data and the Guinier/Porod fits are smoothed using the algorithm below to avoid the formation of ripples in the transformed data. 76 82 77 83 Functions :math:`f(x_i)` and :math:`g(x_i)` where :math:`x_i \in \left\{ … … 87 93 h_i = \frac{1}{1 + \frac{(x_i-b)^2}{(x_i-a)^2}} 88 94 95 89 96 Transform 90 97 --------- 91 98 92 99 Fourier 93 ^^^^^^^ 94 95 If Fourieris selected for the transform type, the analysis will perform a100 ....... 101 102 If "Fourier" is selected for the transform type, the analysis will perform a 96 103 discrete cosine transform on the extrapolated data in order to calculate the 97 correlation function. The following algorithm is applied: 104 correlation function 105 106 .. math:: 107 \Gamma _{1D}(R) = \frac{1}{Q^{*}} \int_{0}^{\infty }I(q) q^{2} cos(qR) dq 108 109 where Q\ :sup:`*` is the Scattering Invariant. 110 111 The following algorithm is applied: 98 112 99 113 .. math:: … … 103 117 104 118 Hilbert 105 ^^^^^^^ 106 If Hilbert is selected for the transform type, the analysis will perform a 119 ....... 120 121 If "Hilbert" is selected for the transform type, the analysis will perform a 107 122 Hilbert transform on the extrapolated data in order to calculate the Volume 108 123 Fraction Profile. 109 124 125 .. note:: This functionality is not yet implemented in SasView. 126 127 110 128 Interpretation 111 129 -------------- 112 Once the correlation function has been calculated by transforming the 113 extrapolated data, it may be interpreted by clicking the "Compute Parameters" 114 button. The correlation function is interpreted in terms of an ideal lamellar 115 morphology, and structural parameters are obtained as shown in Figure 2 below. 116 It should be noted that a small beam size is assumed; no de-smearing is 130 131 Correlation Function 132 .................... 133 134 Once the correlation function has been calculated it may be interpreted by clicking the "Compute Parameters" button. 135 136 The correlation function is interpreted in terms of an ideal lamellar 137 morphology, and structural parameters are obtained from it as shown below. 138 It should be noted that a small beam size is assumed; ie, no de-smearing is 117 139 performed. 118 140 119 141 .. figure:: fig2.gif 120 142 :align: center 121 122 **Figure 2** Interpretation of the correlation function.123 143 124 144 The structural parameters obtained are: … … 131 151 * Local Crystallinity :math:`= L_c/L_p` 132 152 153 Volume Fraction Profile 154 ....................... 155 156 SasView does not provide any automatic interpretation of volume fraction profiles in the same way that it does for correlation functions. However, a number of structural parameters are obtainable by other means: 157 158 * Surface Coverage :math:`=\theta` 159 * Anchor Separation :math:`= D` 160 * Bound Fraction :math:`= <p>` 161 * Second Moment :math:`= \sigma` 162 * Maximum Extent :math:`= \delta_{\text{h}}` 163 * Adsorbed Amount :math:`= \Gamma` 164 165 .. figure:: profile1.png 166 :align: center 167 168 .. figure:: profile2.png 169 :align: center 170 171 172 References 173 ---------- 174 175 Strobl, G. R.; Schneider, M. *J. Polym. Sci.* (1980), 18, 1343-1359 176 177 Koberstein, J.; Stein R. *J. Polym. Sci. Phys. Ed.* (1983), 21, 2181-2200 178 179 Baltá Calleja, F. J.; Vonk, C. G. *X-ray Scattering of Synthetic Poylmers*, Elsevier. Amsterdam (1989), 247-251 180 181 Baltá Calleja, F. J.; Vonk, C. G. *X-ray Scattering of Synthetic Poylmers*, Elsevier. Amsterdam (1989), 257-261 182 183 Baltá Calleja, F. J.; Vonk, C. G. *X-ray Scattering of Synthetic Poylmers*, Elsevier. Amsterdam (1989), 260-270 184 185 :ref:`FDR` (PDF format) 186 133 187 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 188 134 189 135 190 Usage 136 191 ----- 137 192 Upon sending data for correlation function analysis, it will be plotted (minus 138 the background value), along with a red bar indicating the lower Q range (used 139 for back-extrapolation), and 2 purple bars indicating the upper Q range (used 140 for forward-extrapolation) [figure 3]. These bars may be moved my clicking and 141 dragging, or by entering the appropriate values in the Q range input boxes. 193 the background value), along with a *red* bar indicating the *upper end of the 194 low-Q range* (used for back-extrapolation), and 2 *purple* bars indicating the range to be used for forward-extrapolation. These bars may be moved my clicking and 195 dragging, or by entering appropriate values in the Q range input boxes. 142 196 143 197 .. figure:: tutorial1.png 144 198 :align: center 145 199 146 **Figure 3** A plot of some data showing the Q range bars 147 148 Once the Q ranges have been set, click the "Calculate" button next to the 149 background input field to calculate the Bonart thermal background level. 150 Alternatively, enter your own value into the field. Click the "Extrapolate" 151 button to extrapolate the data and plot the extrapolation in the same figure. 152 The values of the parameters used for the Guinier and Porod models will also be 153 shown in the "Extrapolation Parameters" section [figure 4] 200 Once the Q ranges have been set, click the "Calculate" button to determine the background level. Alternatively, enter your own value into the field. If the box turns yellow this indicates that background subtraction has resulted in some negative intensities. 201 202 Click the "Extrapolate" button to extrapolate the data and plot the extrapolation in the same figure. The values of the parameters used for the Guinier and Porod models will also be shown in the "Extrapolation Parameters" section of the window. 154 203 155 204 .. figure:: tutorial2.png 156 205 :align: center 157 206 158 **Figure 4** A plot showing the extrapolated data and the original data 159 160 Then, select which type of transform you would like to perform, using the radio 207 Now select which type of transform you would like to perform, using the radio 161 208 buttons: 162 209 163 210 * **Fourier** Perform a Fourier Transform to calculate the correlation 164 function of the extrapolated data211 function 165 212 * **Hilbert** Perform a Hilbert Transform to calculate the volume fraction 166 profile of the extrapolated data167 168 Click ing the transform button will thenperform the selected transform and plot169 it in a new figure. If a Fourier Transform was performed, the "Compute 170 Parameters" button can also be clicked to calculate values for the output 171 parameters [figure 5] 213 profile 214 215 Click the "Transform" button to perform the selected transform and plot 216 the result in a new graph window. 217 218 If a Fourier Transform was performed, the "Compute Parameters" button can now be clicked to interpret the correlation function as described earlier. 172 219 173 220 .. figure:: tutorial3.png 174 221 :align: center 175 222 176 **Figure 5** The Fourier Transform (correlation function) of the 177 extrapolated data, and the parameters extracted from it. 223 224 .. note:: 225 This help document was last changed by Steve King, 08Oct2016 -
src/sas/sasgui/perspectives/fitting/basepage.py
r51a4d78 r9087214 1037 1037 dispersity = self.disp_box.GetClientData(n) 1038 1038 name = dispersity.__name__ 1039 1040 1039 self._set_dipers_Param(event=None) 1041 1040 … … 1108 1107 self.Refresh() 1109 1108 1109 def get_cat_combo_box_pos(self, state): 1110 """ 1111 Iterate through the categories to find the structurefactor 1112 :return: combo_box_position 1113 """ 1114 for key, value in self.master_category_dict.iteritems(): 1115 for list_item in value: 1116 if state.formfactorcombobox in list_item: 1117 return self.categorybox.Items.index(key) 1118 1110 1119 def reset_page_helper(self, state): 1111 1120 """ … … 1163 1172 category_pos = int(state.categorycombobox) 1164 1173 except: 1174 state.formfactorcombobox = unicode(state.formfactorcombobox.lower()) 1175 state.categorycombobox = unicode(state.categorycombobox) 1165 1176 category_pos = 0 1166 for ind_cat in range(self.categorybox.GetCount()): 1167 if self.categorybox.GetString(ind_cat) == \ 1168 state.categorycombobox: 1169 category_pos = int(ind_cat) 1170 break 1177 if state.categorycombobox in self.categorybox.Items: 1178 category_pos = self.categorybox.Items.index( 1179 state.categorycombobox) 1180 else: 1181 # Look in master list for model name (model.lower) 1182 category_pos = self.get_cat_combo_box_pos(state) 1171 1183 1172 1184 self.categorybox.Select(category_pos) … … 1189 1201 structfactor_pos = int(state.structurecombobox) 1190 1202 except: 1191 structfactor_pos = 0 1192 for ind_struct in range(self.structurebox.GetCount()): 1193 if self.structurebox.GetString(ind_struct) == \ 1194 (state.structurecombobox): 1195 structfactor_pos = int(ind_struct) 1196 break 1203 if state.structurecombobox is not None: 1204 structfactor_pos = 0 1205 state.structurecombobox = unicode(state.structurecombobox) 1206 for ind_struct in range(self.structurebox.GetCount()): 1207 if self.structurebox.GetString(ind_struct) == \ 1208 (state.structurecombobox): 1209 structfactor_pos = int(ind_struct) 1210 break 1197 1211 1198 1212 self.structurebox.SetSelection(structfactor_pos) … … 1407 1421 self.state.npts = self.npts_x 1408 1422 1409 def _onparamEnter_helper(self ):1423 def _onparamEnter_helper(self,is_modified = False): 1410 1424 """ 1411 1425 check if values entered by the user are changed and valid to replot … … 1413 1427 """ 1414 1428 # Flag to register when a parameter has changed. 1415 is_modified = False1429 #is_modified = False 1416 1430 self.fitrange = True 1417 1431 is_2Ddata = False … … 1421 1435 is_2Ddata = True 1422 1436 if self.model != None: 1423 is_modified = (self._check_value_enter(self.fittable_param) 1424 or self._check_value_enter(self.fixed_param) 1425 or self._check_value_enter(self.parameters)) 1437 #Either we get a is_modified = True passed in because 1438 #_update_paramv_on_fit() has been called already or 1439 # we need to check here ourselves. 1440 if not is_modified: 1441 is_modified = (self._check_value_enter(self.fittable_param) 1442 or self._check_value_enter(self.fixed_param) 1443 or self._check_value_enter(self.parameters)) 1426 1444 1427 1445 # Here we should check whether the boundaries have been modified. … … 1472 1490 flag = True 1473 1491 self.fitrange = True 1492 is_modified = False 1474 1493 1475 1494 #wx.PostEvent(self._manager.parent, StatusEvent(status=" \ … … 1484 1503 [self.data]) 1485 1504 ##Check the values 1486 self._check_value_enter(self.fittable_param)1487 self._check_value_enter(self.fixed_param)1488 self._check_value_enter(self.parameters)1505 is_modified = (self._check_value_enter(self.fittable_param) 1506 or self._check_value_enter(self.fixed_param) 1507 or self._check_value_enter(self.parameters)) 1489 1508 1490 1509 # If qmin and qmax have been modified, update qmin and qmax and … … 1568 1587 logging.error(traceback.format_exc()) 1569 1588 1570 return flag 1589 return flag,is_modified 1571 1590 1572 1591 def _reset_parameters_state(self, listtorestore, statelist): … … 1979 1998 form_factor = self.formfactorbox.GetClientData(f_id) 1980 1999 1981 if form_factor is None or not form_factor.is_form_factor: 2000 if form_factor is None or \ 2001 not hasattr(form_factor, 'is_form_factor') or \ 2002 not form_factor.is_form_factor: 1982 2003 self.structurebox.Hide() 1983 2004 self.text2.Hide() … … 2306 2327 wx.PostEvent(self.parent, event) 2307 2328 #draw the model with the current dispersity 2308 self._draw_model() 2329 2330 #Wojtek P, Oct 8, 2016: Calling draw_model seems to be unessecary. 2331 #By comenting it we save an extra Iq calculation 2332 #self._draw_model() 2333 2309 2334 ## Need to use FitInside again here to replace the next four lines. 2310 2335 ## Otherwised polydispersity off does not resize the scrollwindow. … … 3055 3080 """ 3056 3081 content = '' 3082 bound_hi = '' 3083 bound_lo = '' 3057 3084 # go through the str params 3058 3085 for item in param: … … 3086 3113 value = item[2].GetValue() 3087 3114 3115 # Bounds 3116 try: 3117 bound_lo = item[5].GetValue() 3118 bound_hi = item[6].GetValue() 3119 except Exception: 3120 # harmless - need to just pass 3121 pass 3122 3088 3123 # add to the content 3089 3124 if disfunc != '': … … 3101 3136 except Exception: 3102 3137 logging.error(traceback.format_exc()) 3103 content += name + ',' + str(check) + ',' + value + disfunc + ':' 3138 content += name + ',' + str(check) + ',' +\ 3139 value + disfunc + ',' + bound_lo + ',' +\ 3140 bound_hi + ':' 3104 3141 3105 3142 return content … … 3152 3189 # Transfer the text to content[dictionary] 3153 3190 context[name] = [check, value] 3191 3192 # limits 3193 limit_lo = item[3] 3194 context[name].append(limit_lo) 3195 limit_hi = item[4] 3196 context[name].append(limit_hi) 3197 3154 3198 # ToDo: PlugIn this poly disp function for pasting 3155 3199 try: 3156 poly_func = item[ 3]3200 poly_func = item[5] 3157 3201 context[name].append(poly_func) 3158 3202 try: 3159 3203 # take the vals and weights for array 3160 array_values = item[ 4].split(' ')3161 array_weights = item[ 5].split(' ')3204 array_values = item[6].split(' ') 3205 array_weights = item[7].split(' ') 3162 3206 val = [float(a_val) for a_val in array_values[1:]] 3163 3207 weit = [float(a_weit) for a_weit in array_weights[1:]] … … 3207 3251 name = item[1] 3208 3252 if name in content.keys(): 3209 check = content[name][0] 3210 pd = content[name][1] 3253 values = content[name] 3254 check = values[0] 3255 pd = values[1] 3256 3211 3257 if name.count('.') > 0: 3212 3258 # If this is parameter.width, then pd may be a floating … … 3231 3277 fun_val = self.model.fun_list[content[name][1]] 3232 3278 self.model.setParam(name, fun_val) 3279 try: 3280 item[5].SetValue(str(values[-3])) 3281 item[6].SetValue(str(values[-2])) 3282 except Exception: 3283 # passing as harmless non-update 3284 pass 3233 3285 3234 3286 value = content[name][1:] … … 3275 3327 self.model.setParam(name, fun_val) 3276 3328 # save state 3329 try: 3330 item[5].SetValue(str(value[-3])) 3331 item[6].SetValue(str(value[-2])) 3332 except Exception: 3333 # passing as harmless non-update 3334 pass 3335 3277 3336 self._paste_poly_help(item, value) 3278 3337 if check == 'True': … … 3309 3368 """ 3310 3369 # Do nothing if not setting polydispersity 3311 if len(value[ 1]) == 0:3370 if len(value[3]) == 0: 3312 3371 return 3313 3372 -
src/sas/sasgui/perspectives/fitting/fitpage.py
r7988501 r9087214 424 424 self.Bind(wx.EVT_RADIOBUTTON, self.onSlitSmear, 425 425 id=self.slit_smearer.GetId()) 426 self. disable_smearer.SetValue(True)426 self.enable_smearer.SetValue(True) 427 427 428 428 sizer_smearer.Add(self.disable_smearer, 0, wx.LEFT, 10) … … 1058 1058 self.create_default_data() 1059 1059 """ 1060 flag = self._update_paramv_on_fit()1061 1062 wx.CallAfter(self._onparamEnter_helper )1060 flag,is_modified = self._update_paramv_on_fit() 1061 1062 wx.CallAfter(self._onparamEnter_helper,is_modified) 1063 1063 if not flag: 1064 1064 msg = "The parameters are invalid" -
src/sas/sasgui/perspectives/fitting/fitting.py
rff3f5821 rec72ceb 221 221 self.id_edit = wx.NewId() 222 222 editmodel_help = "Edit customized model sample file" 223 self.menu1.AppendMenu(self.id_edit, " Edit Custom Model",223 self.menu1.AppendMenu(self.id_edit, "Plugin Model Operations", 224 224 self.edit_model_menu, editmodel_help) 225 225 #create menubar items … … 236 236 frame = PyConsole(parent=self.parent, manager=self, 237 237 panel=self.fit_panel, 238 title='Advanced CustomModel Editor',238 title='Advanced Plugin Model Editor', 239 239 filename=filename) 240 240 self.put_icon(frame) … … 302 302 event_id = event.GetId() 303 303 dir_path = models.find_plugins_dir() 304 title = "New CustomModel Function"304 title = "New Plugin Model Function" 305 305 self.new_model_frame = EditorWindow(parent=self, base=self, 306 306 path=dir_path, title=title) … … 319 319 Update custom model list in the fitpage combo box 320 320 """ 321 custom_model = ' CustomizedModels'321 custom_model = 'Plugin Models' 322 322 try: 323 323 # Update edit menus … … 350 350 wx_id = wx.NewId() 351 351 #new_model_menu = wx.Menu() 352 self.edit_model_menu.Append(wx_id, 'New ',352 self.edit_model_menu.Append(wx_id, 'New Plugin Model', 353 353 'Add a new model function') 354 354 wx.EVT_MENU(owner, wx_id, self.make_new_model) … … 362 362 self.edit_menu = wx.Menu() 363 363 self.edit_model_menu.AppendMenu(e_id, 364 'Advanced ', self.edit_menu)364 'Advanced Plugin Editor', self.edit_menu) 365 365 self.set_edit_menu_helper(owner, self.edit_custom_model) 366 366 … … 368 368 self.delete_menu = wx.Menu() 369 369 self.edit_model_menu.AppendMenu(d_id, 370 'Delete ', self.delete_menu)370 'Delete Plugin Models', self.delete_menu) 371 371 self.set_edit_menu_helper(owner, self.delete_custom_model) 372 372 373 373 wx_id = wx.NewId() 374 self.edit_model_menu.Append(wx_id, 'Load Models',374 self.edit_model_menu.Append(wx_id, 'Load Plugin Models', 375 375 '(Re)Load all models present in user plugin_models folder') 376 376 wx.EVT_MENU(owner, wx_id, self.load_plugin_models) 377 377 378 378 def set_edit_menu_helper(self, owner=None, menu=None): 379 379 """ -
src/sas/sasgui/perspectives/fitting/media/fitting.rst
r05829fb 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
r05829fb r3e1c9e5 18 18 ======= 19 19 20 .. note:: If some code blocks are not readable, expand the documentation window 21 20 22 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 21 23 … … 116 118 --------------- 117 119 118 For a complete list of all the library models available in SasView, see the Model Documentation.120 For a complete list of all the library models available in SasView, see the `Model Documentation <../../../index.html>`_ . 119 121 120 122 It is also possible to add your own models. … … 124 126 .. _Adding_your_own_models: 125 127 126 Adding your own models128 Adding your own Models 127 129 ---------------------- 128 130 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 ^^^^ 131 There are essentially three ways to generate new fitting models for SasView: 132 133 * Using the SasView :ref:`New_Plugin_Model` helper dialog (best for beginners and/or relatively simple models) 134 * By copying/editing an existing model (this can include models generated by the *New Plugin Model* dialog) in the :ref:`Python_shell` or :ref:`Advanced_Plugin_Editor` (suitable for all use cases) 135 * By writing a model from scratch outside of SasView (only recommended for code monkeys!) 136 137 Please read the guidance on :ref:`Writing_a_Plugin` before proceeding. 138 139 **To be found by SasView your model must reside in the *~\\.sasview\\plugin_models* folder.** 140 141 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 142 143 .. _Plugin_Model_Operations: 144 145 Plugin Model Operations 146 ----------------------- 147 148 From the *Fitting* option in the menu bar, select *Plugin Model Operations* 149 150 .. image:: edit_model_menu.png 151 152 and then one of the sub-options 153 154 * *New Plugin Model* - to create a plugin model template with a helper dialog 155 * *Sum|Multi(p1,p2)* - to create a plugin model by summing/multiplying *existing models* in the model library 156 * *Advanced Plugin Editor* - to create/edit a plugin model in a Python shell 157 * *Delete Plugin Models* - to delete a plugin model 158 * *Load Plugin Models* - to (re-)load plugin models 159 160 .. _New_Plugin_Model: 161 162 New Plugin Model 163 ^^^^^^^^^^^^^^^^ 154 164 155 165 .. image:: new_model.bmp 156 166 157 167 A model template generated by this option can be viewed and further modified using 158 the :ref:`Advanced ` option.168 the :ref:`Advanced_Plugin_Editor` . 159 169 160 170 *NB: "Fit Parameters" has been split into two sections, those which can be … … 167 177 .. image:: sum_model.bmp 168 178 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 179 This option creates a custom model of the form:: 180 181 Custom Model = scale_factor \* {(scale_1 \* model_1) \+ (scale_2 \* model_2)} \+ background 182 183 or:: 184 185 Custom Model = scale_factor \* model_1 \* model_2 \+ background 186 187 In the *Easy Sum/Multi Editor* give the new model a function name and brief 188 description (to appear under the *Details* button on the *FitPage*). Then select 175 189 two existing models, as p1 and p2, and the required operator, '+' or '*' between 176 190 them. Finally, click the *Apply* button to generate the model and then click *Close*. 177 191 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) 192 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. 193 194 .. _Advanced_Plugin_Editor: 195 196 Advanced Plugin Editor 197 ^^^^^^^^^^^^^^^^^^^^^^ 198 199 Selecting this option shows all the plugin models in the plugin model folder, on Windows this is 200 201 *C:\\Users\\{username}\\.sasview\\plugin_models* 189 202 190 203 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* 204 *Advanced Plugin Model Editor*. Note that this is actually the same tool as the :ref:`Python_shell` . 205 206 For details of the SasView plugin model format see :ref:`Writing_a_Plugin` . 207 208 .. 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! 209 210 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'. 211 212 .. image:: ../calculator/new_pycrust_example_2.png 213 214 To use the model, go to the relevant *Fit Page*, select the *Plugin Models* 204 215 category and then select the model from the drop-down menu. 205 216 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.* 217 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. 218 219 Delete Plugin Models 220 ^^^^^^^^^^^^^^^^^^^^ 221 222 Simply highlight the plugin model to be removed. The operation is final!!! 223 224 *NB: Plugin models shipped with SasView cannot be removed in this way.* 225 226 Load Plugin Models 227 ^^^^^^^^^^^^^^^^^^ 228 229 This option loads (or re-loads) all models present in the *~\\.sasview\\plugin_models* folder. 215 230 216 231 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ … … 600 615 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 601 616 602 .. note:: This help document was last changed by Steve King, 04Jun2015617 .. note:: This help document was last changed by Steve King, 10Oct2016 -
src/sas/sasgui/perspectives/fitting/media/plugin.rst
rb2a3814 r3e1c9e5 6 6 .. note:: If some code blocks are not readable, expand the documentation window 7 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 and/or relatively simple models) 14 * By copying/editing an existing model (this can include models generated by the *New Plugin Model* dialog) in the :ref:`Python_shell` or :ref:`Advanced_Plugin_Editor` as described below (suitable for all use cases) 15 * By writing a model from scratch outside of SasView (only recommended for code monkeys!) 16 8 17 Overview 9 18 ^^^^^^^^ 10 19 11 You can write your own model and save it to the the SasView 12 *plugin_models* folder 13 14 *C:\\Users\\[username]\\.sasview\\plugin_models* (on Windows) 15 16 The next time SasView is started it will compile the plugin and add 17 it to the list of *Customized Models* in a FitPage. It is recommended that an 18 existing model be used as a template. 19 20 SasView has three ways of writing models: 21 22 - As a pure python model : Example - 20 If you write your own model and save it to the the SasView *plugin_models* folder 21 22 *C:\\Users\\{username}\\.sasview\\plugin_models* (on Windows) 23 24 the next time SasView is started it will compile the plugin and add 25 it to the list of *Plugin Models* in a FitPage. 26 27 SasView models can be of three types: 28 29 - A pure python model : Example - 23 30 `broadpeak.py <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/broad_peak.py>`_ 24 - A s apython model with embedded C : Example -31 - A python model with embedded C : Example - 25 32 `sphere.py <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/sphere.py>`_ 26 - A s apython wrapper with separate C code : Example -33 - A python wrapper with separate C code : Example - 27 34 `cylinder.py <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/cylinder.py>`_, 28 35 `cylinder.c <https://github.com/SasView/sasmodels/blob/master/sasmodels/models/cylinder.c>`_ … … 42 49 43 50 In the *~\\.sasview\\plugin_models* directory, copy the appropriate files 44 ( using the examples above as templates) to mymodel.py (and mymodel.c, etc)51 (we recommend using the examples above as templates) to mymodel.py (and mymodel.c, etc) 45 52 as required, where "mymodel" is the name for the model you are creating. 46 53 … … 662 669 ^^^^^^^^^^^^^^^^^^^ 663 670 664 Installed SasView 665 ................. 666 667 If you are editing your model from the SasView GUI, you can test it 668 by selecting *Run > Check Model* from the *Model Editor* menu bar. An 669 *Info* box will appear with the results of the compilation and a 670 check that the model runs. 671 672 673 Built SasView 674 ............. 671 Minimal Testing 672 ............... 673 674 Either open the :ref:`Python_shell` (*Tools* > *Python Shell/Editor*) or the :ref:`Advanced_Plugin_Editor` (*Fitting* > *Plugin Model Operations* > *Advanced 675 Plugin Editor*), load your model, and then select *Run > Check Model* from the 676 menu bar. 677 678 An *Info* box will appear with the results of the compilation and a check that 679 the model runs. 680 681 Recommended Testing 682 ................... 675 683 676 684 If the model compiles and runs, you can next run the unit tests that … … 793 801 consider adding your model to the 794 802 `Model Marketplace <http://marketplace.sasview.org/>`_ so that others may use it! 803 804 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 805 806 .. note:: This help document was last changed by Steve King, 10Oct2016 -
src/sas/sasgui/perspectives/fitting/models.py
r212bfc2 r5de7f69 181 181 try: 182 182 model = load_custom_model(path) 183 model.name = "[plug-in] "+model.name 183 184 plugins[model.name] = model 184 185 except Exception: -
src/sas/sasgui/perspectives/fitting/pagestate.py
re6de6b8 r467202f 1753 1753 1754 1754 return doc 1755 1756 # Simple html report templet 1757 HEADER = "<html>\n" 1758 HEADER += "<head>\n" 1759 HEADER += "<meta http-equiv=Content-Type content='text/html; " 1760 HEADER += "charset=windows-1252'> \n" 1761 HEADER += "<meta name=Generator >\n" 1762 HEADER += "</head>\n" 1763 HEADER += "<body lang=EN-US>\n" 1764 HEADER += "<div class=WordSection1>\n" 1765 HEADER += "<p class=MsoNormal><b><span ><center><font size='4' >" 1766 HEADER += "%s</font></center></span></center></b></p>" 1767 HEADER += "<p class=MsoNormal> </p>" 1768 PARA = "<p class=MsoNormal><font size='4' > %s \n" 1769 PARA += "</font></p>" 1770 CENTRE = "<p class=MsoNormal><center><font size='4' > %s \n" 1771 CENTRE += "</font></center></p>" 1772 FEET_1 = \ 1773 """ 1774 <p class=MsoNormal> </p> 1775 <br> 1776 <p class=MsoNormal><b><span ><center> <font size='4' > Graph 1777 </font></span></center></b></p> 1778 <p class=MsoNormal> </p> 1779 <center> 1780 <br><font size='4' >Model Computation</font> 1781 <br><font size='4' >Data: "%s"</font><br> 1782 """ 1783 FEET_2 = \ 1784 """ 1785 <img src="%s" > 1786 </img> 1787 """ 1788 FEET_3 = \ 1789 """ 1790 </center> 1791 </div> 1792 </body> 1793 </html> 1794 """ 1795 ELINE = "<p class=MsoNormal> </p>" -
src/sas/sasgui/perspectives/fitting/simfitpage.py
r998ca90 ra28e52b 1093 1093 sim_page.constraints_list[index][3].SetValue(constraint_value) 1094 1094 sim_page._on_add_constraint(None) 1095 sim_page._manager.sim_page = sim_page 1095 1096 1096 1097 def _format_id(self, original_id):
Note: See TracChangeset
for help on using the changeset viewer.