Changeset 66acafe in sasview for src/sas/sasgui/perspectives/fitting
- Timestamp:
- Sep 19, 2017 9:28:58 AM (7 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, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- b22e23e
- Parents:
- 8c945ec (diff), 632fda9 (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. - git-author:
- Paul Butler <butlerpd@…> (09/19/17 09:28:58)
- git-committer:
- GitHub <noreply@…> (09/19/17 09:28:58)
- Location:
- src/sas/sasgui/perspectives/fitting
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/fitting/basepage.py
rb76e65a r66acafe 1841 1841 if models.name != "NoStructure": 1842 1842 mlist.append((models.name, models)) 1843 1844 1843 # Sort the models 1845 1844 mlist_sorted = sorted(mlist) -
src/sas/sasgui/perspectives/fitting/fitpage.py
r0b6f83c r66acafe 1156 1156 copy_flag = self.get_copy_params() 1157 1157 is_poly_enabled = self.enable_disp.GetValue() 1158 1159 self._on_select_model_helper() 1158 try: 1159 self._on_select_model_helper() 1160 except Exception as e: 1161 evt = StatusEvent(status=e.message, info="error") 1162 wx.PostEvent(self._manager.parent, evt) 1163 # Set S(Q) to None 1164 self.structurebox.SetSelection(0) 1165 self._on_select_model() 1166 return 1160 1167 self.set_model_param_sizer(self.model) 1161 1168 if self.model is None: -
src/sas/sasgui/perspectives/fitting/fitting.py
r5c1c486 r66acafe 357 357 else: 358 358 page.formfactorbox.SetLabel(current_val) 359 if hasattr(page, 'structurebox'): 360 selected_name = page.structurebox.GetStringSelection() 361 362 page.structurebox.Clear() 363 page.initialize_combox() 364 365 index = page.structurebox.FindString(selected_name) 366 if index == -1: 367 index = 0 368 page.structurebox.SetSelection(index) 369 page._on_select_model() 359 370 except: 360 371 logger.error("update_custom_combo: %s", sys.exc_value) -
src/sas/sasgui/perspectives/fitting/models.py
rb1c2011 r632fda9 14 14 import py_compile 15 15 import shutil 16 from copy import copy 16 17 # Explicitly import from the pluginmodel module so that py2exe 17 18 # places it in the distribution. The Model1DPlugin class is used … … 278 279 """ 279 280 280 # regular model names only281 # Regular model names only 281 282 self.model_name_list = [] 282 283 283 # Build list automagically from sasmodels package284 # Build list automagically from sasmodels package 284 285 for model in load_standard_models(): 285 286 self.model_dictionary[model.name] = model … … 293 294 self.model_name_list.append(model.name) 294 295 295 # Looking for plugins296 # Looking for plugins 296 297 self.stored_plugins = self.findModels() 297 298 self.plugins = self.stored_plugins.values() 298 299 for name, plug in self.stored_plugins.iteritems(): 299 300 self.model_dictionary[name] = plug 301 # TODO: Remove 'hasattr' statements when old style plugin models 302 # are no longer supported. All sasmodels models will have 303 # the required attributes. 304 if hasattr(plug, 'is_structure_factor') and plug.is_structure_factor: 305 self.struct_list.append(plug) 306 self.plugins.remove(plug) 307 elif hasattr(plug, 'is_form_factor') and plug.is_form_factor: 308 self.multiplication_factor.append(plug) 309 if hasattr(plug, 'is_multiplicity_model') and plug.is_multiplicity_model: 310 self.multi_func_list.append(plug) 300 311 301 312 self._get_multifunc_models() … … 340 351 """ 341 352 self.plugins = [] 342 new_plugins = _find_models() 343 for name, plug in new_plugins.iteritems(): 344 for stored_name, stored_plug in self.stored_plugins.iteritems(): 345 if name == stored_name: 346 del self.stored_plugins[name] 347 del self.model_dictionary[name] 348 break 353 self.stored_plugins = _find_models() 354 structure_names = [model.name for model in self.struct_list] 355 form_names = [model.name for model in self.multiplication_factor] 356 357 # Remove all plugin structure factors and form factors 358 for name in copy(structure_names): 359 if '[plug-in]' in name: 360 i = structure_names.index(name) 361 del self.struct_list[i] 362 structure_names.remove(name) 363 for name in copy(form_names): 364 if '[plug-in]' in name: 365 i = form_names.index(name) 366 del self.multiplication_factor[i] 367 form_names.remove(name) 368 369 # Add new plugin structure factors and form factors 370 for name, plug in self.stored_plugins.iteritems(): 371 if plug.is_structure_factor: 372 if name in structure_names: 373 # Delete the old model from self.struct list 374 i = structure_names.index(name) 375 del self.struct_list[i] 376 # Add the new model to self.struct_list 377 self.struct_list.append(plug) 378 elif plug.is_form_factor: 379 if name in form_names: 380 # Delete the old model from self.multiplication_factor 381 i = form_names.index(name) 382 del self.multiplication_factor[i] 383 # Add the new model to self.multiplication_factor 384 self.multiplication_factor.append(plug) 385 386 # Add references to the updated model 349 387 self.stored_plugins[name] = plug 350 self.plugins.append(plug) 388 if not plug.is_structure_factor: 389 # Don't show S(Q) models in the 'Plugin Models' dropdown 390 self.plugins.append(plug) 351 391 self.model_dictionary[name] = plug 352 392 353 393 self.model_combobox.reset_list("Plugin Models", self.plugins) 394 self.model_combobox.reset_list("Structure Factors", self.struct_list) 395 self.model_combobox.reset_list("P(Q)*S(Q)", self.multiplication_factor) 396 354 397 return self.model_combobox.get_list() 355 398 -
src/sas/sasgui/perspectives/fitting/fitpanel.py
r67b0a99 r6f9abd3 501 501 if data is None: 502 502 return None 503 focused_page = self.GetPage(self.GetSelection()) 503 504 for page in self.opened_pages.values(): 504 505 # check if the selected data existing in the fitpanel 505 506 pos = self.GetPageIndex(page) 506 507 if not check_data_validity(page.get_data()) and not page.batch_on: 508 if page.model is not None and page != focused_page: 509 # Page has an active theory and is in background - don't 510 # send data here. 511 continue 507 512 # make sure data get placed in 1D empty tab if data is 1D 508 513 # else data get place on 2D tab empty tab -
src/sas/sasgui/perspectives/fitting/media/fitting_help.rst
r05b0bf6 rca383a0 195 195 the :ref:`Advanced_Plugin_Editor` . 196 196 197 **SasView version 4.2** made it possible to specify whether a plugin created with 198 the *New Plugin Model* dialog is actually a form factor P(Q) or a structure factor 199 S(Q). To do this, simply add one or other of the following lines under the *import* 200 statements. 201 202 For a form factor:: 203 204 form_factor = True 205 206 or for a structure factor:: 207 208 structure_factor = True 209 210 If the plugin is a structure factor it is *also* necessary to add two variables to 211 the parameter list:: 212 213 parameters = [ 214 ['radius_effective', '', 1, [0.0, numpy.inf], 'volume', ''], 215 ['volfraction', '', 1, [0.0, 1.0], '', ''], 216 [...], 217 218 and to the declarations of the functions Iq and Iqxy::: 219 220 def Iq(x , radius_effective, volfraction, ...): 221 222 def Iqxy(x, y, radius_effective, volfraction, ...): 223 224 Such a plugin should then be available in the S(Q) drop-down box on a FitPage (once 225 a P(Q) model has been selected). 226 197 227 Sum|Multi(p1,p2) 198 228 ^^^^^^^^^^^^^^^^ … … 206 236 or:: 207 237 208 Plugin Model = scale_factor * model_1 /* model_2+ background238 Plugin Model = scale_factor * (model1 * model2) + background 209 239 210 240 In the *Easy Sum/Multi Editor* give the new model a function name and brief 211 241 description (to appear under the *Details* button on the *FitPage*). Then select 212 242 two existing models, as p1 and p2, and the required operator, '+' or '*' between 213 them. Finally, click the *Apply* button to generate the model and then click *Close*. 214 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. 243 them. Finally, click the *Apply* button to generate and test the model and then click *Close*. 244 245 Any changes to a plugin model generated in this way only become effective *after* it is re-selected 246 from the plugin models drop-down menu on the FitPage. If the model is not listed you can force a 247 recompilation of the plugins by selecting *Fitting* > *Plugin Model Operations* > *Load Plugin Models*. 248 249 **SasView version 4.2** introduced a much simplified and more extensible structure for plugin models 250 generated through the Easy Sum/Multi Editor. For example, the code for a combination of a sphere model 251 with a power law model now looks like this:: 252 253 from sasmodels.core import load_model_info 254 from sasmodels.sasview_model import make_model_from_info 255 256 model_info = load_model_info('sphere+power_law') 257 model_info.name = 'MyPluginModel' 258 model_info.description = 'sphere + power_law' 259 Model = make_model_from_info(model_info) 260 261 To change the models or operators contributing to this plugin it is only necessary to edit the string 262 in the brackets after *load_model_info*, though it would also be a good idea to update the model name 263 and description too!!! 264 265 The model specification string can handle multiple models and combinations of operators (+ or *) which 266 are processed according to normal conventions. Thus 'model1+model2*model3' would be valid and would 267 multiply model2 by model3 before adding model1. In this example, parameters in the *FitPage* would be 268 prefixed A (for model2), B (for model3) and C (for model1). Whilst this might appear a little 269 confusing, unless you were creating a plugin model from multiple instances of the same model the parameter 270 assignments ought to be obvious when you load the plugin. 271 272 If you need to include another plugin model in the model specification string, just prefix the name of 273 that model with *custom*. For instance:: 274 275 sphere+custom.MyPluginModel 276 277 To create a P(Q)*\S(Q) model use the @ symbol instead of * like this:: 278 279 sphere@hardsphere 280 281 This streamlined approach to building complex plugin models from existing library models, or models 282 available on the *Model Marketplace*, also permits the creation of P(Q)*\S(Q) plugin models, something 283 that was not possible in earlier versions of SasView. 216 284 217 285 .. _Advanced_Plugin_Editor: -
src/sas/sasgui/perspectives/fitting/media/plugin.rst
r72100ee re081946 18 18 * By writing a model from scratch outside of SasView (only recommended for 19 19 code monkeys!) 20 21 **What follows below is quite technical. If you just want a helping hand to get 22 started creating your own models see** :ref:`Adding_your_own_models`. 20 23 21 24 Overview
Note: See TracChangeset
for help on using the changeset viewer.