Ignore:
File:
1 edited

Legend:

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

    r2469df7 rd247504b  
    660660        Do the layout for parameter related widgets 
    661661        """ 
    662         param_txt = wx.StaticText(self, -1, 'Fit Parameters NOT requiring' + \ 
    663                                   ' polydispersity (if any): ') 
    664  
    665         param_tip = "#Set the parameters NOT requiring polydispersity " + \ 
    666         "and their initial values.\n" 
     662        param_txt = wx.StaticText(self, -1, 'Fit Parameters: ') 
     663 
     664        param_tip = "#Set the parameters and their initial values.\n" 
    667665        param_tip += "#Example:\n" 
    668666        param_tip += "A = 1\nB = 1" 
     
    678676                                  (self.param_tcl, 1, wx.EXPAND | wx.ALL, 10)]) 
    679677 
    680         # Parameters with polydispersity 
    681         pd_param_txt = wx.StaticText(self, -1, 'Fit Parameters requiring ' + \ 
    682                                      'polydispersity (if any): ') 
    683  
    684         pd_param_tip = "#Set the parameters requiring polydispersity and " + \ 
    685         "their initial values.\n" 
    686         pd_param_tip += "#Example:\n" 
    687         pd_param_tip += "C = 2\nD = 2" 
    688         newid = wx.NewId() 
    689         self.pd_param_tcl = EditWindow(self, newid, wx.DefaultPosition, 
    690                                     wx.DefaultSize, 
    691                                     wx.CLIP_CHILDREN | wx.SUNKEN_BORDER) 
    692         self.pd_param_tcl.setDisplayLineNumbers(True) 
    693         self.pd_param_tcl.SetToolTipString(pd_param_tip) 
    694  
    695         self.param_sizer.AddMany([(pd_param_txt, 0, wx.LEFT, 10), 
    696                                   (self.pd_param_tcl, 1, wx.EXPAND | wx.ALL, 10)]) 
    697678 
    698679    def _layout_function(self): 
     
    896877            description = self.desc_tcl.GetValue() 
    897878            param_str = self.param_tcl.GetText() 
    898             pd_param_str = self.pd_param_tcl.GetText() 
    899879            func_str = self.function_tcl.GetText() 
    900880            # No input for the model function 
     
    902882                if func_str.count('return') > 0: 
    903883                    self.write_file(self.fname, name, description, param_str, 
    904                                     pd_param_str, func_str) 
     884                                    func_str) 
    905885                    try: 
    906886                        result, msg = check_model(self.fname), None 
     
    942922        self.warning = msg 
    943923 
    944     def write_file(self, fname, name, desc_str, param_str, pd_param_str, func_str): 
     924    def write_file(self, fname, name, desc_str, param_str, func_str): 
    945925        """ 
    946926        Write content in file 
     
    949929        :param desc_str: content of the description strings 
    950930        :param param_str: content of params; Strings 
    951         :param pd_param_str: content of params requiring polydispersity; Strings 
    952931        :param func_str: content of func; Strings 
    953932        """ 
     
    963942        # Write out parameters 
    964943        param_names = []    # to store parameter names 
    965         pd_params = [] 
    966944        out_f.write('parameters = [ \n') 
    967945        out_f.write('#   ["name", "units", default, [lower, upper], "type", "description"],\n') 
     
    970948            out_f.write("    ['%s', '', %s, [-inf, inf], '', '%s'],\n" 
    971949                        % (pname, pvalue, desc)) 
    972         for pname, pvalue, desc in self.get_param_helper(pd_param_str): 
    973             param_names.append(pname) 
    974             pd_params.append(pname) 
    975             out_f.write("    ['%s', '', %s, [-inf, inf], 'volume', '%s'],\n" 
    976                         % (pname, pvalue, desc)) 
    977950        out_f.write('    ]\n') 
    978951 
    979952        # Write out function definition 
     953        out_f.write('\n') 
    980954        out_f.write('def Iq(%s):\n' % ', '.join(['x'] + param_names)) 
    981955        out_f.write('    """Absolute scattering"""\n') 
     
    987961            out_f.write('    import numpy as np') 
    988962        for func_line in func_str.split('\n'): 
    989             out_f.write('%s%s\n' % (spaces4, func_line)) 
     963            out_f.write('%s%s\n' % ('    ', func_line)) 
    990964        out_f.write('## uncomment the following if Iq works for vector x\n') 
    991965        out_f.write('#Iq.vectorized = True\n') 
    992  
    993         # If polydisperse, create place holders for form_volume, ER and VR 
    994         if pd_params: 
    995             out_f.write('\n') 
    996             out_f.write(CUSTOM_TEMPLATE_PD % {'args': ', '.join(pd_params)}) 
    997966 
    998967        # Create place holder for Iqxy 
     
    11251094description = """%(description)s""" 
    11261095 
    1127 ''' 
    1128  
    1129 CUSTOM_TEMPLATE_PD = '''\ 
    1130 def form_volume(%(args)s): 
    1131     """ 
    1132     Volume of the particles used to compute absolute scattering intensity 
    1133     and to weight polydisperse parameter contributions. 
    1134     """ 
    1135     return 0.0 
    1136  
    1137 def ER(%(args)s): 
    1138     """ 
    1139     Effective radius of particles to be used when computing structure factors. 
    1140  
    1141     Input parameters are vectors ranging over the mesh of polydispersity values. 
    1142     """ 
    1143     return 0.0 
    1144  
    1145 def VR(%(args)s): 
    1146     """ 
    1147     Volume ratio of particles to be used when computing structure factors. 
    1148  
    1149     Input parameters are vectors ranging over the mesh of polydispersity values. 
    1150     """ 
    1151     return 1.0 
    11521096''' 
    11531097 
Note: See TracChangeset for help on using the changeset viewer.