[d1e0473] | 1 | |
---|
| 2 | |
---|
[c77d859] | 3 | import sys |
---|
| 4 | import wx |
---|
| 5 | import wx.lib.newevent |
---|
| 6 | import numpy |
---|
| 7 | import copy |
---|
| 8 | import math |
---|
| 9 | from sans.models.dispersion_models import ArrayDispersion, GaussianDispersion |
---|
| 10 | |
---|
| 11 | from sans.guicomm.events import StatusEvent |
---|
[69bee6d] | 12 | from sans.guiframe.utils import format_number,check_float |
---|
[77e23a2] | 13 | |
---|
[b787e68c] | 14 | ## event to post model to fit to fitting plugins |
---|
[c77d859] | 15 | (ModelEventbox, EVT_MODEL_BOX) = wx.lib.newevent.NewEvent() |
---|
[b787e68c] | 16 | |
---|
| 17 | ## event to know the selected fit engine |
---|
[77e23a2] | 18 | (FitterTypeEvent, EVT_FITTER_TYPE) = wx.lib.newevent.NewEvent() |
---|
[34a0c17] | 19 | (FitStopEvent, EVT_FIT_STOP) = wx.lib.newevent.NewEvent() |
---|
[eda428b] | 20 | _BOX_WIDTH = 76 |
---|
[c77d859] | 21 | |
---|
| 22 | import basepage |
---|
| 23 | from basepage import BasicPage |
---|
[b787e68c] | 24 | from basepage import PageInfoEvent |
---|
[997131a] | 25 | from DataLoader.qsmearing import smear_selection |
---|
[c77d859] | 26 | |
---|
| 27 | class FitPage(BasicPage): |
---|
| 28 | """ |
---|
| 29 | FitPanel class contains fields allowing to display results when |
---|
| 30 | fitting a model and one data |
---|
| 31 | @note: For Fit to be performed the user should check at least one parameter |
---|
| 32 | on fit Panel window. |
---|
| 33 | |
---|
| 34 | """ |
---|
[cfc0913] | 35 | def __init__(self,parent, page_info): |
---|
| 36 | BasicPage.__init__(self, parent, page_info) |
---|
[c77d859] | 37 | """ |
---|
| 38 | Initialization of the Panel |
---|
| 39 | """ |
---|
| 40 | ## fit page does not content npts txtcrtl |
---|
| 41 | self.npts=None |
---|
[2b63df0] | 42 | ## thread for compute Chisqr |
---|
| 43 | self.calc_Chisqr=None |
---|
[dcf29d7] | 44 | ## default fitengine type |
---|
[707436d] | 45 | self.engine_type = None |
---|
[b787e68c] | 46 | ## draw sizer |
---|
[c77d859] | 47 | self._fill_datainfo_sizer() |
---|
[da26c1a] | 48 | |
---|
[c77d859] | 49 | self._fill_model_sizer( self.sizer1) |
---|
[cfc0913] | 50 | self._fill_range_sizer() |
---|
[fbf4bf8] | 51 | #self._on_select_model(event=None) |
---|
[997131a] | 52 | if self.data !=None: |
---|
| 53 | self.smearer = smear_selection( self.data ) |
---|
[847091f] | 54 | if self.smearer ==None: |
---|
| 55 | self.enable_smearer.Disable() |
---|
| 56 | self.disable_smearer.Disable() |
---|
[813334e] | 57 | |
---|
[cfc0913] | 58 | ## to update the panel according to the fit engine type selected |
---|
[77e23a2] | 59 | self.Bind(EVT_FITTER_TYPE,self._on_engine_change) |
---|
[34a0c17] | 60 | self.Bind(EVT_FIT_STOP,self._on_fit_complete) |
---|
[77e23a2] | 61 | |
---|
[34a0c17] | 62 | def _on_fit_complete(self, event): |
---|
| 63 | """ |
---|
| 64 | When fit is complete ,reset the fit button label. |
---|
| 65 | """ |
---|
| 66 | #self.btFit.SetLabel("Fit") |
---|
| 67 | #self.btFit.Unbind(event=wx.EVT_BUTTON, id=self.btFit.GetId()) |
---|
| 68 | #self.btFit.Bind(event=wx.EVT_BUTTON, handler=self._onFit,id=self.btFit.GetId()) |
---|
| 69 | pass |
---|
| 70 | |
---|
| 71 | |
---|
[77e23a2] | 72 | def _on_engine_change(self, event): |
---|
| 73 | """ |
---|
| 74 | get an event containing the current name of the fit engine type |
---|
| 75 | @param event: FitterTypeEvent containing the name of the current engine |
---|
| 76 | """ |
---|
[dcf29d7] | 77 | self.engine_type = event.type |
---|
| 78 | |
---|
[77e23a2] | 79 | if len(self.parameters)==0: |
---|
| 80 | return |
---|
[ad6dd4c] | 81 | if event.type =="park": |
---|
| 82 | self.btFit.SetLabel("Fit") |
---|
[77e23a2] | 83 | for item in self.parameters: |
---|
| 84 | if event.type =="scipy": |
---|
[60132ef] | 85 | item[5].SetValue("") |
---|
[77e23a2] | 86 | item[5].Hide() |
---|
[60132ef] | 87 | item[6].SetValue("") |
---|
[77e23a2] | 88 | item[6].Hide() |
---|
| 89 | self.text2_min.Hide() |
---|
| 90 | self.text2_max.Hide() |
---|
| 91 | else: |
---|
| 92 | item[5].Show(True) |
---|
| 93 | item[6].Show(True) |
---|
| 94 | self.text2_min.Show(True) |
---|
| 95 | self.text2_max.Show(True) |
---|
[3fef0a8] | 96 | for item in self.orientation_params: |
---|
| 97 | if event.type =="scipy": |
---|
| 98 | item[5].SetValue("") |
---|
| 99 | item[5].Hide() |
---|
| 100 | item[6].SetValue("") |
---|
| 101 | item[6].Hide() |
---|
| 102 | self.text2_min.Hide() |
---|
| 103 | self.text2_max.Hide() |
---|
| 104 | else: |
---|
| 105 | item[5].Show(True) |
---|
| 106 | item[6].Show(True) |
---|
| 107 | self.text2_min.Show(True) |
---|
| 108 | self.text2_max.Show(True) |
---|
| 109 | |
---|
| 110 | for item in self.orientation_params_disp: |
---|
| 111 | if event.type =="scipy": |
---|
| 112 | item[5].SetValue("") |
---|
| 113 | item[5].Hide() |
---|
| 114 | item[6].SetValue("") |
---|
| 115 | item[6].Hide() |
---|
| 116 | self.text2_min.Hide() |
---|
| 117 | self.text2_max.Hide() |
---|
| 118 | else: |
---|
| 119 | item[5].Show(True) |
---|
| 120 | item[6].Show(True) |
---|
| 121 | self.text2_min.Show(True) |
---|
| 122 | self.text2_max.Show(True) |
---|
[77e23a2] | 123 | |
---|
| 124 | self.sizer3.Layout() |
---|
| 125 | self.SetScrollbars(20,20,200,100) |
---|
[c77d859] | 126 | |
---|
| 127 | |
---|
| 128 | def _fill_range_sizer(self): |
---|
| 129 | """ |
---|
| 130 | Fill the sizer containing the plotting range |
---|
| 131 | add access to npts |
---|
| 132 | """ |
---|
[1ae3fe1] | 133 | sizer_fit = wx.GridSizer(1, 1,0, 0) |
---|
[c77d859] | 134 | |
---|
| 135 | self.btFit = wx.Button(self,wx.NewId(),'Fit') |
---|
| 136 | self.btFit.Bind(wx.EVT_BUTTON, self._onFit,id= self.btFit.GetId()) |
---|
| 137 | self.btFit.SetToolTipString("Perform fit.") |
---|
[2d5f7a1] | 138 | |
---|
[c77d859] | 139 | |
---|
| 140 | sizer_fit.Add((5,5),1, wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 5) |
---|
[1ae3fe1] | 141 | sizer_fit.Add(self.btFit,0, wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 5) |
---|
[c77d859] | 142 | |
---|
| 143 | sizer_smearer = wx.BoxSizer(wx.HORIZONTAL) |
---|
| 144 | #Filling the sizer containing instruments smearing info. |
---|
| 145 | self.disable_smearer = wx.RadioButton(self, -1, 'No', style=wx.RB_GROUP) |
---|
| 146 | self.enable_smearer = wx.RadioButton(self, -1, 'Yes') |
---|
| 147 | self.Bind(wx.EVT_RADIOBUTTON, self.onSmear, id=self.disable_smearer.GetId()) |
---|
| 148 | self.Bind(wx.EVT_RADIOBUTTON, self.onSmear, id=self.enable_smearer.GetId()) |
---|
| 149 | |
---|
| 150 | sizer_smearer.Add(wx.StaticText(self,-1,'Instrument Smearing? ')) |
---|
| 151 | sizer_smearer.Add((10, 10)) |
---|
| 152 | sizer_smearer.Add( self.enable_smearer ) |
---|
| 153 | sizer_smearer.Add((10,10)) |
---|
| 154 | sizer_smearer.Add( self.disable_smearer ) |
---|
| 155 | |
---|
[7b0fd65] | 156 | #Display Chi^2/dof |
---|
[d1e0473] | 157 | sizer_smearer.Add((68,10)) |
---|
[7b0fd65] | 158 | box_description= wx.StaticBox(self, -1,'Chi2/dof') |
---|
| 159 | boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL) |
---|
[2a5bba7] | 160 | boxsizer1.SetMinSize((60,-1)) |
---|
[2b63df0] | 161 | temp_smearer = None |
---|
| 162 | if self.enable_smearer.GetValue(): |
---|
| 163 | temp_smearer= self.smearer |
---|
| 164 | |
---|
| 165 | self.tcChi = wx.StaticText(self, -1, "-", style=wx.ALIGN_LEFT) |
---|
| 166 | |
---|
[7b0fd65] | 167 | boxsizer1.Add( self.tcChi ) |
---|
| 168 | sizer_smearer.Add( boxsizer1 ) |
---|
| 169 | |
---|
| 170 | #Set sizer for Fitting section |
---|
[45bf0ede] | 171 | self._set_range_sizer( title="Fitting", |
---|
[c77d859] | 172 | object1=sizer_smearer, object= sizer_fit) |
---|
[7b0fd65] | 173 | |
---|
[c77d859] | 174 | |
---|
| 175 | def _fill_datainfo_sizer(self): |
---|
| 176 | """ |
---|
| 177 | fill sizer 0 with data info |
---|
| 178 | """ |
---|
| 179 | self.sizer0.Clear(True) |
---|
| 180 | ## no loaded data , don't fill the sizer |
---|
| 181 | if self.data== None: |
---|
| 182 | self.sizer0.Layout() |
---|
| 183 | return |
---|
| 184 | |
---|
[fa58441] | 185 | box_description= wx.StaticBox(self, -1, 'Data') |
---|
[c77d859] | 186 | boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL) |
---|
| 187 | #---------------------------------------------------------- |
---|
| 188 | sizer_data = wx.GridSizer(3, 3,5, 5) |
---|
| 189 | #Filling the sizer containing data related fields |
---|
| 190 | DataSource =wx.StaticText(self, -1,str(self.data.name)) |
---|
| 191 | |
---|
[fa58441] | 192 | sizer_data.Add(wx.StaticText(self, -1, 'Source Name : ')) |
---|
[c77d859] | 193 | sizer_data.Add(DataSource ) |
---|
[2a5bba7] | 194 | sizer_data.Add( (0,5) ) |
---|
[c77d859] | 195 | |
---|
| 196 | #---------sizer 2 draw-------------------------------- |
---|
| 197 | #set maximum range for x in linear scale |
---|
| 198 | if not hasattr(self.data,"data"): #Display only for 1D data fit |
---|
| 199 | # Minimum value of data |
---|
[813334e] | 200 | data_min = min(self.data.x) |
---|
[c77d859] | 201 | # Maximum value of data |
---|
[813334e] | 202 | data_max = max(self.data.x) |
---|
[7b0fd65] | 203 | text4_3 = wx.StaticText(self, -1, 'Total Q Range (1/A)', |
---|
[c77d859] | 204 | style=wx.ALIGN_LEFT) |
---|
| 205 | sizer_data.Add( text4_3 ) |
---|
[813334e] | 206 | sizer_data.Add(wx.StaticText(self, -1, "Min : %s"%str(data_min))) |
---|
| 207 | sizer_data.Add(wx.StaticText(self, -1, "Max : %s"%str(data_max))) |
---|
[c77d859] | 208 | |
---|
| 209 | else: |
---|
[813334e] | 210 | ## Minimum value of data |
---|
| 211 | data_min= 0 |
---|
| 212 | x= max(math.fabs(self.data.xmin), math.fabs(self.data.xmax)) |
---|
| 213 | y= max(math.fabs(self.data.ymin), math.fabs(self.data.ymax)) |
---|
| 214 | ## Maximum value of data |
---|
| 215 | data_max = math.sqrt(x*x + y*y) |
---|
| 216 | |
---|
[d2d0cfdf] | 217 | #For qmin and qmax, do not use format_number |
---|
| 218 | #.(If do, qmin and max could be different from what is in the data.) |
---|
[d1e0473] | 219 | text4_3 = wx.StaticText(self, -1, "Total Q Range (1/A)", |
---|
[c77d859] | 220 | style=wx.ALIGN_LEFT) |
---|
| 221 | sizer_data.Add( text4_3 ) |
---|
[813334e] | 222 | sizer_data.Add(wx.StaticText(self, -1, "Min : %s"%str(data_min))) |
---|
| 223 | sizer_data.Add(wx.StaticText(self, -1, "Max : %s"%str(data_max))) |
---|
| 224 | ## set q range to plot |
---|
| 225 | self.qmin_x= data_min |
---|
| 226 | self.qmax_x= data_max |
---|
| 227 | |
---|
[c77d859] | 228 | boxsizer1.Add(sizer_data) |
---|
| 229 | #------------------------------------------------------------ |
---|
| 230 | self.sizer0.Add(boxsizer1,0, wx.EXPAND | wx.ALL, 10) |
---|
| 231 | self.sizer0.Layout() |
---|
[813334e] | 232 | |
---|
[c77d859] | 233 | |
---|
[7b0fd65] | 234 | |
---|
[c77d859] | 235 | def _fill_model_sizer(self, sizer): |
---|
| 236 | """ |
---|
| 237 | fill sizer containing model info |
---|
| 238 | """ |
---|
[87fbc60] | 239 | |
---|
[c77d859] | 240 | ## class base method to add view 2d button |
---|
[7b0fd65] | 241 | self._set_model_sizer(sizer=sizer, title="Model",object=None ) |
---|
| 242 | |
---|
[c77d859] | 243 | |
---|
| 244 | def _set_sizer_gaussian(self): |
---|
| 245 | """ |
---|
| 246 | draw sizer with gaussian dispersity parameters |
---|
| 247 | """ |
---|
| 248 | self.fittable_param=[] |
---|
| 249 | self.fixed_param=[] |
---|
[60132ef] | 250 | self.orientation_params_disp=[] |
---|
| 251 | |
---|
[c77d859] | 252 | self.sizer4_4.Clear(True) |
---|
| 253 | |
---|
| 254 | if self.model==None: |
---|
| 255 | ##no model is selected |
---|
| 256 | return |
---|
| 257 | if not self.enable_disp.GetValue(): |
---|
| 258 | ## the user didn't select dispersity display |
---|
| 259 | return |
---|
[376916c] | 260 | |
---|
| 261 | self._reset_dispersity() |
---|
| 262 | # Create the dispersion objects |
---|
| 263 | for item in self.model.dispersion.keys(): |
---|
| 264 | disp_model = GaussianDispersion() |
---|
| 265 | self._disp_obj_dict[item] = disp_model |
---|
| 266 | self.model.set_dispersion(item, disp_model) |
---|
[c477b31] | 267 | self.state._disp_obj_dict[item]= disp_model |
---|
[376916c] | 268 | |
---|
[c77d859] | 269 | ix=0 |
---|
| 270 | iy=1 |
---|
| 271 | disp = wx.StaticText(self, -1, 'Names') |
---|
| 272 | self.sizer4_4.Add(disp,( iy, ix),(1,1), |
---|
| 273 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 274 | ix += 1 |
---|
| 275 | values = wx.StaticText(self, -1, 'Values') |
---|
| 276 | self.sizer4_4.Add(values,( iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 277 | ix +=2 |
---|
| 278 | self.text_disp_1 = wx.StaticText(self, -1, 'Errors') |
---|
| 279 | self.sizer4_4.Add( self.text_disp_1,(iy, ix),(1,1),\ |
---|
| 280 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 281 | self.text_disp_1.Hide() |
---|
| 282 | ix += 1 |
---|
| 283 | npts = wx.StaticText(self, -1, 'Npts') |
---|
| 284 | self.sizer4_4.Add(npts,( iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 285 | ix += 1 |
---|
| 286 | nsigmas = wx.StaticText(self, -1, 'Nsigmas') |
---|
| 287 | self.sizer4_4.Add(nsigmas,( iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 288 | |
---|
| 289 | for item in self.model.dispersion.keys(): |
---|
[780d095] | 290 | if not item in self.model.orientation_params: |
---|
| 291 | self.disp_cb_dict[item]= None |
---|
| 292 | name1=item+".width" |
---|
| 293 | name2=item+".npts" |
---|
| 294 | name3=item+".nsigmas" |
---|
| 295 | iy += 1 |
---|
| 296 | for p in self.model.dispersion[item].keys(): |
---|
| 297 | |
---|
| 298 | if p=="width": |
---|
| 299 | ix = 0 |
---|
| 300 | cb = wx.CheckBox(self, -1, name1, (10, 10)) |
---|
| 301 | wx.EVT_CHECKBOX(self, cb.GetId(), self.select_param) |
---|
| 302 | self.sizer4_4.Add( cb,( iy, ix),(1,1), |
---|
| 303 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 304 | ix = 1 |
---|
| 305 | value= self.model.getParam(name1) |
---|
| 306 | ctl1 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), |
---|
[c77d859] | 307 | style=wx.TE_PROCESS_ENTER) |
---|
[780d095] | 308 | ctl1.SetValue(str (format_number(value))) |
---|
| 309 | ctl1.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) |
---|
| 310 | ctl1.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) |
---|
| 311 | ctl1.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter) |
---|
| 312 | self.sizer4_4.Add(ctl1, (iy,ix),(1,1),wx.EXPAND) |
---|
| 313 | ## text to show error sign |
---|
| 314 | ix = 2 |
---|
| 315 | text2=wx.StaticText(self, -1, '+/-') |
---|
| 316 | self.sizer4_4.Add(text2,(iy, ix),(1,1), |
---|
| 317 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 318 | text2.Hide() |
---|
| 319 | ## txtcrtl to add error from fit |
---|
| 320 | ix = 3 |
---|
| 321 | ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=wx.TE_PROCESS_ENTER) |
---|
| 322 | self.sizer4_4.Add(ctl2, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 323 | ctl2.Hide() |
---|
| 324 | self.fittable_param.append([cb,name1,ctl1,text2, |
---|
| 325 | ctl2, None, None,None]) |
---|
| 326 | elif p=="npts": |
---|
| 327 | ix = 4 |
---|
| 328 | value= self.model.getParam(name2) |
---|
| 329 | Tctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/2,20), |
---|
| 330 | style=wx.TE_PROCESS_ENTER) |
---|
| 331 | |
---|
| 332 | Tctl.SetValue(str (format_number(value))) |
---|
| 333 | Tctl.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) |
---|
| 334 | Tctl.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) |
---|
| 335 | Tctl.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter) |
---|
| 336 | self.sizer4_4.Add(Tctl, (iy,ix),(1,1), |
---|
| 337 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 338 | self.fixed_param.append([None,name2, Tctl,None,None, |
---|
| 339 | None, None,None]) |
---|
| 340 | elif p=="nsigmas": |
---|
| 341 | ix = 5 |
---|
| 342 | value= self.model.getParam(name3) |
---|
| 343 | Tctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/2,20), |
---|
| 344 | style=wx.TE_PROCESS_ENTER) |
---|
| 345 | Tctl.SetValue(str (format_number(value))) |
---|
| 346 | Tctl.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) |
---|
| 347 | Tctl.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) |
---|
| 348 | Tctl.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter) |
---|
| 349 | self.sizer4_4.Add(Tctl, (iy,ix),(1,1), |
---|
| 350 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 351 | ix +=1 |
---|
| 352 | self.sizer4_4.Add((20,20), (iy,ix),(1,1), |
---|
| 353 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 354 | |
---|
| 355 | self.fixed_param.append([None,name3, Tctl |
---|
| 356 | ,None,None, None, None,None]) |
---|
| 357 | ix =0 |
---|
| 358 | iy +=1 |
---|
| 359 | self.sizer4_4.Add((20,20),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 360 | for item in self.model.dispersion.keys(): |
---|
| 361 | if item in self.model.orientation_params: |
---|
| 362 | self.disp_cb_dict[item]= None |
---|
| 363 | name1=item+".width" |
---|
| 364 | name2=item+".npts" |
---|
| 365 | name3=item+".nsigmas" |
---|
| 366 | iy += 1 |
---|
| 367 | for p in self.model.dispersion[item].keys(): |
---|
| 368 | |
---|
| 369 | if p=="width": |
---|
| 370 | ix = 0 |
---|
| 371 | cb = wx.CheckBox(self, -1, name1, (10, 10)) |
---|
| 372 | wx.EVT_CHECKBOX(self, cb.GetId(), self.select_param) |
---|
| 373 | self.sizer4_4.Add( cb,( iy, ix),(1,1), |
---|
| 374 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 375 | if self.data.__class__.__name__ =="Data2D": |
---|
| 376 | cb.Enable() |
---|
| 377 | else: |
---|
| 378 | cb.Disable() |
---|
| 379 | ix = 1 |
---|
| 380 | value= self.model.getParam(name1) |
---|
| 381 | ctl1 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), |
---|
[c77d859] | 382 | style=wx.TE_PROCESS_ENTER) |
---|
[780d095] | 383 | ctl1.SetValue(str (format_number(value))) |
---|
| 384 | if self.data.__class__.__name__ =="Data2D": |
---|
| 385 | ctl1.Enable() |
---|
| 386 | else: |
---|
| 387 | ctl1.Disable() |
---|
| 388 | ctl1.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) |
---|
| 389 | ctl1.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) |
---|
| 390 | ctl1.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter) |
---|
| 391 | self.sizer4_4.Add(ctl1, (iy,ix),(1,1),wx.EXPAND) |
---|
| 392 | ## text to show error sign |
---|
| 393 | ix = 2 |
---|
| 394 | text2=wx.StaticText(self, -1, '+/-') |
---|
| 395 | self.sizer4_4.Add(text2,(iy, ix),(1,1), |
---|
| 396 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 397 | text2.Hide() |
---|
| 398 | ## txtcrtl to add error from fit |
---|
| 399 | ix = 3 |
---|
| 400 | ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=wx.TE_PROCESS_ENTER) |
---|
| 401 | self.sizer4_4.Add(ctl2, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 402 | ctl2.Hide() |
---|
| 403 | if self.data.__class__.__name__ =="Data2D": |
---|
| 404 | ctl2.Enable() |
---|
| 405 | else: |
---|
| 406 | ctl2.Disable() |
---|
| 407 | self.fittable_param.append([cb,name1,ctl1,text2, |
---|
| 408 | ctl2, None, None,None]) |
---|
[60132ef] | 409 | self.orientation_params_disp.append([cb,name1,ctl1,text2, |
---|
[780d095] | 410 | ctl2, None, None,None]) |
---|
| 411 | elif p=="npts": |
---|
| 412 | ix = 4 |
---|
| 413 | value= self.model.getParam(name2) |
---|
| 414 | Tctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/2,20), |
---|
| 415 | style=wx.TE_PROCESS_ENTER) |
---|
| 416 | |
---|
| 417 | Tctl.SetValue(str (format_number(value))) |
---|
| 418 | if self.data.__class__.__name__ =="Data2D": |
---|
| 419 | Tctl.Enable() |
---|
| 420 | else: |
---|
| 421 | Tctl.Disable() |
---|
| 422 | Tctl.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) |
---|
| 423 | Tctl.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) |
---|
| 424 | Tctl.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter) |
---|
| 425 | self.sizer4_4.Add(Tctl, (iy,ix),(1,1), |
---|
| 426 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 427 | self.fixed_param.append([None,name2, Tctl,None,None, |
---|
| 428 | None, None,None]) |
---|
[60132ef] | 429 | self.orientation_params_disp.append([None,name2, Tctl,None,None, |
---|
[780d095] | 430 | None, None,None]) |
---|
| 431 | elif p=="nsigmas": |
---|
| 432 | ix = 5 |
---|
| 433 | value= self.model.getParam(name3) |
---|
| 434 | Tctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/2,20), |
---|
| 435 | style=wx.TE_PROCESS_ENTER) |
---|
| 436 | Tctl.SetValue(str (format_number(value))) |
---|
| 437 | if self.data.__class__.__name__ =="Data2D": |
---|
| 438 | Tctl.Enable() |
---|
| 439 | else: |
---|
| 440 | Tctl.Disable() |
---|
| 441 | Tctl.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) |
---|
| 442 | Tctl.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) |
---|
| 443 | Tctl.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter) |
---|
| 444 | self.sizer4_4.Add(Tctl, (iy,ix),(1,1), |
---|
| 445 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 446 | ix +=1 |
---|
| 447 | self.sizer4_4.Add((20,20), (iy,ix),(1,1), |
---|
| 448 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 449 | self.fixed_param.append([None,name3, Tctl |
---|
| 450 | ,None,None, None, None,None]) |
---|
[60132ef] | 451 | self.orientation_params_disp.append([None,name3, Tctl |
---|
[1c1436d] | 452 | ,None,None, None, None,None]) |
---|
[d2d0cfdf] | 453 | |
---|
[c477b31] | 454 | self.state.disp_cb_dict = copy.deepcopy(self.disp_cb_dict) |
---|
[c77d859] | 455 | wx.PostEvent(self.parent, StatusEvent(status=\ |
---|
| 456 | " Selected Distribution: Gaussian")) |
---|
| 457 | ix =0 |
---|
| 458 | iy +=1 |
---|
| 459 | self.sizer4_4.Add((20,20),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 460 | self.sizer4_4.Layout() |
---|
| 461 | self.sizer4.Layout() |
---|
| 462 | self.SetScrollbars(20,20,200,100) |
---|
[0a518e4c] | 463 | |
---|
[c77d859] | 464 | |
---|
| 465 | def _onFit(self, event): |
---|
| 466 | """ |
---|
| 467 | Allow to fit |
---|
| 468 | """ |
---|
| 469 | from sans.guiframe.utils import check_value |
---|
| 470 | flag = check_value( self.qmin, self.qmax) |
---|
| 471 | |
---|
| 472 | if not flag: |
---|
| 473 | msg= "Fitting range invalid" |
---|
| 474 | wx.PostEvent(self.parent.parent, StatusEvent(status= msg )) |
---|
| 475 | return |
---|
| 476 | |
---|
| 477 | if len(self.param_toFit) <= 0: |
---|
| 478 | msg= "Select at least one parameter to fit" |
---|
| 479 | wx.PostEvent(self.parent.parent, StatusEvent(status= msg )) |
---|
| 480 | return |
---|
[d0ce2c30] | 481 | |
---|
| 482 | # Remove or do not allow fitting on the Q=0 point, especially when y(q=0)=None at x[0]. |
---|
[ad6dd4c] | 483 | #ToDo: Fix this. |
---|
[1c1436d] | 484 | self.qmin_x = float(self.qmin.GetValue()) |
---|
[c77d859] | 485 | self.qmax_x =float( self.qmax.GetValue()) |
---|
[6f023e8] | 486 | self.manager._reset_schedule_problem( value=0) |
---|
[ca7a626] | 487 | self.manager.schedule_for_fit( value=1,page=self,fitproblem =None) |
---|
| 488 | self.manager.set_fit_range(page= self,qmin= self.qmin_x, qmax= self.qmax_x) |
---|
[ad6dd4c] | 489 | |
---|
[c77d859] | 490 | #single fit |
---|
[ca7a626] | 491 | self.manager.onFit() |
---|
[ad6dd4c] | 492 | ## allow stopping the fit |
---|
[34a0c17] | 493 | #if self.engine_type=="scipy": |
---|
| 494 | # self.btFit.SetLabel("Stop") |
---|
| 495 | # self.btFit.Unbind(event=wx.EVT_BUTTON, id= self.btFit.GetId()) |
---|
| 496 | # self.btFit.Bind(event= wx.EVT_BUTTON, handler=self._StopFit, id=self.btFit.GetId()) |
---|
| 497 | #else: |
---|
| 498 | # self.btFit.SetLabel("Fit") |
---|
| 499 | # self.btFit.Bind(event= wx.EVT_BUTTON, handler=self._onFit, id=self.btFit.GetId()) |
---|
[1c1436d] | 500 | self.btFit.SetFocus() |
---|
[c77d859] | 501 | self.sizer5.Layout() |
---|
| 502 | self.SetScrollbars(20,20,55,40) |
---|
| 503 | |
---|
[ad6dd4c] | 504 | def _StopFit(self, event): |
---|
| 505 | """ |
---|
| 506 | Stop fit |
---|
| 507 | """ |
---|
| 508 | self.btFit.SetLabel("Fit") |
---|
| 509 | if self.engine_type=="scipy": |
---|
| 510 | self.manager.stop_fit() |
---|
[34a0c17] | 511 | self.btFit.Unbind(event=wx.EVT_BUTTON, id=self.btFit.GetId()) |
---|
| 512 | self.btFit.Bind(event=wx.EVT_BUTTON, handler=self._onFit,id=self.btFit.GetId()) |
---|
| 513 | |
---|
| 514 | |
---|
[ad6dd4c] | 515 | self.btFit.SetFocus() |
---|
| 516 | self.sizer5.Layout() |
---|
| 517 | self.SetScrollbars(20,20,55,40) |
---|
| 518 | |
---|
[c77d859] | 519 | def _on_select_model(self, event): |
---|
| 520 | """ |
---|
| 521 | call back for model selection |
---|
| 522 | """ |
---|
[59a7f2d] | 523 | self._on_select_model_helper() |
---|
[fbf4bf8] | 524 | if self.model == None: |
---|
| 525 | self.set_model_param_sizer(self.model) |
---|
| 526 | return |
---|
| 527 | else: |
---|
| 528 | self.set_model_param_sizer(self.model) |
---|
[c77d859] | 529 | try: |
---|
[997131a] | 530 | temp_smear= None |
---|
| 531 | if self.enable_smearer.GetValue(): |
---|
| 532 | temp_smear= self.smearer |
---|
| 533 | self.compute_chisqr(temp_smear) |
---|
[c77d859] | 534 | except: |
---|
| 535 | ## error occured on chisqr computation |
---|
| 536 | pass |
---|
[3b605bb] | 537 | self.enable_disp.SetValue(False) |
---|
| 538 | self.disable_disp.SetValue(True) |
---|
[1c1436d] | 539 | self.set_dispers_sizer() |
---|
[3b605bb] | 540 | |
---|
| 541 | evt = ModelEventbox(model=self.model) |
---|
| 542 | wx.PostEvent(self.event_owner, evt) |
---|
| 543 | |
---|
[298b762] | 544 | |
---|
| 545 | def _onparamRangeEnter(self, event): |
---|
| 546 | """ |
---|
| 547 | Check validity of value enter in the parameters range field |
---|
| 548 | """ |
---|
| 549 | tcrtl= event.GetEventObject() |
---|
| 550 | if tcrtl.GetValue().lstrip().rstrip()!="": |
---|
| 551 | try: |
---|
| 552 | value = float(tcrtl.GetValue()) |
---|
| 553 | tcrtl.SetBackgroundColour(wx.WHITE) |
---|
| 554 | tcrtl.Refresh() |
---|
| 555 | except: |
---|
| 556 | tcrtl.SetBackgroundColour("pink") |
---|
| 557 | tcrtl.Refresh() |
---|
| 558 | else: |
---|
| 559 | tcrtl.SetBackgroundColour(wx.WHITE) |
---|
| 560 | tcrtl.Refresh() |
---|
| 561 | self._onparamEnter_helper() |
---|
| 562 | |
---|
[dd5949d] | 563 | def _onparamEnter(self,event): |
---|
| 564 | """ |
---|
| 565 | when enter value on panel redraw model according to changed |
---|
| 566 | """ |
---|
[69bee6d] | 567 | tcrtl= event.GetEventObject() |
---|
| 568 | if check_float(tcrtl): |
---|
| 569 | self._onparamEnter_helper() |
---|
[da26c1a] | 570 | temp_smearer = None |
---|
| 571 | if self.enable_smearer.GetValue(): |
---|
| 572 | temp_smearer= self.smearer |
---|
| 573 | self.compute_chisqr(smearer= temp_smearer) |
---|
[69bee6d] | 574 | else: |
---|
| 575 | msg= "Cannot Plot :Must enter a number!!! " |
---|
| 576 | wx.PostEvent(self.parent.parent, StatusEvent(status = msg )) |
---|
| 577 | return |
---|
[cfc0913] | 578 | |
---|
[882a912] | 579 | |
---|
| 580 | def set_data(self, data ): |
---|
| 581 | """ |
---|
| 582 | reset the current data |
---|
| 583 | """ |
---|
| 584 | if data ==None: |
---|
| 585 | return |
---|
| 586 | self.data =data |
---|
| 587 | self.state.data= data |
---|
| 588 | self._fill_datainfo_sizer() |
---|
| 589 | self.SetScrollbars(20,20,200,100) |
---|
| 590 | self.Layout() |
---|
| 591 | |
---|
[a074145] | 592 | def reset_page(self, state): |
---|
| 593 | """ |
---|
| 594 | reset the state |
---|
| 595 | """ |
---|
| 596 | self.reset_page_helper(state) |
---|
| 597 | evt = ModelEventbox(model=self.model) |
---|
| 598 | wx.PostEvent(self.event_owner, evt) |
---|
| 599 | |
---|
| 600 | |
---|
[2140e68] | 601 | def get_range(self): |
---|
| 602 | """ |
---|
| 603 | return the fitting range |
---|
| 604 | """ |
---|
[c9a4377] | 605 | return float(self.qmin_x) , float(self.qmax_x) |
---|
[c77d859] | 606 | |
---|
| 607 | def get_param_list(self): |
---|
| 608 | """ |
---|
| 609 | @return self.param_toFit: list containing references to TextCtrl |
---|
| 610 | checked.Theses TextCtrl will allow reference to parameters to fit. |
---|
| 611 | @raise: if return an empty list of parameter fit will nnote work |
---|
| 612 | properly so raise ValueError,"missing parameter to fit" |
---|
| 613 | """ |
---|
| 614 | if self.param_toFit !=[]: |
---|
| 615 | return self.param_toFit |
---|
| 616 | else: |
---|
| 617 | raise ValueError,"missing parameter to fit" |
---|
| 618 | |
---|
| 619 | def onsetValues(self,chisqr, out,cov): |
---|
| 620 | """ |
---|
| 621 | Build the panel from the fit result |
---|
| 622 | @param chisqr:Value of the goodness of fit metric |
---|
| 623 | @param out:list of parameter with the best value found during fitting |
---|
| 624 | @param cov:Covariance matrix |
---|
| 625 | |
---|
| 626 | """ |
---|
| 627 | self.tcChi.SetLabel(format_number(chisqr)) |
---|
| 628 | params = {} |
---|
| 629 | is_modified = False |
---|
| 630 | has_error = False |
---|
[0a518e4c] | 631 | self.text2_3.Hide() |
---|
[e473e4f5] | 632 | try: |
---|
| 633 | n = self.disp_box.GetCurrentSelection() |
---|
| 634 | dispersity= self.disp_box.GetClientData(n) |
---|
| 635 | name= dispersity.__name__ |
---|
| 636 | if name == "GaussianDispersion": |
---|
| 637 | if hasattr(self,"text_disp_1" ): |
---|
| 638 | if self.text_disp_1 !=None: |
---|
| 639 | self.text_disp_1.Hide() |
---|
| 640 | except: |
---|
| 641 | pass |
---|
[c77d859] | 642 | #set the panel when fit result are float not list |
---|
| 643 | if out.__class__==numpy.float64: |
---|
| 644 | self.param_toFit[0][2].SetValue(format_number(out)) |
---|
| 645 | self.param_toFit[0][2].Refresh() |
---|
[0a518e4c] | 646 | |
---|
| 647 | self.param_toFit[0][4].Clear() |
---|
| 648 | self.param_toFit[0][4].Hide() |
---|
[c77d859] | 649 | if cov !=None : |
---|
| 650 | self.text2_3.Show(True) |
---|
[e473e4f5] | 651 | try: |
---|
| 652 | name= dispersity.__name__ |
---|
| 653 | if name == "GaussianDispersion": |
---|
| 654 | if hasattr(self,"text_disp_1" ): |
---|
| 655 | if self.text_disp_1 !=None: |
---|
| 656 | self.text_disp_1.Show(True) |
---|
| 657 | except: |
---|
| 658 | pass |
---|
[ad6dd4c] | 659 | if cov[0]==None or not numpy.isfinite(cov[0]): |
---|
[69bee6d] | 660 | self.param_toFit[0][3].Hide() |
---|
| 661 | self.param_toFit[0][4].Clear() |
---|
| 662 | self.param_toFit[0][4].Hide() |
---|
| 663 | self.param_toFit[0][4].Refresh() |
---|
| 664 | else: |
---|
| 665 | self.param_toFit[0][3].Show(True) |
---|
| 666 | self.param_toFit[0][4].Clear() |
---|
| 667 | self.param_toFit[0][4].SetValue(format_number(cov[0])) |
---|
| 668 | self.param_toFit[0][4].Show(True) |
---|
| 669 | self.param_toFit[0][4].Refresh() |
---|
[c77d859] | 670 | else: |
---|
| 671 | i=0 |
---|
| 672 | j=0 |
---|
| 673 | #Set the panel when fit result are list |
---|
| 674 | for item in self.param_toFit: |
---|
[0a518e4c] | 675 | ## reset error value to initial state |
---|
| 676 | item[4].Clear() |
---|
| 677 | item[4].Hide() |
---|
| 678 | item[4].Refresh() |
---|
[c77d859] | 679 | if( out != None ) and len(out)<=len(self.param_toFit)and i < len(out): |
---|
| 680 | item[2].SetValue(format_number(self.model.getParam(item[1]))) |
---|
| 681 | item[2].Refresh() |
---|
| 682 | if(cov !=None)and len(cov)<=len(self.param_toFit)and i < len(cov): |
---|
| 683 | self.text2_3.Show(True) |
---|
[e473e4f5] | 684 | try: |
---|
| 685 | name= dispersity.__name__ |
---|
| 686 | if name == "GaussianDispersion": |
---|
| 687 | if hasattr(self,"text_disp_1" ): |
---|
| 688 | if self.text_disp_1!=None: |
---|
| 689 | self.text_disp_1.Show(True) |
---|
| 690 | except: |
---|
| 691 | pass |
---|
[c77d859] | 692 | item[3].Show(True) |
---|
| 693 | item[4].Clear() |
---|
| 694 | for j in range(len(out)): |
---|
| 695 | if out[j]==self.model.getParam(item[1]): |
---|
| 696 | break |
---|
[69bee6d] | 697 | ## unable to compare cov[j]==numpy.nan so switch to None |
---|
[ad6dd4c] | 698 | if cov[j]==None or not numpy.isfinite(cov[j]): |
---|
[69bee6d] | 699 | item[3].Hide() |
---|
| 700 | item[4].Refresh() |
---|
| 701 | item[4].Clear() |
---|
| 702 | item[4].Hide() |
---|
| 703 | else: |
---|
| 704 | item[4].SetValue(format_number(cov[j])) |
---|
| 705 | item[4].Refresh() |
---|
| 706 | item[4].Show(True) |
---|
[c77d859] | 707 | i+=1 |
---|
| 708 | |
---|
| 709 | self.sizer3.Layout() |
---|
| 710 | self.sizer4.Layout() |
---|
| 711 | self.SetScrollbars(20,20,200,100) |
---|
| 712 | |
---|
| 713 | |
---|
| 714 | def onSmear(self, event): |
---|
| 715 | """ |
---|
| 716 | Create a smear object that will change the way residuals |
---|
| 717 | are compute when fitting |
---|
| 718 | """ |
---|
[3370922] | 719 | temp_smearer = None |
---|
[c77d859] | 720 | if self.enable_smearer.GetValue(): |
---|
[997131a] | 721 | msg="" |
---|
| 722 | temp_smearer= self.smearer |
---|
[c77d859] | 723 | if hasattr(self.data,"dxl"): |
---|
| 724 | msg= ": Resolution smearing parameters" |
---|
| 725 | if hasattr(self.data,"dxw"): |
---|
| 726 | msg= ": Slit smearing parameters" |
---|
[997131a] | 727 | if self.smearer ==None: |
---|
[c77d859] | 728 | wx.PostEvent(self.manager.parent, StatusEvent(status=\ |
---|
| 729 | "Data contains no smearing information")) |
---|
| 730 | else: |
---|
| 731 | wx.PostEvent(self.manager.parent, StatusEvent(status=\ |
---|
| 732 | "Data contains smearing information %s"%msg)) |
---|
[3370922] | 733 | |
---|
[fb8daaaf] | 734 | ## set smearing value whether or not the data contain the smearing info |
---|
[3370922] | 735 | self.manager.set_smearer(smearer=temp_smearer, qmin= float(self.qmin_x), |
---|
[2b63df0] | 736 | qmax= float(self.qmax_x)) |
---|
[875f1a2] | 737 | ##Calculate chi2 |
---|
[997131a] | 738 | self.compute_chisqr(smearer= temp_smearer) |
---|
[cfc0913] | 739 | ## save the state enable smearing |
---|
[2b63df0] | 740 | self.save_current_state() |
---|
[847091f] | 741 | |
---|
[2b63df0] | 742 | def complete_chisqr(self, output, elapsed=None): |
---|
| 743 | """ |
---|
| 744 | print result chisqr |
---|
| 745 | """ |
---|
| 746 | try: |
---|
| 747 | self.tcChi.SetLabel(format_number(output)) |
---|
| 748 | except: |
---|
| 749 | raise |
---|
| 750 | |
---|
| 751 | |
---|
| 752 | def compute_chisqr1D(self, smearer=None): |
---|
| 753 | """ |
---|
| 754 | Compute chisqr for 1D |
---|
| 755 | """ |
---|
| 756 | from sans.guiframe.utils import check_value |
---|
| 757 | flag = check_value( self.qmin, self.qmax) |
---|
| 758 | |
---|
| 759 | if not flag: |
---|
| 760 | return |
---|
| 761 | |
---|
| 762 | try: |
---|
| 763 | self.qmin_x = float(self.qmin.GetValue()) |
---|
| 764 | self.qmax_x = float(self.qmax.GetValue()) |
---|
| 765 | ##return residuals within self.qmin_x and self.qmax_x |
---|
| 766 | from gui_thread import CalcChisqr1D |
---|
| 767 | ## If a thread is already started, stop it |
---|
| 768 | if self.calc_Chisqr!= None and self.calc_Chisqr.isrunning(): |
---|
| 769 | self.calc_Chisqr.stop() |
---|
| 770 | |
---|
| 771 | self.calc_Chisqr= CalcChisqr1D( x= self.data.x, |
---|
| 772 | y= self.data.y, |
---|
| 773 | dy= self.data.dy, |
---|
| 774 | model= self.model, |
---|
| 775 | smearer=smearer, |
---|
| 776 | qmin=self.qmin_x, |
---|
| 777 | qmax=self.qmax_x, |
---|
| 778 | completefn = self.complete_chisqr, |
---|
| 779 | updatefn = None) |
---|
| 780 | |
---|
| 781 | self.calc_Chisqr.queue() |
---|
| 782 | |
---|
| 783 | except: |
---|
| 784 | raise ValueError," Could not compute Chisqr for %s Model 2D: "%self.model.name |
---|
| 785 | |
---|
| 786 | |
---|
| 787 | |
---|
| 788 | |
---|
[b787e68c] | 789 | |
---|
[c77d859] | 790 | def compute_chisqr2D(self): |
---|
| 791 | """ |
---|
| 792 | compute chi square given a model and data 2D and set the value |
---|
| 793 | to the tcChi txtcrl |
---|
| 794 | """ |
---|
| 795 | from sans.guiframe.utils import check_value |
---|
| 796 | flag = check_value( self.qmin, self.qmax) |
---|
[2b63df0] | 797 | if not flag: |
---|
| 798 | return |
---|
| 799 | |
---|
| 800 | try: |
---|
| 801 | self.qmin_x = float(self.qmin.GetValue()) |
---|
| 802 | self.qmax_x = float(self.qmax.GetValue()) |
---|
| 803 | |
---|
| 804 | ##return residuals within self.qmin_x and self.qmax_x |
---|
| 805 | from gui_thread import CalcChisqr2D |
---|
| 806 | ## If a thread is already started, stop it |
---|
| 807 | if self.calc_Chisqr!= None and self.calc_Chisqr.isrunning(): |
---|
| 808 | self.calc_Chisqr.stop() |
---|
| 809 | |
---|
| 810 | self.calc_Chisqr= CalcChisqr2D( x_bins= self.data.x_bins, |
---|
| 811 | y_bins= self.data.y_bins, |
---|
| 812 | data= self.data.data, |
---|
| 813 | err_data = self.data.err_data, |
---|
| 814 | model= self.model, |
---|
| 815 | qmin= self.qmin_x, |
---|
| 816 | qmax = self.qmax_x, |
---|
| 817 | completefn = self.complete_chisqr, |
---|
| 818 | updatefn = None) |
---|
[c77d859] | 819 | |
---|
[2b63df0] | 820 | self.calc_Chisqr.queue() |
---|
| 821 | |
---|
| 822 | except: |
---|
| 823 | raise ValueError," Could not compute Chisqr for %s Model 2D: "%self.model.name |
---|
| 824 | |
---|
| 825 | |
---|
[c77d859] | 826 | |
---|
[997131a] | 827 | def compute_chisqr(self , smearer=None): |
---|
[c77d859] | 828 | """ |
---|
| 829 | compute chi square given a model and data 1D and set the value |
---|
| 830 | to the tcChi txtcrl |
---|
| 831 | """ |
---|
| 832 | from sans.guiframe.utils import check_value |
---|
| 833 | flag = check_value( self.qmin, self.qmax) |
---|
| 834 | if flag== True: |
---|
| 835 | try: |
---|
| 836 | if hasattr(self.data,"data"): |
---|
| 837 | self.compute_chisqr2D() |
---|
| 838 | return |
---|
| 839 | else: |
---|
[2b63df0] | 840 | self.compute_chisqr1D(smearer=smearer) |
---|
| 841 | return |
---|
[c77d859] | 842 | except: |
---|
[a8088d7] | 843 | wx.PostEvent(self.parent.GrandParent, StatusEvent(status=\ |
---|
[2b63df0] | 844 | "Chisqr Error: %s"% sys.exc_value)) |
---|
[a8088d7] | 845 | return |
---|
[c77d859] | 846 | |
---|
| 847 | |
---|
| 848 | def select_all_param(self,event): |
---|
| 849 | """ |
---|
| 850 | set to true or false all checkBox given the main checkbox value cb1 |
---|
[d1e0473] | 851 | """ |
---|
| 852 | |
---|
[c77d859] | 853 | self.param_toFit=[] |
---|
| 854 | if self.parameters !=[]: |
---|
[998b6b8] | 855 | if self.cb1.GetValue(): |
---|
[c77d859] | 856 | for item in self.parameters: |
---|
[3fef0a8] | 857 | ## for data2D select all to fit |
---|
| 858 | if self.data.__class__.__name__=="Data2D": |
---|
[c77d859] | 859 | item[0].SetValue(True) |
---|
| 860 | self.param_toFit.append(item ) |
---|
[3fef0a8] | 861 | else: |
---|
| 862 | ## for 1D all parameters except orientation |
---|
| 863 | if not item in self.orientation_params: |
---|
| 864 | item[0].SetValue(True) |
---|
| 865 | self.param_toFit.append(item ) |
---|
| 866 | if len(self.fittable_param)>0: |
---|
| 867 | for item in self.fittable_param: |
---|
| 868 | if self.data.__class__.__name__=="Data2D": |
---|
| 869 | item[0].SetValue(True) |
---|
| 870 | self.param_toFit.append(item ) |
---|
| 871 | else: |
---|
| 872 | ## for 1D all parameters except orientation |
---|
[513115c] | 873 | if not item in self.orientation_params_disp: |
---|
[3fef0a8] | 874 | item[0].SetValue(True) |
---|
| 875 | self.param_toFit.append(item ) |
---|
[c77d859] | 876 | else: |
---|
| 877 | for item in self.parameters: |
---|
| 878 | item[0].SetValue(False) |
---|
| 879 | for item in self.fittable_param: |
---|
| 880 | item[0].SetValue(False) |
---|
| 881 | self.param_toFit=[] |
---|
[60132ef] | 882 | |
---|
[cfc0913] | 883 | self.save_current_state() |
---|
| 884 | |
---|
[c77d859] | 885 | |
---|
| 886 | |
---|
| 887 | def select_param(self,event): |
---|
| 888 | """ |
---|
| 889 | Select TextCtrl checked for fitting purpose and stores them |
---|
| 890 | in self.param_toFit=[] list |
---|
| 891 | """ |
---|
| 892 | self.param_toFit=[] |
---|
| 893 | for item in self.parameters: |
---|
| 894 | #Select parameters to fit for list of primary parameters |
---|
[998b6b8] | 895 | if item[0].GetValue(): |
---|
[c77d859] | 896 | if not (item in self.param_toFit): |
---|
| 897 | self.param_toFit.append(item ) |
---|
| 898 | else: |
---|
| 899 | #remove parameters from the fitting list |
---|
| 900 | if item in self.param_toFit: |
---|
| 901 | self.param_toFit.remove(item) |
---|
| 902 | #Select parameters to fit for list of fittable parameters with dispersion |
---|
| 903 | for item in self.fittable_param: |
---|
[998b6b8] | 904 | if item[0].GetValue(): |
---|
[c77d859] | 905 | if not (item in self.param_toFit): |
---|
| 906 | self.param_toFit.append(item) |
---|
| 907 | else: |
---|
| 908 | #remove parameters from the fitting list |
---|
| 909 | if item in self.param_toFit: |
---|
| 910 | self.param_toFit.remove(item) |
---|
| 911 | #Set the value of checkbox that selected every checkbox or not |
---|
| 912 | if len(self.parameters)+len(self.fittable_param) ==len(self.param_toFit): |
---|
| 913 | self.cb1.SetValue(True) |
---|
| 914 | else: |
---|
| 915 | self.cb1.SetValue(False) |
---|
[cfc0913] | 916 | ## save current state of the page |
---|
| 917 | self.save_current_state() |
---|
| 918 | |
---|
[c77d859] | 919 | |
---|
| 920 | |
---|
[77e23a2] | 921 | def set_model_param_sizer(self, model): |
---|
[c77d859] | 922 | """ |
---|
| 923 | Build the panel from the model content |
---|
| 924 | @param model: the model selected in combo box for fitting purpose |
---|
| 925 | """ |
---|
| 926 | self.sizer3.Clear(True) |
---|
| 927 | self.parameters = [] |
---|
| 928 | self.param_toFit=[] |
---|
| 929 | self.fittable_param=[] |
---|
| 930 | self.fixed_param=[] |
---|
[780d095] | 931 | self.orientation_params=[] |
---|
[60132ef] | 932 | self.orientation_params_disp=[] |
---|
[c77d859] | 933 | |
---|
| 934 | if model ==None: |
---|
| 935 | self.sizer3.Layout() |
---|
| 936 | self.SetScrollbars(20,20,200,100) |
---|
| 937 | return |
---|
[707436d] | 938 | ## the panel is drawn using the current value of the fit engine |
---|
| 939 | if self.engine_type==None and self.manager !=None: |
---|
| 940 | self.engine_type= self.manager._return_engine_type() |
---|
| 941 | |
---|
[c77d859] | 942 | box_description= wx.StaticBox(self, -1,str("Model Parameters")) |
---|
| 943 | boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL) |
---|
| 944 | sizer = wx.GridBagSizer(5,5) |
---|
| 945 | ## save the current model |
---|
| 946 | self.model = model |
---|
| 947 | |
---|
| 948 | keys = self.model.getParamList() |
---|
| 949 | #list of dispersion paramaters |
---|
| 950 | self.disp_list=self.model.getDispParamList() |
---|
| 951 | |
---|
| 952 | keys.sort() |
---|
| 953 | |
---|
| 954 | iy = 1 |
---|
| 955 | ix = 0 |
---|
| 956 | self.cb1 = wx.CheckBox(self, -1,"Select all", (10, 10)) |
---|
| 957 | wx.EVT_CHECKBOX(self, self.cb1.GetId(), self.select_all_param) |
---|
| 958 | self.cb1.SetValue(False) |
---|
| 959 | |
---|
| 960 | sizer.Add(self.cb1,(iy, ix),(1,1),\ |
---|
[eda428b] | 961 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 5) |
---|
[c77d859] | 962 | ix +=1 |
---|
| 963 | self.text2_2 = wx.StaticText(self, -1, 'Values') |
---|
| 964 | sizer.Add(self.text2_2,(iy, ix),(1,1),\ |
---|
| 965 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 966 | ix +=2 |
---|
| 967 | self.text2_3 = wx.StaticText(self, -1, 'Errors') |
---|
| 968 | sizer.Add(self.text2_3,(iy, ix),(1,1),\ |
---|
| 969 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 970 | self.text2_3.Hide() |
---|
| 971 | ix +=1 |
---|
| 972 | self.text2_min = wx.StaticText(self, -1, 'Min') |
---|
| 973 | sizer.Add(self.text2_min,(iy, ix),(1,1),\ |
---|
| 974 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 975 | self.text2_min.Hide() |
---|
| 976 | ix +=1 |
---|
| 977 | self.text2_max = wx.StaticText(self, -1, 'Max') |
---|
| 978 | sizer.Add(self.text2_max,(iy, ix),(1,1),\ |
---|
| 979 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 980 | self.text2_max.Hide() |
---|
[6fdfc8f] | 981 | ix += 1 |
---|
| 982 | self.text2_4 = wx.StaticText(self, -1, '[Units]') |
---|
| 983 | sizer.Add(self.text2_4,(iy, ix),(1,1),\ |
---|
| 984 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 985 | self.text2_4.Hide() |
---|
[dcf29d7] | 986 | if self.engine_type=="park": |
---|
| 987 | self.text2_max.Show(True) |
---|
| 988 | self.text2_min.Show(True) |
---|
[c77d859] | 989 | |
---|
| 990 | for item in keys: |
---|
[780d095] | 991 | if not item in self.disp_list and not item in self.model.orientation_params: |
---|
[c77d859] | 992 | iy += 1 |
---|
| 993 | ix = 0 |
---|
| 994 | ## add parameters name with checkbox for selecting to fit |
---|
| 995 | cb = wx.CheckBox(self, -1, item ) |
---|
| 996 | cb.SetValue(False) |
---|
| 997 | wx.EVT_CHECKBOX(self, cb.GetId(), self.select_param) |
---|
| 998 | sizer.Add( cb,( iy, ix),(1,1), |
---|
[eda428b] | 999 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 5) |
---|
[d1e0473] | 1000 | |
---|
[c77d859] | 1001 | ## add parameter value |
---|
| 1002 | ix += 1 |
---|
| 1003 | value= self.model.getParam(item) |
---|
| 1004 | ctl1 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), |
---|
| 1005 | style=wx.TE_PROCESS_ENTER) |
---|
| 1006 | |
---|
[77e23a2] | 1007 | ctl1.SetValue(format_number(value)) |
---|
| 1008 | ctl1.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) |
---|
[c77d859] | 1009 | ctl1.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) |
---|
| 1010 | ctl1.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter) |
---|
| 1011 | sizer.Add(ctl1, (iy,ix),(1,1), wx.EXPAND) |
---|
| 1012 | ## text to show error sign |
---|
| 1013 | ix += 1 |
---|
| 1014 | text2=wx.StaticText(self, -1, '+/-') |
---|
| 1015 | sizer.Add(text2,(iy, ix),(1,1),\ |
---|
| 1016 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 1017 | text2.Hide() |
---|
| 1018 | ## txtcrtl to add error from fit |
---|
| 1019 | ix += 1 |
---|
| 1020 | ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=wx.TE_PROCESS_ENTER) |
---|
| 1021 | sizer.Add(ctl2, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 1022 | ctl2.Hide() |
---|
| 1023 | |
---|
[77e23a2] | 1024 | param_min, param_max= self.model.details[item][1:] |
---|
[c77d859] | 1025 | ix += 1 |
---|
| 1026 | ctl3 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER) |
---|
[298b762] | 1027 | if param_min ==None: |
---|
| 1028 | ctl3.SetValue("") |
---|
| 1029 | else: |
---|
| 1030 | ctl3.SetValue(str(param_min)) |
---|
[77e23a2] | 1031 | ctl3.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) |
---|
[298b762] | 1032 | ctl3.Bind(wx.EVT_KILL_FOCUS, self._onparamRangeEnter) |
---|
| 1033 | ctl3.Bind(wx.EVT_TEXT_ENTER,self._onparamRangeEnter) |
---|
[c77d859] | 1034 | sizer.Add(ctl3, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 1035 | ctl3.Hide() |
---|
[77e23a2] | 1036 | |
---|
[c77d859] | 1037 | ix += 1 |
---|
| 1038 | ctl4 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER) |
---|
[77e23a2] | 1039 | ctl4.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) |
---|
[298b762] | 1040 | ctl4.Bind(wx.EVT_KILL_FOCUS, self._onparamRangeEnter) |
---|
| 1041 | ctl4.Bind(wx.EVT_TEXT_ENTER,self._onparamRangeEnter) |
---|
[c77d859] | 1042 | sizer.Add(ctl4, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
[298b762] | 1043 | if param_max==None: |
---|
| 1044 | ctl4.SetValue("") |
---|
| 1045 | else: |
---|
| 1046 | ctl4.SetValue(str(param_max)) |
---|
[c77d859] | 1047 | ctl4.Hide() |
---|
[dcf29d7] | 1048 | |
---|
| 1049 | if self.engine_type=="park": |
---|
| 1050 | ctl3.Show(True) |
---|
| 1051 | ctl4.Show(True) |
---|
[6fdfc8f] | 1052 | ix +=1 |
---|
| 1053 | # Units |
---|
| 1054 | try: |
---|
| 1055 | units = wx.StaticText(self, -1, self.model.details[item][0], style=wx.ALIGN_LEFT) |
---|
| 1056 | except: |
---|
| 1057 | units = wx.StaticText(self, -1, "", style=wx.ALIGN_LEFT) |
---|
| 1058 | sizer.Add(units, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
[dcf29d7] | 1059 | |
---|
[c77d859] | 1060 | ##[cb state, name, value, "+/-", error of fit, min, max , units] |
---|
| 1061 | self.parameters.append([cb,item, ctl1, |
---|
| 1062 | text2,ctl2, ctl3, ctl4,None]) |
---|
[2d5f7a1] | 1063 | |
---|
[c77d859] | 1064 | iy+=1 |
---|
[2a5bba7] | 1065 | sizer.Add((10,10),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
[780d095] | 1066 | for item in self.model.orientation_params: |
---|
| 1067 | if not item in self.disp_list : |
---|
| 1068 | iy += 1 |
---|
| 1069 | ix = 0 |
---|
| 1070 | ## add parameters name with checkbox for selecting to fit |
---|
| 1071 | cb = wx.CheckBox(self, -1, item ) |
---|
| 1072 | cb.SetValue(False) |
---|
| 1073 | wx.EVT_CHECKBOX(self, cb.GetId(), self.select_param) |
---|
| 1074 | if self.data.__class__.__name__ =="Data2D": |
---|
| 1075 | cb.Enable() |
---|
| 1076 | else: |
---|
| 1077 | cb.Disable() |
---|
| 1078 | sizer.Add( cb,( iy, ix),(1,1), |
---|
[dffa973] | 1079 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 5) |
---|
[d1e0473] | 1080 | |
---|
[780d095] | 1081 | ## add parameter value |
---|
| 1082 | ix += 1 |
---|
| 1083 | value= self.model.getParam(item) |
---|
| 1084 | ctl1 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), |
---|
| 1085 | style=wx.TE_PROCESS_ENTER) |
---|
| 1086 | |
---|
| 1087 | ctl1.SetValue(format_number(value)) |
---|
| 1088 | if self.data.__class__.__name__ =="Data2D": |
---|
| 1089 | ctl1.Enable() |
---|
| 1090 | else: |
---|
| 1091 | ctl1.Disable() |
---|
| 1092 | ctl1.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) |
---|
| 1093 | ctl1.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) |
---|
| 1094 | ctl1.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter) |
---|
| 1095 | sizer.Add(ctl1, (iy,ix),(1,1), wx.EXPAND) |
---|
| 1096 | ## text to show error sign |
---|
| 1097 | ix += 1 |
---|
| 1098 | text2=wx.StaticText(self, -1, '+/-') |
---|
| 1099 | sizer.Add(text2,(iy, ix),(1,1),\ |
---|
| 1100 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 1101 | text2.Hide() |
---|
| 1102 | ## txtcrtl to add error from fit |
---|
| 1103 | ix += 1 |
---|
| 1104 | ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=wx.TE_PROCESS_ENTER) |
---|
| 1105 | sizer.Add(ctl2, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 1106 | ctl2.Hide() |
---|
| 1107 | if self.data.__class__.__name__ =="Data2D": |
---|
| 1108 | ctl1.Enable() |
---|
| 1109 | else: |
---|
| 1110 | ctl1.Disable() |
---|
| 1111 | param_min, param_max= self.model.details[item][1:] |
---|
| 1112 | ix += 1 |
---|
| 1113 | ctl3 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER) |
---|
[298b762] | 1114 | if param_min ==None: |
---|
| 1115 | ctl3.SetValue("") |
---|
| 1116 | else: |
---|
| 1117 | ctl3.SetValue(str(param_min)) |
---|
[780d095] | 1118 | ctl3.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) |
---|
[298b762] | 1119 | ctl3.Bind(wx.EVT_KILL_FOCUS, self._onparamRangeEnter) |
---|
| 1120 | ctl3.Bind(wx.EVT_TEXT_ENTER,self._onparamRangeEnter) |
---|
[780d095] | 1121 | sizer.Add(ctl3, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 1122 | ctl3.Hide() |
---|
| 1123 | if self.data.__class__.__name__ =="Data2D": |
---|
| 1124 | ctl3.Enable() |
---|
| 1125 | else: |
---|
| 1126 | ctl3.Disable() |
---|
| 1127 | ix += 1 |
---|
| 1128 | ctl4 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER) |
---|
| 1129 | ctl4.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) |
---|
[298b762] | 1130 | ctl4.Bind(wx.EVT_KILL_FOCUS, self._onparamRangeEnter) |
---|
| 1131 | ctl4.Bind(wx.EVT_TEXT_ENTER,self._onparamRangeEnter) |
---|
[780d095] | 1132 | sizer.Add(ctl4, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
[3fef0a8] | 1133 | if param_max ==None: |
---|
| 1134 | ctl4.SetValue("") |
---|
| 1135 | else: |
---|
| 1136 | ctl4.SetValue(str(param_max)) |
---|
[780d095] | 1137 | ctl4.Hide() |
---|
| 1138 | if self.data.__class__.__name__ =="Data2D": |
---|
| 1139 | ctl4.Enable() |
---|
| 1140 | else: |
---|
| 1141 | ctl4.Disable() |
---|
| 1142 | if self.engine_type=="park": |
---|
| 1143 | ctl3.Show(True) |
---|
| 1144 | ctl4.Show(True) |
---|
[6fdfc8f] | 1145 | ix +=1 |
---|
| 1146 | # Units |
---|
| 1147 | try: |
---|
| 1148 | units = wx.StaticText(self, -1, self.model.details[item][0], style=wx.ALIGN_LEFT) |
---|
| 1149 | except: |
---|
| 1150 | units = wx.StaticText(self, -1, "", style=wx.ALIGN_LEFT) |
---|
| 1151 | if self.data.__class__.__name__ =="Data2D": |
---|
| 1152 | units.Enable() |
---|
| 1153 | else: |
---|
| 1154 | units.Disable() |
---|
| 1155 | sizer.Add(units, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
[780d095] | 1156 | |
---|
| 1157 | |
---|
| 1158 | ##[cb state, name, value, "+/-", error of fit, min, max , units] |
---|
| 1159 | self.parameters.append([cb,item, ctl1, |
---|
| 1160 | text2,ctl2, ctl3, ctl4,None]) |
---|
| 1161 | self.orientation_params.append([cb,item, ctl1, |
---|
| 1162 | text2,ctl2, ctl3, ctl4,None]) |
---|
| 1163 | |
---|
| 1164 | iy+=1 |
---|
| 1165 | sizer.Add((10,10),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
[c77d859] | 1166 | |
---|
| 1167 | #Display units text on panel |
---|
| 1168 | for item in keys: |
---|
| 1169 | if self.model.details[item][0]!='': |
---|
| 1170 | self.text2_4.Show() |
---|
| 1171 | break |
---|
| 1172 | else: |
---|
| 1173 | self.text2_4.Hide() |
---|
| 1174 | |
---|
| 1175 | boxsizer1.Add(sizer) |
---|
| 1176 | |
---|
| 1177 | self.sizer3.Add(boxsizer1,0, wx.EXPAND | wx.ALL, 10) |
---|
| 1178 | self.sizer3.Layout() |
---|
| 1179 | self.SetScrollbars(20,20,200,100) |
---|
| 1180 | |
---|
| 1181 | |
---|
| 1182 | |
---|
| 1183 | |
---|
| 1184 | class HelpWindow(wx.Frame): |
---|
| 1185 | def __init__(self, parent, id, title): |
---|
| 1186 | wx.Frame.__init__(self, parent, id, title, size=(570, 400)) |
---|
| 1187 | |
---|
| 1188 | from sans.models.CylinderModel import CylinderModel |
---|
| 1189 | model = CylinderModel() |
---|
[2d5f7a1] | 1190 | |
---|
[c77d859] | 1191 | from danse.common.plottools.plottables import Data1D |
---|
| 1192 | data= Data1D(x=[1,2], y=[3,4], dy=[0.1, 0,1]) |
---|
| 1193 | |
---|
[cfc0913] | 1194 | from fitpanel import PageInfo |
---|
[c77d859] | 1195 | myinfo = PageInfo(self, model, data=data ) |
---|
| 1196 | |
---|
| 1197 | ## add data |
---|
| 1198 | |
---|
| 1199 | from models import ModelList |
---|
| 1200 | mylist= ModelList() |
---|
| 1201 | |
---|
| 1202 | from sans.models.SphereModel import SphereModel |
---|
| 1203 | from sans.models.SquareWellStructure import SquareWellStructure |
---|
| 1204 | from sans.models.DebyeModel import DebyeModel |
---|
| 1205 | from sans.models.LineModel import LineModel |
---|
| 1206 | name= "shapes" |
---|
| 1207 | list1= [SphereModel] |
---|
| 1208 | mylist.set_list( name, list1) |
---|
| 1209 | |
---|
| 1210 | name= "Shape-independent" |
---|
| 1211 | list1= [DebyeModel] |
---|
| 1212 | mylist.set_list( name, list1) |
---|
| 1213 | |
---|
| 1214 | name= "Structure Factors" |
---|
| 1215 | list1= [SquareWellStructure] |
---|
| 1216 | mylist.set_list( name, list1) |
---|
| 1217 | |
---|
| 1218 | name= "Added models" |
---|
| 1219 | list1= [LineModel] |
---|
| 1220 | mylist.set_list( name, list1) |
---|
| 1221 | |
---|
| 1222 | myinfo.model_list_box = mylist.get_list() |
---|
| 1223 | |
---|
| 1224 | self.page = FitPage(self, myinfo) |
---|
| 1225 | |
---|
| 1226 | |
---|
| 1227 | |
---|
| 1228 | self.Centre() |
---|
| 1229 | self.Show(True) |
---|
| 1230 | |
---|
| 1231 | |
---|
| 1232 | |
---|
| 1233 | if __name__=="__main__": |
---|
| 1234 | app = wx.App() |
---|
| 1235 | HelpWindow(None, -1, 'HelpWindow') |
---|
| 1236 | app.MainLoop() |
---|
| 1237 | |
---|