Changeset 1b07935d in sasview for sansview/perspectives/fitting
- Timestamp:
- Sep 8, 2008 9:10:57 AM (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:
- 6f4b71f
- Parents:
- d89f09b
- Location:
- sansview/perspectives/fitting
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/fitpage.py
rd89f09b r1b07935d 495 495 when enter value on panel redraw model according to changed 496 496 """ 497 self.set_model_parameter() 498 499 def set_model_parameter(self): 497 500 if len(self.parameters) !=0 and self.model !=None: 498 501 for item in self.parameters: … … 507 510 wx.PostEvent(self.parent.GrandParent, StatusEvent(status=\ 508 511 "Drawing Error:wrong value entered : %s"% sys.exc_value)) 509 510 511 512 def select_all_param(self,event): 512 513 """ -
sansview/perspectives/fitting/fitpanel.py
rd89f09b r1b07935d 49 49 self.model_list_box={} 50 50 # save the title of the last page tab added 51 self.name=None 51 self.fit_page_name=None 52 self.draw_model_name=[] 52 53 self.nb.Update() 53 54 self.SetSizer(self.sizer) … … 72 73 73 74 74 def add_ page( self,page_title ):75 def add_fit_page( self,page_title ): 75 76 """ 76 77 Add a fitting page on the notebook contained by fitpanel … … 79 80 @return panel : page just added for futher used. is used by fitting module 80 81 """ 81 if self. name != page_title:82 if self.fit_page_name != page_title: 82 83 from fitpage import FitPage 83 84 panel = FitPage(self.nb, -1) … … 86 87 self.nb.AddPage(page=panel,text=page_title,select=True) 87 88 panel.populate_box( self.model_list_box) 88 self. name = page_title89 self.fit_page_name = page_title 89 90 return panel 91 def add_model_page(self,model,page_title): 92 if not page_title in self.draw_model_name: 93 from modelpage import ModelPage 94 panel = ModelPage(self.nb,model, -1) 95 panel.set_manager(self.manager) 96 panel.set_owner(self.event_owner) 97 self.nb.AddPage(page=panel,text=page_title,select=True) 98 panel.populate_box( self.model_list_box) 99 self.draw_model_name.append(page_title) 100 90 101 91 102 def get_notebook(self): -
sansview/perspectives/fitting/fitproblem.py
rd89f09b r1b07935d 65 65 """ 66 66 67 self.model_list[0].model.setParam(name,value) 68 new_model=Model(self.model_list[0].model) 69 self.model_list[0]=new_model 67 self.model_list[0].setParam(name,value) 68 70 69 71 70 def reset_model(self,model): -
sansview/perspectives/fitting/fitting.py
rd89f09b r1b07935d 74 74 self.fit_panel.set_model_list(self.menu_mng.get_model_list()) 75 75 owner.Bind(fitpage.EVT_MODEL_BOX,self._on_model_panel) 76 #owner.Bind(modelpage.EVT_MODEL_DRAW,self.draw_model) 76 77 77 78 return [(id, self.menu1, "Fitting"),(id2, menu2, "Model")] … … 154 155 name = 'Fit' 155 156 try: 156 page = self.fit_panel.add_ page(name)157 page = self.fit_panel.add_fit_page(name) 157 158 page.set_data_name(item) 158 159 self.page_finder[page]= FitProblem() … … 219 220 for name in pars: 220 221 if result.pvec.__class__==numpy.float64: 221 model. model.setParam(name,result.pvec)222 model.setParam(name,result.pvec) 222 223 else: 223 model. model.setParam(name,result.pvec[i])224 model.setParam(name,result.pvec[i]) 224 225 #print "fitting: i name out[i]", i,name,float(result.pvec[i]) 225 226 i += 1 … … 255 256 print "fitting: fit in park fitting", p.name, p.value,p.stderr 256 257 model_name,param_name = self.split_string(p.name) 257 print "fitting: simultfit",model. model.name,model_name,param_name ,p.name,param_name,p.value258 if model. model.name == model_name:258 print "fitting: simultfit",model.name,model_name,param_name ,p.name,param_name,p.value 259 if model.name == model_name: 259 260 print "fitting: hello",p.name,param_name,p.value 260 261 small_out.append(p.value ) 261 262 small_cov.append(p.stderr) 262 model. model.setParam(param_name,p.value)263 model.setParam(param_name,p.value) 263 264 #print "fitting: out of each page",page,small_out,small_cov,data.group_id 264 265 page.onsetValues(result.fitness, small_out,small_cov) … … 408 409 #print "fitter",self.fitter 409 410 #print "fitting: model name",model.name 410 self.fitter.set_model( model,model.model.name, self.id, pars)411 self.fitter.set_model(Model(model),model.name, self.id, pars) 411 412 self.fitter.set_data(data,self.id,qmin,qmax) 412 413 else: … … 455 456 self.page_finder[current_pg].set_theory("Fitness") 456 457 #print "on model",model.name 457 self.page_finder[current_pg].set_model( Model(model),M_name)458 self.page_finder[current_pg].set_model(model,M_name) 458 459 self.plot_helper(currpage= current_pg,qmin= None,qmax= None) 459 460 sim_page.add_model(self.page_finder) … … 503 504 try: 504 505 tempx = qmin 505 tempy = model. eval(qmin)506 tempy = model.run(qmin) 506 507 theory.x.append(tempx) 507 508 theory.y.append(tempy) … … 514 515 if data.x[i]> qmin and data.x[i]< qmax: 515 516 tempx = data.x[i] 516 tempy = model. eval(tempx)517 tempy = model.run(tempx) 517 518 518 519 theory.x.append(tempx) … … 523 524 try: 524 525 tempx = qmax 525 tempy = model. eval(qmax)526 tempy = model.run(qmax) 526 527 theory.x.append(tempx) 527 528 theory.y.append(tempy) … … 542 543 Plot a theory from a model selected from the menu 543 544 """ 545 #name = evt.model.__class__.__name__ 546 name="Model View" 547 self.fit_panel.add_model_page(evt.model,name) 548 self.draw_model(evt.model) 549 550 def draw_model(self,model): 544 551 x = pylab.arange(0.001, 0.1, 0.001) 545 552 xlen = len(x) … … 548 555 549 556 for i in range(xlen): 550 y[i] = evt.model.run(x[i])557 y[i] = model.run(x[i]) 551 558 dy[i] = math.sqrt(math.fabs(y[i])) 552 559 try: … … 562 569 print "SimView.complete1D: could not import sans.guicomm.events" 563 570 564 565 571 if __name__ == "__main__": 566 572 i = Plugin() -
sansview/perspectives/fitting/simfitpage.py
rd89f09b r1b07935d 1 2 1 3 2 import sys,re,string, wx … … 55 54 self.model_list=[] 56 55 self.model_toFit=[] 56 self.page_finder={} 57 57 iy +=1 58 58 self.sizer2.Add((20,20),(iy, ix)) … … 64 64 65 65 def onFit(self,event): 66 """ signal for fitting""" 67 if len(self.model_toFit) >0 : 68 self.set_model() 69 self.manager._on_simul_fit() 70 else: 71 wx.PostEvent(self.parent.GrandParent, StatusEvent(status=\ 66 """ signal for fitting""" 67 if len(self.model_toFit) >0 : 68 if len(self.params)>0: 69 self.set_model() 70 else: 71 for page in self.page_finder.iterkeys(): 72 page.set_model_parameter() 73 self.manager._on_simul_fit() 74 else: 75 wx.PostEvent(self.parent.GrandParent, StatusEvent(status=\ 72 76 "Select at least on model to fit ")) 73 77 def set_manager(self, manager): … … 99 103 @param page_finder: the dictionary containing models information 100 104 """ 105 import copy 101 106 self.model_list=[] 102 107 self.model_toFit=[] 103 108 self.sizer1.Clear(True) 109 self.page_finder=page_finder 104 110 ix = 0 105 111 iy = 1 … … 179 185 #print "simfitpage: list fitpanel2",list,list[0] 180 186 model=list[0] 181 param_list=model. model.getParamList()187 param_list=model.getParamList() 182 188 #print "simfitpage: on set_model ",self.params 183 189 if self.params !=[]: 184 190 for element in self.params: 185 if model. model.name == str(element[0]):191 if model.name == str(element[0]): 186 192 for item in param_list: 187 193 if item==str(element[1]): … … 189 195 #print "simfitpage: model name",element[0], model.name 190 196 #print "simfitpage: param name ,param value",element[1],element[2] 191 self.manager.set_page_finder(model. model.name,element[1],\197 self.manager.set_page_finder(model.name,element[1],\ 192 198 str(element[2])) 193 199 #print "simfitpage:on set_model page 2",model.params['A'],self.params[2] 194 200 195 201 196 202 def _onTextEnter(self,event):
Note: See TracChangeset
for help on using the changeset viewer.