Changeset 0008f54 in sasview for calculatorview
- Timestamp:
- Jun 14, 2012 4:22:57 PM (13 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, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- fdef956
- Parents:
- 72538fc
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
calculatorview/src/sans/perspectives/calculator/model_editor.py
r316e231 r0008f54 59 59 def __init__(self, parent=None, base=None, id=None, title='', model_list=[], plugin_dir=None): 60 60 """ 61 Dialog window popup when selecting 'Easy Custom Sum ' on the menu61 Dialog window popup when selecting 'Easy Custom Sum/Multiply' on the menu 62 62 """ 63 63 wx.Dialog.__init__(self, parent=parent, id=id, … … 75 75 self.model2_string = "CylinderModel" 76 76 self._notes = '' 77 self.operator = '+' 77 78 self._msg_box = None 78 79 self.msg_sizer = None … … 89 90 self.name_hsizer = wx.BoxSizer(wx.HORIZONTAL) 90 91 #title name [string] 91 name_txt = wx.StaticText(self, -1, ' SumFunction Name : ')92 name_txt = wx.StaticText(self, -1, 'Function Name : ') 92 93 self.name_tcl = wx.TextCtrl(self, -1, size=(PANEL_WIDTH*3/5, -1)) 93 94 self.name_tcl.Bind(wx.EVT_TEXT_ENTER, self.on_change_name) 94 95 self.name_tcl.SetValue('') 95 96 self.name_tcl.SetFont(self.font) 96 hint_name = "Unique Sum Model Function Name."97 hint_name = "Unique Sum/Multiply Model Function Name." 97 98 self.name_tcl.SetToolTipString(hint_name) 98 99 self.name_hsizer.AddMany([(name_txt, 0, wx.LEFT|wx.TOP, 10), … … 152 153 size=(_BOX_WIDTH/2, 25)) 153 154 # Intro 154 explanation = " custom model = scale_factor * (model1 + model2)\n" 155 explanation = " custom model = scale_factor * (model1 %s model2)\n"\ 156 % self.operator 155 157 #explanation += " Note: This will overwrite the previous sum model.\n" 156 158 model_string = " Model%s (p%s):" … … 231 233 if len(title) > 20: 232 234 s_title = title[0:19] + '...' 233 self._notes = " SumModel function (%s) has been set! \n" % str(s_title)235 self._notes = "Model function (%s) has been set! \n" % str(s_title) 234 236 self.good_name = True 235 237 self.on_apply(self.fname) … … 249 251 self.parent.update_custom_combo() 250 252 msg = self._notes 251 info = 'Info r'253 info = 'Info' 252 254 color = 'blue' 253 255 except: … … 307 309 description = self.desc_tcl.GetValue().lstrip().rstrip() 308 310 if description == '': 309 description = name1 + "+"+ name2311 description = name1 + self.operator + name2 310 312 name = self.name_tcl.GetValue().lstrip().rstrip() 311 313 if name == '': … … 324 326 elif line.count("self.description = '%s'"): 325 327 out_f.write(line % description + "\n") 326 #elif line.count("self.name = '%s'"): 327 # out_f.write(line % name + "\n") 328 elif line.count("run") and line.count("%s"): 329 out_f.write(line % self.operator) 330 elif line.count("evalDistribution") and line.count("%s"): 331 out_f.write(line % self.operator) 328 332 else: 329 333 out_f.write(line + "\n") … … 854 858 """ 855 859 SUM_TEMPLATE = """ 856 # A sample of an experimental model function for Sum (Pmodel1,Pmodel2)860 # A sample of an experimental model function for Sum/Multiply(Pmodel1,Pmodel2) 857 861 import copy 858 862 from sans.models.pluginmodel import Model1DPlugin … … 951 955 p1_name = name1 952 956 name = p1_name 953 name += " +"957 name += "%s"% (self.operator) 954 958 p2_name = self._get_upper_name(name2) 955 959 if not p2_name: … … 1024 1028 1025 1029 def setParam(self, name, value): 1026 # set param to p1+p2model1030 # set param to this (p1, p2) model 1027 1031 self._setParamHelper(name, value) 1028 1032 … … 1093 1097 self._set_scale_factor() 1094 1098 return self.params['scale_factor'] * \ 1095 (self.p_model1.run(x) +self.p_model2.run(x))1099 (self.p_model1.run(x) %s self.p_model2.run(x)) 1096 1100 1097 1101 def runXY(self, x = 0.0): 1098 1102 self._set_scale_factor() 1099 1103 return self.params['scale_factor'] * \ 1100 (self.p_model1.runXY(x) +self.p_model2.runXY(x))1104 (self.p_model1.runXY(x) %s self.p_model2.runXY(x)) 1101 1105 1102 1106 ## Now (May27,10) directly uses the model eval function … … 1105 1109 self._set_scale_factor() 1106 1110 return self.params['scale_factor'] * \ 1107 (self.p_model1.evalDistribution(x) +\1111 (self.p_model1.evalDistribution(x) %s \ 1108 1112 self.p_model2.evalDistribution(x)) 1109 1113 … … 1126 1130 def fill_description(self, p_model1, p_model2): 1127 1131 description = "" 1128 description += "This model gives the summation of %s and %s. "% \1129 ( p_model1.name, p_model2.name )1132 description += "This model gives the summation or multiplication of" 1133 description += "%s and %s. "% ( p_model1.name, p_model2.name ) 1130 1134 self.description += description 1131 1135 … … 1149 1153 #m2.p_model2.setParam("scale", 100) 1150 1154 #m2.p_model2.setParam("rg", 100) 1151 out2 = m2.p_model1.runXY(0.01) + m2.p_model2.runXY(0.01)1155 out2 = m2.p_model1.runXY(0.01) %s m2.p_model2.runXY(0.01)\n 1152 1156 print out1, " = ", out2 1153 1157 if out1 == out2:
Note: See TracChangeset
for help on using the changeset viewer.