- Timestamp:
- Oct 22, 2008 12:35:02 PM (16 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:
- c0d9981
- Parents:
- 978967c
- Location:
- sansview/perspectives/fitting
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/fitpage1D.py
r5cab7d3 r44bbf6a 54 54 self.sizer2 = wx.GridBagSizer(5,5) 55 55 self.sizer1 = wx.GridBagSizer(5,5) 56 self.DataSource = wx.TextCtrl(self, -1,size=(_BOX_WIDTH,20)) 57 self.DataSource.SetToolTipString("name of data to fit") 58 self.DataSource.SetValue(str(data.name)) 56 #self.DataSource = wx.TextCtrl(self, -1,size=(_BOX_WIDTH,20)) 57 #self.DataSource.SetToolTipString("name of data to fit") 58 #self.DataSource.SetValue(str(data.name)) 59 #self.DataSource.Disable() 60 self.DataSource =wx.StaticText(self, -1,str(data.name)) 61 59 62 self.modelbox = wx.ComboBox(self, -1) 60 63 id = wx.NewId() … … 64 67 self.static_line_1 = wx.StaticLine(self, -1) 65 68 66 67 68 69 self.vbox.Add(self.sizer3) 69 70 self.vbox.Add(self.sizer2) 70 71 self.vbox.Add(self.static_line_1, 0, wx.EXPAND, 0) 71 72 self.vbox.Add(self.sizer5) 72 73 73 self.vbox.Add(self.sizer4) 74 74 self.vbox.Add(self.sizer1) 75 76 77 75 78 76 id = wx.NewId() … … 82 80 ix = 0 83 81 iy = 1 84 self.sizer3.Add(wx.StaticText(self, -1, 'Data Source '),(iy,ix),\82 self.sizer3.Add(wx.StaticText(self, -1, 'Data Source Name : '),(iy,ix),\ 85 83 (1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 86 84 ix += 1 … … 120 118 self.xmin.Bind(wx.EVT_KILL_FOCUS, self._onTextEnter) 121 119 self.xmin.Bind(wx.EVT_TEXT_ENTER, self._onTextEnter) 120 self.xmin.Disable() 122 121 ix += 2 123 122 self.xmax = wx.TextCtrl(self, -1,size=(_BOX_WIDTH,20)) … … 127 126 self.xmax.Bind(wx.EVT_KILL_FOCUS, self._onTextEnter) 128 127 self.xmax.Bind(wx.EVT_TEXT_ENTER, self._onTextEnter) 128 self.xmax.Disable() 129 129 #Set chisqr result into TextCtrl 130 130 ix = 0 … … 252 252 post an event to its owner to draw an appropriate theory 253 253 """ 254 254 self.btFit.SetFocus() 255 255 for item in self.model_list_box.itervalues(): 256 256 name = item.__name__ … … 342 342 self.model = model 343 343 keys = self.model.getParamList() 344 print "fitpage1D : dispersion list",self.model.getDispParamList()344 #print "fitpage1D : dispersion list",self.model.getDispParamList() 345 345 keys.sort() 346 346 disp_list=self.model.getDispParamList() … … 407 407 ix= 0 408 408 iy=1 409 self.disp = wx.StaticText(self, -1, 'Dispersion') 410 self.sizer5.Add(self.disp,( iy, ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 411 iy+=1 409 if len(disp_list)>0: 410 disp = wx.StaticText(self, -1, 'Dispersion') 411 self.sizer5.Add(disp,( iy, ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 412 ix += 1 413 values = wx.StaticText(self, -1, 'Values') 414 self.sizer5.Add(values,( iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 415 #ix += 1 416 #disps = wx.StaticText(self, -1, 'Disp') 417 #self.sizer5.Add(disps,( iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 418 #ix += 1 419 #npts = wx.StaticText(self, -1, 'npts') 420 #self.sizer5.Add(npts,( iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 421 iy+=1 422 412 423 for item in disp_list: 413 424 ix = 0 -
sansview/perspectives/fitting/fitpage2D.py
r2dbb681 r44bbf6a 49 49 #panel interface 50 50 self.vbox = wx.BoxSizer(wx.VERTICAL) 51 self.sizer5 = wx.GridBagSizer(5,5) 51 52 self.sizer4 = wx.GridBagSizer(5,5) 52 53 self.sizer3 = wx.GridBagSizer(5,5) 53 54 self.sizer2 = wx.GridBagSizer(5,5) 54 55 self.sizer1 = wx.GridBagSizer(5,5) 55 self.DataSource = wx.TextCtrl(self, -1,size=(_BOX_WIDTH,20)) 56 self.DataSource.SetValue(str(data.name)) 57 self.DataSource.SetToolTipString("name of data to fit") 56 #self.DataSource = wx.TextCtrl(self, -1,size=(_BOX_WIDTH,20)) 57 #self.DataSource.SetToolTipString("name of data to fit") 58 #self.DataSource.SetValue(str(data.name)) 59 #self.DataSource.Disable() 60 self.DataSource =wx.StaticText(self, -1,str(data.name)) 58 61 self.modelbox = wx.ComboBox(self, -1) 59 62 id = wx.NewId() … … 61 64 self.btFit.Bind(wx.EVT_BUTTON, self.onFit,id=id) 62 65 self.btFit.SetToolTipString("Perform fit.") 66 self.static_line_1 = wx.StaticLine(self, -1) 67 63 68 self.vbox.Add(self.sizer3) 64 69 self.vbox.Add(self.sizer2) 70 self.vbox.Add(self.static_line_1, 0, wx.EXPAND, 0) 71 self.vbox.Add(self.sizer5) 65 72 self.vbox.Add(self.sizer4) 66 73 self.vbox.Add(self.sizer1) … … 362 369 keys = self.model.getParamList() 363 370 keys.sort() 371 disp_list=self.model.getDispParamList() 372 disp_list.sort() 364 373 iy = 1 365 374 ix = 0 … … 383 392 self.text2_4.Hide() 384 393 for item in keys: 385 iy += 1 394 if not item in disp_list: 395 iy += 1 396 ix = 0 397 398 cb = wx.CheckBox(self, -1, item, (10, 10)) 399 cb.SetValue(False) 400 self.sizer2.Add( cb,( iy, ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 401 wx.EVT_CHECKBOX(self, cb.GetId(), self.select_param) 402 403 ix += 1 404 value= self.model.getParam(item) 405 ctl1 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=wx.TE_PROCESS_ENTER) 406 ctl1.SetValue(str (format_number(value))) 407 ctl1.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) 408 ctl1.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter) 409 self.sizer2.Add(ctl1, (iy,ix),(1,1), wx.EXPAND) 410 ix += 1 411 text2=wx.StaticText(self, -1, '+/-') 412 self.sizer2.Add(text2,(iy, ix),(1,1),\ 413 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 414 text2.Hide() 415 ix += 1 416 ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=wx.TE_PROCESS_ENTER) 417 self.sizer2.Add(ctl2, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 418 ctl2.Hide() 419 ix +=1 420 #save data 421 self.parameters.append([cb,ctl1,text2,ctl2]) 422 # Units 423 try: 424 units = wx.StaticText(self, -1, self.model.details[item][0], style=wx.ALIGN_LEFT) 425 except: 426 units = wx.StaticText(self, -1, "", style=wx.ALIGN_LEFT) 427 428 self.sizer2.Add(units, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 429 iy+=1 430 self.sizer2.Add((20,20),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 431 ix= 0 432 iy=1 433 if len(disp_list)>0: 434 disp = wx.StaticText(self, -1, 'Dispersion') 435 self.sizer5.Add(disp,( iy, ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 436 ix += 1 437 values = wx.StaticText(self, -1, 'Values') 438 self.sizer5.Add(values,( iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 439 #ix += 1 440 #disps = wx.StaticText(self, -1, 'Disp') 441 #self.sizer5.Add(disps,( iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 442 #ix += 1 443 #npts = wx.StaticText(self, -1, 'npts') 444 #self.sizer5.Add(npts,( iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 445 iy+=1 446 447 for item in disp_list: 386 448 ix = 0 387 388 cb = wx.CheckBox(self, -1, item, (10, 10)) 389 cb.SetValue(False) 390 self.sizer2.Add( cb,( iy, ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 391 wx.EVT_CHECKBOX(self, cb.GetId(), self.select_param) 449 cb2 = wx.CheckBox(self, -1, item, (10, 10)) 450 cb2.SetValue(False) 451 self.sizer5.Add( cb2,( iy, ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 452 wx.EVT_CHECKBOX(self, cb2.GetId(), self.select_param) 392 453 393 454 ix += 1 394 455 value= self.model.getParam(item) 395 ctl1 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=wx.TE_PROCESS_ENTER)396 ctl1.SetValue(str (format_number(value)))397 ctl1.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter)398 ctl1.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter)399 self.sizer2.Add(ctl1, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)400 ix += 1401 text2=wx.StaticText(self, -1, '+/-')402 self.sizer2.Add(text2,(iy, ix),(1,1),\403 wx.EXPAND|wx.ADJUST_MINSIZE, 0)404 text2.Hide()405 ix += 1406 456 ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=wx.TE_PROCESS_ENTER) 407 self.sizer2.Add(ctl2, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 408 ctl2.Hide() 409 ix +=1 410 # Units 411 try: 412 units = wx.StaticText(self, -1, self.model.details[item][0], style=wx.ALIGN_LEFT) 413 except: 414 units = wx.StaticText(self, -1, "", style=wx.ALIGN_LEFT) 415 416 self.sizer2.Add(units, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 417 #save data 418 self.parameters.append([cb,ctl1,text2,ctl2]) 457 ctl2.SetValue(str (format_number(value))) 458 ctl2.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) 459 ctl2.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter) 460 self.sizer5.Add(ctl2, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 461 iy += 1 419 462 #Display units text on panel 420 463 for item in keys: … … 425 468 self.text2_4.Hide() 426 469 #Disable or enable fit button 427 if (self.modelbox.GetValue() and self.DataSource.GetValue()): 428 if not (len(self.param_toFit ) >0): 429 self.xmin.Disable() 430 self.xmax.Disable() 431 self.ymin.Disable() 432 self.ymax.Disable() 433 else: 434 self.xmin.Enable() 435 self.xmax.Enable() 436 self.ymin.Enable() 437 self.ymax.Enable() 438 else: 470 471 if not (len(self.param_toFit ) >0): 439 472 self.xmin.Disable() 440 473 self.xmax.Disable() 441 474 self.ymin.Disable() 442 475 self.ymax.Disable() 476 else: 477 self.xmin.Enable() 478 self.xmax.Enable() 479 self.ymin.Enable() 480 self.ymax.Enable() 481 443 482 self.compute_chisqr() 444 483 self.vbox.Layout() -
sansview/perspectives/fitting/fitting.py
r2dbb681 r44bbf6a 14 14 import fitpage1D,fitpage2D 15 15 import park 16 16 class Theory2D(Data2D): 17 def __init__(self,image=None,err_image=None,xmin=None, 18 xmax=None,ymin=None,ymax=None,zmin=None,zmax=None): 19 Data2D.__init__(self,image,err_image,xmin, 20 xmax,ymin,ymax,zmin,zmax) 17 21 class Plugin: 18 22 """ … … 513 517 theory.x.append(tempx) 514 518 theory.y.append(tempy) 515 516 519 except: 517 520 wx.PostEvent(self.parent, StatusEvent(status="fitting \ … … 519 522 else: 520 523 theory=Data2D(data.image, data.err_image) 524 #theory=Theory2D(data.image, data.err_image) 521 525 theory.x_bins= data.x_bins 522 526 theory.y_bins= data.y_bins … … 530 534 if ymax==None: 531 535 ymax=data.ymax 532 533 #for i in range(len(data.y_bins)): 534 # if data.y_bins[i]>= ymin and data.y_bins[i]<= ymax: 535 # for j in range(len(data.x_bins)): 536 # if data.x_bins[i]>= qmin and data.x_bins[i]<= qmax: 537 # theory.image= model.runXY([data.x_bins[j],data.y_bins[i]]) 536 537 theory.image = numpy.zeros((len(data.y_bins),len(data.x_bins))) 538 for i in range(len(data.y_bins)): 539 if data.y_bins[i]>= ymin and data.y_bins[i]<= ymax: 540 for j in range(len(data.x_bins)): 541 if data.x_bins[i]>= qmin and data.x_bins[i]<= qmax: 542 theory.image[j][i]=model.runXY([data.x_bins[j],data.y_bins[i]]) 538 543 539 540 #print "fitting : plot_helper:", theory.image 544 #print "fitting : plot_helper:", theory.image 541 545 #print data.image 542 theory.image=model.runXY(data.image)543 544 546 #print "fitting : plot_helper:",theory.image 545 547 theory.zmin= data.zmin -
sansview/perspectives/fitting/models.py
r2dbb681 r44bbf6a 177 177 #self.custom_models[str(id)] = item 178 178 self.model_list[str(id)]=items 179 item=items() 180 name = item.__class__.__name__ 181 if hasattr(item, "name"): 182 name = item.name 179 name = items.__name__ 180 if hasattr(items, "name"): 181 name = items.name 183 182 added_models.Append(id, name, name) 184 183 self.model_list_box[name] =items
Note: See TracChangeset
for help on using the changeset viewer.