Changeset 8c0d9eb in sasview for src/sas/sasgui/perspectives


Ignore:
Timestamp:
Mar 2, 2017 11:40:28 AM (8 years ago)
Author:
krzywon
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:
b61bd57
Parents:
2d568f6 (diff), 775e0b7 (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.
Message:

Merge branch 'master' into ticket-844-part2

Location:
src/sas/sasgui/perspectives
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/perspectives/calculator/model_editor.py

    ra08b89b rddbac66  
    55function of y (usually the intensity).  It also provides a drop down of 
    66standard available math functions.  Finally a full python editor panel for 
    7 complete customizatin is provided. 
    8  
    9 :TODO the writiong of the file and name checking (and maybe some other 
    10 funtions?) should be moved to a computational module which could be called 
    11 fropm a python script.  Basically one just needs to pass the name, 
     7complete customization is provided. 
     8 
     9:TODO the writing of the file and name checking (and maybe some other 
     10functions?) should be moved to a computational module which could be called 
     11from a python script.  Basically one just needs to pass the name, 
    1212description text and function text (or in the case of the composite editor 
    1313the names of the first and second model and the operator to be used). 
     
    6161    """ 
    6262    Dialog for easy custom composite models.  Provides a wx.Dialog panel 
    63     to choose two existing models (including pre-existing custom models which 
     63    to choose two existing models (including pre-existing Plugin Models which 
    6464    may themselves be composite models) as well as an operation on those models 
    6565    (add or multiply) the resulting model will add a scale parameter for summed 
     
    380380            color = 'blue' 
    381381        except: 
    382             msg = "Easy Custom Sum/Multipy: Error occurred..." 
     382            msg = "Easy Sum/Multipy Plugin: Error occurred..." 
    383383            info = 'Error' 
    384384            color = 'red' 
     
    501501        self.factor = factor 
    502502        self._operator = operator 
    503         self.explanation = "  Custom Model = %s %s (model1 %s model2)\n" % \ 
     503        self.explanation = "  Plugin Model = %s %s (model1 %s model2)\n" % \ 
    504504                           (self.factor, f_oper, self._operator) 
    505505        self.explanationctr.SetLabel(self.explanation) 
     
    617617class EditorPanel(wx.ScrolledWindow): 
    618618    """ 
    619     Custom model function editor 
     619    Simple Plugin Model function editor 
    620620    """ 
    621621    def __init__(self, parent, base, path, title, *args, **kwds): 
     
    652652        self.msg_sizer = None 
    653653        self.warning = "" 
    654         self._description = "New Custom Model" 
     654        #This does not seem to be used anywhere so commenting out for now 
     655        #    -- PDB 2/26/17  
     656        #self._description = "New Plugin Model" 
    655657        self.function_tcl = None 
    656658        self.math_combo = None 
     
    991993        else: 
    992994            self._notes = result 
    993             msg = "Successful! Please look for %s in Customized Models."%name 
     995            msg = "Successful! Please look for %s in Plugin Models."%name 
    994996            msg += "  " + self._notes 
    995997            info = 'Info' 
     
    11381140    def on_help(self, event): 
    11391141        """ 
    1140         Bring up the Custom Model Editor Documentation whenever 
     1142        Bring up the New Plugin Model Editor Documentation whenever 
    11411143        the HELP button is clicked. 
    11421144 
     
    11901192        #self.Destroy() 
    11911193 
    1192 ## Templates for custom models 
     1194## Templates for plugin models 
    11931195 
    11941196CUSTOM_TEMPLATE = """ 
  • src/sas/sasgui/perspectives/calculator/pyconsole.py

    rd472e86 rddbac66  
    302302        success = show_model_output(self, fname) 
    303303 
    304         # Update custom model list in fitpage combobox 
     304        # Update plugin model list in fitpage combobox 
    305305        if success and self._manager != None and self.panel != None: 
    306306            self._manager.set_edit_menu_helper(self.parent) 
  • src/sas/sasgui/perspectives/fitting/basepage.py

    ra6fccd7 r7a5aedd  
    5353    ON_MAC = True 
    5454 
     55CUSTOM_MODEL = 'Plugin Models' 
     56 
    5557class BasicPage(ScrolledPanel, PanelBase): 
    5658    """ 
    57     This class provide general structure of fitpanel page 
     59    This class provide general structure of the fitpanel page 
    5860    """ 
    5961    # Internal name for the AUI manager 
     
    677679    def _copy_info(self, flag): 
    678680        """ 
    679         Send event dpemding on flag 
    680  
    681         : Param flag: flag that distinguish event 
     681        Send event depending on flag 
     682 
     683        : Param flag: flag that distinguishes the event 
    682684        """ 
    683685        # messages depending on the flag 
     
    11191121        :precondition: the page is already drawn or created 
    11201122 
    1121         :postcondition: the state of the underlying data change as well as the 
     1123        :postcondition: the state of the underlying data changes as well as the 
    11221124            state of the graphic interface 
    11231125        """ 
     
    11671169        self._show_combox(None) 
    11681170        from models import PLUGIN_NAME_BASE 
    1169         if self.categorybox.GetValue() == 'Customized Models' \ 
     1171        if self.categorybox.GetValue() == CUSTOM_MODEL \ 
    11701172                and PLUGIN_NAME_BASE not in state.formfactorcombobox: 
    11711173            state.formfactorcombobox = \ 
     
    13351337    def _selectDlg(self): 
    13361338        """ 
    1337         open a dialog file to selected the customized dispersity 
     1339        open a dialog file to select the customized polydispersity function 
    13381340        """ 
    13391341        if self.parent is not None: 
     
    17601762    def _set_multfactor_combobox(self, multiplicity=10): 
    17611763        """ 
    1762         Set comboBox for muitfactor of CoreMultiShellModel 
     1764        Set comboBox for multitfactor of CoreMultiShellModel 
    17631765        :param multiplicit: no. of multi-functionality 
    17641766        """ 
     
    17981800        Fill panel's combo box according to the type of model selected 
    17991801        """ 
    1800         custom_model = 'Customized Models' 
     1802 
    18011803        mod_cat = self.categorybox.GetStringSelection() 
    18021804        self.structurebox.SetSelection(0) 
     
    18071809        m_list = [] 
    18081810        try: 
    1809             if mod_cat == custom_model: 
     1811            if mod_cat == CUSTOM_MODEL: 
    18101812                for model in self.model_list_box[mod_cat]: 
    18111813                    m_list.append(self.model_dict[model.name]) 
     
    34533455        fills out the category list box 
    34543456        """ 
    3455         uncat_str = 'Customized Models' 
     3457        uncat_str = 'Plugin Models' 
    34563458        self._read_category_info() 
    34573459 
     
    34823484        self.model_box.Clear() 
    34833485 
    3484         if category == 'Customized Models': 
     3486        if category == 'Plugin Models': 
    34853487            for model in self.model_list_box[category]: 
    34863488                str_m = str(model).split(".")[0] 
  • src/sas/sasgui/perspectives/fitting/fitpage.py

    r2d568f6 r8c0d9eb  
    3131SMEAR_SIZE_L = 0.00 
    3232SMEAR_SIZE_H = 0.00 
    33  
     33CUSTOM_MODEL = 'Plugin Models' 
    3434 
    3535class FitPage(BasicPage): 
     
    12461246            wx.PostEvent(self.parent, new_event) 
    12471247            # update list of plugins if new plugin is available 
    1248             custom_model = 'Customized Models' 
     1248            custom_model = CUSTOM_MODEL 
    12491249            mod_cat = self.categorybox.GetStringSelection() 
    12501250            if mod_cat == custom_model: 
  • src/sas/sasgui/perspectives/fitting/fitting.py

    r73cbeec rddbac66  
    225225 
    226226        self.id_edit = wx.NewId() 
    227         editmodel_help = "Edit customized model sample file" 
    228227        self.menu1.AppendMenu(self.id_edit, "Plugin Model Operations", 
    229                               self.edit_model_menu, editmodel_help) 
     228                              self.edit_model_menu) 
    230229        #create  menubar items 
    231230        return [(self.menu1, self.sub_menu)] 
     
    260259            self.update_custom_combo() 
    261260            if os.path.isfile(p_path): 
    262                 msg = "Sorry! Could not be able to delete the default " 
    263                 msg += "custom model... \n" 
     261                msg = "Sorry! unable to delete the default " 
     262                msg += "plugin model... \n" 
    264263                msg += "Please manually remove the files (.py, .pyc) " 
    265264                msg += "in the 'plugin_models' folder \n" 
     
    274273                    if item.GetLabel() == label: 
    275274                        self.edit_menu.DeleteItem(item) 
    276                         msg = "The custom model, %s, has been deleted." % label 
     275                        msg = "The plugin model, %s, has been deleted." % label 
    277276                        evt = StatusEvent(status=msg, type='stop', info='info') 
    278277                        wx.PostEvent(self.parent, evt) 
     
    331330            temp = self.fit_panel.reset_pmodel_list() 
    332331            if temp: 
    333                 # Set the new custom model list for all fit pages 
     332                # Set the new plugin model list for all fit pages 
    334333                for uid, page in self.fit_panel.opened_pages.iteritems(): 
    335334                    if hasattr(page, "formfactorbox"): 
     
    19651964                ## then kill itself but cannot.  Paul Kienzle came up with 
    19661965                ## this fix to prevent threads from stepping on each other 
    1967                 ## which was causing a simple custom model to crash Sasview. 
     1966                ## which was causing a simple custom plugin model to crash 
     1967                ##Sasview. 
    19681968                ## We still don't know why the fit sometimes lauched a second 
    19691969                ## thread -- something which should also be investigated. 
  • src/sas/sasgui/perspectives/fitting/media/fitting_help.rst

    r26c8be3 r5295cf5  
    3434*  in *Single* fit mode - individual data sets are fitted independently one-by-one 
    3535 
    36 *  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) 
    3739 
    3840*  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!) 
     
    4345----------------- 
    4446 
    45 By default, the models in SasView are grouped into five categories 
    46  
    47 *  *Shapes* - models describing 'objects' (spheres, cylinders, etc) 
     47The 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) 
    4856*  *Shape-Independent* - models describing structure in terms of density correlation functions, fractals, peaks, power laws, etc 
    49 *  *Customized Models* - SasView- or User-created (non-library) Python models 
    50 *  *Uncategorised* - other models (for reflectivity, etc) 
     57*  *Paracrystal* - semi ordered structures (bcc, fcc, etc) 
    5158*  *Structure Factor* - S(Q) models 
     59*  *Plugin Models* - User-created (custom/non-library) Python models 
    5260 
    5361Use the *Category* drop-down menu to chose a category of model, then select 
     
    8492.. image:: cat_fig0.bmp 
    8593 
    86 The categorization of all models except the customized models can be reassigned, 
    87 added to, and removed using *Category Manager*. Models can also be hidden from view 
    88 in the drop-down menus. 
     94The categorization of all models except the user supplied Plugin Models can be 
     95reassigned, added to, and removed using *Category Manager*. Models can also be 
     96hidden from view in the drop-down menus. 
    8997 
    9098.. image:: cat_fig1.bmp 
     
    93101^^^^^^^^^^^^^^^^^ 
    94102 
    95 To change category, highlight a model in the list by left-clicking on its entry and 
    96 then click the *Modify* button. Use the *Change Category* panel that appears to make 
    97 the required changes. 
     103To change category, highlight a model in the list by left-clicking on its entry 
     104and then click the *Modify* button. Use the *Change Category* panel that appears 
     105to make the required changes. 
    98106 
    99107.. image:: cat_fig2.bmp 
     
    106114^^^^^^^^^^^^^^^^^^^^^ 
    107115 
    108 Use the *Enable All / Disable All* buttons and the check boxes beside each model to 
    109 select the models to show/hide. To apply the selection, click *Ok*. Otherwise click 
    110 *Cancel*. 
     116Use the *Enable All / Disable All* buttons and the check boxes beside each model 
     117to select the models to show/hide. To apply the selection, click *Ok*. Otherwise 
     118click *Cancel*. 
    111119 
    112120*NB: It may be necessary to change to a different category and then back again* 
     
    118126--------------- 
    119127 
    120 For a complete list of all the library models available in SasView, see the `Model Documentation <../../../index.html>`_ . 
     128For a complete list of all the library models available in SasView, see 
     129the `Model Documentation <../../../index.html>`_ . 
    121130 
    122131It is also possible to add your own models. 
     
    131140There are essentially three ways to generate new fitting models for SasView: 
    132141 
    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!) 
     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!) 
    136149 
    137150Please read the guidance on :ref:`Writing_a_Plugin` before proceeding. 
     
    163176^^^^^^^^^^^^^^^^ 
    164177 
    165 Relatively straightforward models can be programmed directly from the SasView GUI  
    166 using the *New Plugin Model Function*. 
     178Relatively straightforward models can be programmed directly from the SasView 
     179GUI using the *New Plugin Model Function*. 
    167180 
    168181.. image:: new_model.bmp 
     
    175188*checked*\ . 
    176189 
    177 Also note that the 'Fit Parameters' have been split into two sections: those which  
    178 can be polydisperse (shape and orientation parameters) and those which are not 
    179 (eg, scattering length densities). 
     190Also note that the 'Fit Parameters' have been split into two sections: those 
     191which can be polydisperse (shape and orientation parameters) and those which are 
     192not (eg, scattering length densities). 
    180193 
    181194A model file generated by this option can be viewed and further modified using 
     
    187200.. image:: sum_model.bmp 
    188201 
    189 This option creates a custom model of the form:: 
    190  
    191      Custom Model = scale_factor \* {(scale_1 \* model_1) \+ (scale_2 \* model_2)} \+ background 
     202This option creates a custom Plugin Model of the form:: 
     203 
     204     Plugin Model = scale_factor * {(scale_1 * model_1) +/- (scale_2 * model_2)} + background 
    192205 
    193206or:: 
    194207 
    195      Custom Model = scale_factor \* model_1 \* model_2 \+ background 
     208     Plugin Model = scale_factor * model_1 /* model_2 + background 
    196209 
    197210In the *Easy Sum/Multi Editor* give the new model a function name and brief 
     
    232245Simply highlight the plugin model to be removed. The operation is final!!! 
    233246 
    234 *NB: Plugin models shipped with SasView cannot be removed in this way.* 
     247*NB: Models shipped with SasView cannot be removed in this way.* 
    235248 
    236249Load Plugin Models 
    237250^^^^^^^^^^^^^^^^^^ 
    238251 
    239 This option loads (or re-loads) all models present in the *~\\.sasview\\plugin_models* folder. 
     252This option loads (or re-loads) all models present in the 
     253*~\\.sasview\\plugin_models* folder. 
    240254 
    241255.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
     
    400414:ref:`Assessing_Fit_Quality`. 
    401415 
    402 *NB: If you need to use a customized model, you must ensure that model is available* 
    403 *first (see* :ref:`Adding_your_own_models` *).* 
     416*NB: If you need to use a custom Plugin Model, you must ensure that model is 
     417available first (see* :ref:`Adding_your_own_models` *).* 
    404418 
    405419Method 
     
    484498If multiple data sets are in one file, load just that file. *Unselect All Data*, then 
    485499select a single initial data set to be fitted. Fit that selected data set as described 
    486 above under :ref:`Single_Fit_Mode` . 
    487  
    488 *NB: If you need to use a customized model, you must ensure that model is available* 
    489 *first (see* :ref:`Adding_your_own_models` *).* 
     500above under :ref:`Single_Fit_Mode`. 
     501 
     502*NB: If you need to use a custom Plugin Model, you must ensure that model is 
     503available first (see* :ref:`Adding_your_own_models` *).* 
    490504 
    491505Method 
  • src/sas/sasgui/perspectives/fitting/media/plugin.rst

    rca6cbc1c r5295cf5  
    2727 
    2828the next time SasView is started it will compile the plugin and add 
    29 it to the list of *Customized Models* in a FitPage. 
     29it to the list of *Plugin Models* in a FitPage. 
    3030 
    3131SasView models can be of three types: 
  • src/sas/sasgui/perspectives/fitting/models.py

    r0de74af r11b094f  
    325325                    self.plugins.append(plug) 
    326326                    self.model_dictionary[name] = plug 
    327             self.model_combobox.set_list("Customized Models", self.plugins) 
     327            self.model_combobox.set_list("Plugin Models", self.plugins) 
    328328            return self.model_combobox.get_list() 
    329329        else: 
     
    346346            self.model_dictionary[name] = plug 
    347347 
    348         self.model_combobox.reset_list("Customized Models", self.plugins) 
     348        self.model_combobox.reset_list("Plugin Models", self.plugins) 
    349349        return self.model_combobox.get_list() 
    350350 
     
    389389#                                     self.shape_indep_list) 
    390390        self.model_combobox.set_list("Structure Factors", self.struct_list) 
    391         self.model_combobox.set_list("Customized Models", self.plugins) 
     391        self.model_combobox.set_list("Plugin Models", self.plugins) 
    392392        self.model_combobox.set_list("P(Q)*S(Q)", self.multiplication_factor) 
    393393        self.model_combobox.set_list("multiplication", 
  • src/sas/sasgui/perspectives/fitting/pagestate.py

    r6d2b50b r71601312  
    3333from sas.sascalc.dataloader.data_info import Data2D, Collimation, Detector 
    3434from sas.sascalc.dataloader.data_info import Process, Aperture 
     35 
    3536# Information to read/write state as xml 
    3637FITTING_NODE_NAME = 'fitting_plug_in' 
    3738CANSAS_NS = "cansas1d/1.0" 
     39 
     40CUSTOM_MODEL = 'Plugin Models' 
     41CUSTOM_MODEL_OLD = 'Customized Models' 
    3842 
    3943LIST_OF_DATA_ATTRIBUTES = [["is_data", "is_data", "bool"], 
     
    366370        :return: None 
    367371        """ 
     372        if self.categorycombobox == CUSTOM_MODEL_OLD: 
     373            self.categorycombobox = CUSTOM_MODEL 
    368374        if self.formfactorcombobox == '': 
    369375            FIRST_FORM = { 
     
    378384                'Sphere' : 'adsorbed_layer', 
    379385                'Structure Factor' : 'hardsphere', 
    380                 'Customized Models' : '' 
     386                CUSTOM_MODEL : '' 
    381387            } 
    382388            if self.categorycombobox == '': 
  • src/sas/sasgui/perspectives/fitting/model_thread.py

    rc1681ea rc1c9929  
    177177            unsmeared_output = numpy.zeros((len(self.data.x))) 
    178178            unsmeared_output[first_bin:last_bin+1] = self.model.evalDistribution(mask) 
     179            self.smearer.model = self.model 
    179180            output = self.smearer(unsmeared_output, first_bin, last_bin) 
    180181 
Note: See TracChangeset for help on using the changeset viewer.