Changes in src/sas/sasgui/perspectives/calculator/model_editor.py [2469df7:d247504b] in sasview
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/calculator/model_editor.py
r2469df7 rd247504b 660 660 Do the layout for parameter related widgets 661 661 """ 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" 667 665 param_tip += "#Example:\n" 668 666 param_tip += "A = 1\nB = 1" … … 678 676 (self.param_tcl, 1, wx.EXPAND | wx.ALL, 10)]) 679 677 680 # Parameters with polydispersity681 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)])697 678 698 679 def _layout_function(self): … … 896 877 description = self.desc_tcl.GetValue() 897 878 param_str = self.param_tcl.GetText() 898 pd_param_str = self.pd_param_tcl.GetText()899 879 func_str = self.function_tcl.GetText() 900 880 # No input for the model function … … 902 882 if func_str.count('return') > 0: 903 883 self.write_file(self.fname, name, description, param_str, 904 pd_param_str,func_str)884 func_str) 905 885 try: 906 886 result, msg = check_model(self.fname), None … … 942 922 self.warning = msg 943 923 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): 945 925 """ 946 926 Write content in file … … 949 929 :param desc_str: content of the description strings 950 930 :param param_str: content of params; Strings 951 :param pd_param_str: content of params requiring polydispersity; Strings952 931 :param func_str: content of func; Strings 953 932 """ … … 963 942 # Write out parameters 964 943 param_names = [] # to store parameter names 965 pd_params = []966 944 out_f.write('parameters = [ \n') 967 945 out_f.write('# ["name", "units", default, [lower, upper], "type", "description"],\n') … … 970 948 out_f.write(" ['%s', '', %s, [-inf, inf], '', '%s'],\n" 971 949 % (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))977 950 out_f.write(' ]\n') 978 951 979 952 # Write out function definition 953 out_f.write('\n') 980 954 out_f.write('def Iq(%s):\n' % ', '.join(['x'] + param_names)) 981 955 out_f.write(' """Absolute scattering"""\n') … … 987 961 out_f.write(' import numpy as np') 988 962 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)) 990 964 out_f.write('## uncomment the following if Iq works for vector x\n') 991 965 out_f.write('#Iq.vectorized = True\n') 992 993 # If polydisperse, create place holders for form_volume, ER and VR994 if pd_params:995 out_f.write('\n')996 out_f.write(CUSTOM_TEMPLATE_PD % {'args': ', '.join(pd_params)})997 966 998 967 # Create place holder for Iqxy … … 1125 1094 description = """%(description)s""" 1126 1095 1127 '''1128 1129 CUSTOM_TEMPLATE_PD = '''\1130 def form_volume(%(args)s):1131 """1132 Volume of the particles used to compute absolute scattering intensity1133 and to weight polydisperse parameter contributions.1134 """1135 return 0.01136 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.01144 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.01152 1096 ''' 1153 1097
Note: See TracChangeset
for help on using the changeset viewer.