Changes in / [9258c43c:de43192] in sasview


Ignore:
Location:
src/sas/sasgui/perspectives
Files:
2 edited

Legend:

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

    rd247504b rc6dfb9f  
    663663        Do the layout for parameter related widgets 
    664664        """ 
    665         param_txt = wx.StaticText(self, -1, 'Fit Parameters: ') 
    666  
    667         param_tip = "#Set the parameters and their initial values.\n" 
     665        param_txt = wx.StaticText(self, -1, 'Fit Parameters NOT requiring' + \ 
     666                                  ' polydispersity (if any): ') 
     667 
     668        param_tip = "#Set the parameters NOT requiring polydispersity " + \ 
     669        "and their initial values.\n" 
    668670        param_tip += "#Example:\n" 
    669671        param_tip += "A = 1\nB = 1" 
     
    679681                                  (self.param_tcl, 1, wx.EXPAND | wx.ALL, 10)]) 
    680682 
     683        # Parameters with polydispersity 
     684        pd_param_txt = wx.StaticText(self, -1, 'Fit Parameters requiring ' + \ 
     685                                     'polydispersity (if any): ') 
     686 
     687        pd_param_tip = "#Set the parameters requiring polydispersity and " + \ 
     688        "their initial values.\n" 
     689        pd_param_tip += "#Example:\n" 
     690        pd_param_tip += "C = 2\nD = 2" 
     691        newid = wx.NewId() 
     692        self.pd_param_tcl = EditWindow(self, newid, wx.DefaultPosition, 
     693                                    wx.DefaultSize, 
     694                                    wx.CLIP_CHILDREN | wx.SUNKEN_BORDER) 
     695        self.pd_param_tcl.setDisplayLineNumbers(True) 
     696        self.pd_param_tcl.SetToolTipString(pd_param_tip) 
     697 
     698        self.param_sizer.AddMany([(pd_param_txt, 0, wx.LEFT, 10), 
     699                                  (self.pd_param_tcl, 1, wx.EXPAND | wx.ALL, 10)]) 
    681700 
    682701    def _layout_function(self): 
     
    880899            description = self.desc_tcl.GetValue() 
    881900            param_str = self.param_tcl.GetText() 
     901            pd_param_str = self.pd_param_tcl.GetText() 
    882902            func_str = self.function_tcl.GetText() 
    883903            # No input for the model function 
     
    885905                if func_str.count('return') > 0: 
    886906                    self.write_file(self.fname, name, description, param_str, 
    887                                     func_str) 
     907                                    pd_param_str, func_str) 
    888908                    try: 
    889909                        result, msg = check_model(self.fname), None 
     
    925945        self.warning = msg 
    926946 
    927     def write_file(self, fname, name, desc_str, param_str, func_str): 
     947    def write_file(self, fname, name, desc_str, param_str, pd_param_str, func_str): 
    928948        """ 
    929949        Write content in file 
     
    932952        :param desc_str: content of the description strings 
    933953        :param param_str: content of params; Strings 
     954        :param pd_param_str: content of params requiring polydispersity; Strings 
    934955        :param func_str: content of func; Strings 
    935956        """ 
     
    945966        # Write out parameters 
    946967        param_names = []    # to store parameter names 
     968        pd_params = [] 
    947969        out_f.write('parameters = [ \n') 
    948970        out_f.write('#   ["name", "units", default, [lower, upper], "type", "description"],\n') 
     
    951973            out_f.write("    ['%s', '', %s, [-inf, inf], '', '%s'],\n" 
    952974                        % (pname, pvalue, desc)) 
     975        for pname, pvalue, desc in self.get_param_helper(pd_param_str): 
     976            param_names.append(pname) 
     977            pd_params.append(pname) 
     978            out_f.write("    ['%s', '', %s, [-inf, inf], 'volume', '%s'],\n" 
     979                        % (pname, pvalue, desc)) 
    953980        out_f.write('    ]\n') 
    954981 
    955982        # Write out function definition 
    956         out_f.write('\n') 
    957983        out_f.write('def Iq(%s):\n' % ', '.join(['x'] + param_names)) 
    958984        out_f.write('    """Absolute scattering"""\n') 
     
    964990            out_f.write('    import numpy as np') 
    965991        for func_line in func_str.split('\n'): 
    966             out_f.write('%s%s\n' % ('    ', func_line)) 
     992            out_f.write('%s%s\n' % (spaces4, func_line)) 
    967993        out_f.write('## uncomment the following if Iq works for vector x\n') 
    968994        out_f.write('#Iq.vectorized = True\n') 
     995 
     996        # If polydisperse, create place holders for form_volume, ER and VR 
     997        if pd_params: 
     998            out_f.write('\n') 
     999            out_f.write(CUSTOM_TEMPLATE_PD % {'args': ', '.join(pd_params)}) 
    9691000 
    9701001        # Create place holder for Iqxy 
     
    10971128description = """%(description)s""" 
    10981129 
     1130''' 
     1131 
     1132CUSTOM_TEMPLATE_PD = '''\ 
     1133def form_volume(%(args)s): 
     1134    """ 
     1135    Volume of the particles used to compute absolute scattering intensity 
     1136    and to weight polydisperse parameter contributions. 
     1137    """ 
     1138    return 0.0 
     1139 
     1140def ER(%(args)s): 
     1141    """ 
     1142    Effective radius of particles to be used when computing structure factors. 
     1143 
     1144    Input parameters are vectors ranging over the mesh of polydispersity values. 
     1145    """ 
     1146    return 0.0 
     1147 
     1148def VR(%(args)s): 
     1149    """ 
     1150    Volume ratio of particles to be used when computing structure factors. 
     1151 
     1152    Input parameters are vectors ranging over the mesh of polydispersity values. 
     1153    """ 
     1154    return 1.0 
    10991155''' 
    11001156 
  • src/sas/sasgui/perspectives/fitting/media/fitting_help.rst

    r8b89396 r47ace50  
    180180*checked*\ . 
    181181 
     182Also note that the 'Fit Parameters' have been split into two sections: those 
     183which can be polydisperse (shape and orientation parameters) and those which are 
     184not (eg, scattering length densities). 
     185 
    182186A model file generated by this option can be viewed and further modified using 
    183187the :ref:`Advanced_Plugin_Editor` . 
    184188 
    185 Note that the New Plugin Model Feature currently does not allow for parameters 
    186 to be polydisperse.  However they can be edited in the Advanced Editor. 
    187  
    188  
    189 **SasView version 4.2** made it possible to specify whether a plugin created 
    190 with the *New Plugin Model* dialog is actually a form factor P(Q) or a structure 
    191 factor S(Q). To do this, simply add one or other of the following lines under 
    192 the *import* statements. 
     189**SasView version 4.2** made it possible to specify whether a plugin created with 
     190the *New Plugin Model* dialog is actually a form factor P(Q) or a structure factor 
     191S(Q). To do this, simply add one or other of the following lines under the *import* 
     192statements. 
    193193 
    194194For a form factor:: 
     
    200200     structure_factor = True 
    201201 
    202 If the plugin is a structure factor it is *also* necessary to add two variables 
    203 to the parameter list:: 
     202If the plugin is a structure factor it is *also* necessary to add two variables to 
     203the parameter list:: 
    204204 
    205205     parameters = [ 
Note: See TracChangeset for help on using the changeset viewer.