Changeset 0aeabc6 in sasview for sansview/perspectives/fitting
- Timestamp:
- May 18, 2009 10:17:11 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:
- b0eee0f0
- Parents:
- 138c139
- Location:
- sansview/perspectives/fitting
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/basepage.py
r71f0373 r0aeabc6 71 71 self.qmin_x= 0.0001 72 72 self.qmax_x= 0.13 73 self.num_points= 10073 self.num_points= 50 74 74 ## Create memento to save the current state 75 75 … … 321 321 #TODO: total hack - fix this 322 322 self.state.model= self.model.clone() 323 if not hasattr(self.model, "_persistency_dict"):324 323 #if not hasattr(self.model, "_persistency_dict"): 324 self.model._persistency_dict = {} 325 325 self.model._persistency_dict[p] = [self.values, self.weights] 326 326 self.state.model._persistency_dict[p] = [self.values, self.weights] … … 330 330 331 331 ## Redraw the model 332 print "select angle => draw"332 333 333 self._draw_model() 334 334 ## post state to fit panel … … 368 368 369 369 self.state.model = self.model.clone() 370 if not hasattr(self.model, "_persistency_dict"):371 370 #if not hasattr(self.model, "_persistency_dict"): 371 self.model._persistency_dict = {} 372 372 self.state.model._persistency_dict= copy.deepcopy(self.model._persistency_dict) 373 373 … … 471 471 Store current state 472 472 """ 473 ## save model option 473 474 if self.model!= None: 474 475 self.disp_list= self.model.getDispParamList() 475 476 self.state.disp_list= copy.deepcopy(self.disp_list) 476 477 self.state.model = self.model.clone() 477 self.state.save_data(self.data) 478 self.state.disp_list = self.disp_list 478 479 479 self.state.enable2D = copy.deepcopy(self.enable2D) 480 480 self.state.values= copy.deepcopy(self.values) 481 481 self.state.weights = copy.deepcopy( self.weights) 482 ## save data 483 self.state.save_data(self.data) 484 482 485 try: 483 486 n = self.disp_box.GetCurrentSelection() … … 516 519 self.state.values = copy.deepcopy(self.values) 517 520 self.state.weights = copy.deepcopy(self.weights) 521 ## save plotting range 518 522 self._save_plotting_range() 519 523 … … 545 549 state of the graphic interface 546 550 """ 547 ## set the value of the current state to the state given as parameter 548 self.state = state.clone() 549 550 self.model= self.state.model 551 self.data = self.state.data 552 self.smearer= self.state.smearer 551 self.model= state.model 552 self.data = state.data 553 self.smearer= state.smearer 553 554 self.enable2D= state.enable2D 554 555 … … 573 574 574 575 ## display dispersion info layer 575 self.enable_disp.SetValue(s elf.state.enable_disp)576 self.disable_disp.SetValue(s elf.state.disable_disp)576 self.enable_disp.SetValue(state.enable_disp) 577 self.disable_disp.SetValue(state.disable_disp) 577 578 578 579 if hasattr(self, "disp_box"): 579 self.disp_box.SetSelection(s elf.state.disp_box)580 self.disp_box.SetSelection(state.disp_box) 580 581 n = self.disp_box.GetCurrentSelection() 581 582 dispersity= self.disp_box.GetClientData(n) … … 586 587 self.disp_cb_dict = {} 587 588 self.disp_cb_dict = copy.deepcopy(state.disp_cb_dict) 588 self.state.disp_cb_dict = copy.deepcopy(state.disp_cb_dict)589 589 590 590 self._disp_obj_dict={} 591 for k , v in s elf.state._disp_obj_dict.iteritems():591 for k , v in state._disp_obj_dict.iteritems(): 592 592 self._disp_obj_dict[k]=v 593 593 … … 599 599 for k,v in state.disp_cb_dict.iteritems(): 600 600 self.disp_cb_dict[k].SetValue(v) 601 self.state.disp_cb_dict[k]=v601 602 602 if self.disp_cb_dict[k].GetValue(): 603 603 # Create the dispersion objects … … 610 610 #TODO: refactor model to clean this up? 611 611 self._disp_obj_dict[k] = disp_model 612 self.state._disp_obj_dict [k]= disp_model 613 self.state.values=[] 614 self.state.weights=[] 615 self.state.values = self.values 616 self.state.weights = self.weights 612 617 613 self.values=[] 618 614 self.weights = [] … … 621 617 622 618 # Set the new model as the dispersion object for the selected parameter 623 if not hasattr(self.model, "_persistency_dict"):624 619 #if not hasattr(self.model, "_persistency_dict"): 620 self.model._persistency_dict = {} 625 621 self.model._persistency_dict[k] = [state.values, state.weights] 626 622 self.model.set_dispersion(k, disp_model) 627 623 628 624 ##plotting range restore 629 self._reset_plotting_range( )625 self._reset_plotting_range(state) 630 626 ## smearing info restore 631 627 if hasattr(self,"enable_smearer"): 632 628 ## set smearing value whether or not the data contain the smearing info 633 self.enable_smearer.SetValue(self.state.enable_smearer) 634 self.disable_smearer.SetValue(self.state.disable_smearer) 635 self.compute_chisqr(smearer= self.smearer) 629 self.enable_smearer.SetValue(state.enable_smearer) 630 self.disable_smearer.SetValue(state.disable_smearer) 631 self.tcChi.SetLabel(str( state.tcChi)) 632 self.sizer5.Layout() 633 self.Layout() 634 self.Refresh() 635 #self.compute_chisqr(smearer= self.smearer) 636 636 637 637 ## reset state of checkbox,textcrtl and dispersity parameters value … … 642 642 ## draw the model with previous parameters value 643 643 self._onparamEnter_helper() 644 644 645 645 ## reset context menu items 646 646 self._reset_context_menu() 647 648 647 ## set the value of the current state to the state given as parameter 648 self.state = state.clone() 649 ## post state to fit panel 650 event = PageInfoEvent(page = self) 651 wx.PostEvent(self.parent, event) 649 652 650 653 def _selectDlg(self): … … 674 677 675 678 676 def _reset_plotting_range(self ):679 def _reset_plotting_range(self, state): 677 680 """ 678 681 Reset the plotting range to a given state 679 682 """ 680 681 self.qmin.SetValue(str(self.state.qmin)) 682 self.qmax.SetValue(str(self.state.qmax)) 683 self.qmin.SetValue(str(state.qmin)) 684 self.qmax.SetValue(str(state.qmax)) 683 685 if self.state.npts!=None: 684 self.npts.SetValue(format_number(self.state.npts)) 685 self.num_points = float(self.state.npts) 686 687 self.qmin_x = float(self.qmin.GetValue()) 688 self.qmax_x = float(self.qmax.GetValue()) 689 686 self.npts.SetValue(str(state.npts)) 687 690 688 691 689 def _save_plotting_range(self ): … … 743 741 ## if any value is modify draw model with new value 744 742 if is_modified: 745 print "is_modified--->",is_modified743 746 744 self._draw_model() 747 745 self.save_current_state() … … 960 958 if self.enable_smearer.GetValue(): 961 959 temp_smear= self.smearer 962 print "self.model.dispersion",self.model.dispersion960 963 961 self.manager.draw_model(self.model, data=self.data, 964 962 smearer= temp_smear, … … 1143 1141 from sans.models.MultiplicationModel import MultiplicationModel 1144 1142 self.model= MultiplicationModel(form_factor(),struct_factor()) 1143 1145 1144 else: 1146 1145 if form_factor != None: … … 1339 1338 self.model.set_dispersion(p, disp_model) 1340 1339 # Redraw the model 1341 print "reset dispersity=> draw"1340 1342 1341 self._draw_model() 1343 1342 -
sansview/perspectives/fitting/fitpage.py
r71f0373 r0aeabc6 557 557 tcrtl.SetBackgroundColour("pink") 558 558 tcrtl.Refresh() 559 return 559 560 else: 560 561 tcrtl.SetBackgroundColour(wx.WHITE) 561 562 tcrtl.Refresh() 562 self._onparamEnter_helper() 563 self._onparamEnter_helper() 564 565 ##compute chisqr for range change 566 temp_smearer = None 567 if self.enable_smearer.GetValue(): 568 msg="" 569 temp_smearer= self.smearer 570 ##Calculate chi2 571 self.compute_chisqr(smearer= temp_smearer) 572 563 573 564 574 def _onparamEnter(self,event): … … 747 757 """ 748 758 try: 749 self.tcChi.SetLabel(format_number(output)) 759 self.tcChi.SetLabel(str(output)) 760 761 self.sizer5.Layout() 762 self.Layout() 763 self.Refresh 764 ## post state to fit panel 765 self.state.tcChi =output 766 event = PageInfoEvent(page = self) 767 wx.PostEvent(self.parent, event) 750 768 except: 751 raise769 pass 752 770 753 771 … … 809 827 if self.calc_Chisqr!= None and self.calc_Chisqr.isrunning(): 810 828 self.calc_Chisqr.stop() 811 829 812 830 self.calc_Chisqr= CalcChisqr2D( x_bins= self.data.x_bins, 813 831 y_bins= self.data.y_bins, -
sansview/perspectives/fitting/fitpanel.py
r71f0373 r0aeabc6 332 332 self.model_page_number=self.GetSelection() 333 333 self.model_page=self.GetPage(self.GetSelection()) 334 # Set the range used to plot models 335 self.model_page.set_range(qmin, qmax, npts) 334 336 335 ## resetting page 337 336 if reset: … … 339 338 340 339 memento= self.fit_page_name[page_title][0] 341 342 340 panel.reset_page(memento) 343 341 else: 344 342 self.fit_page_name[page_title]=[] 345 343 self.fit_page_name[page_title].insert(0,panel.createMemento()) 346 ## We just created a model page, we are ready to plot the model 347 self.manager.draw_model(model, qmin=qmin, qmax=qmax) 344 348 345 349 -
sansview/perspectives/fitting/gui_thread.py
r6dd2be3 r0aeabc6 149 149 """ 150 150 self.starttime = time.time() 151 if self.model ==None: 152 return 153 if self.data==None: 154 return 151 155 if self.err_data==None or self.err_data==[]: 152 156 self.err_data= numpy.zeros(len(self.x_bins),len(self.y_bins)) -
sansview/perspectives/fitting/pagestate.py
r71f0373 r0aeabc6 23 23 # model on which the fit would be performed 24 24 self.model = model 25 if not hasattr(self.model, "_persistency_dict"):26 self.model._persistency_dict = {}27 self.model._persistency_dict = copy.deepcopy(model._persistency_dict)25 #if not hasattr(self.model, "_persistency_dict"): 26 # self.model._persistency_dict = {} 27 #self.model._persistency_dict = copy.deepcopy(model._persistency_dict) 28 28 #fit page manager 29 29 self.manager = None … … 84 84 ## state of selected all check button 85 85 self.cb1 = False 86 ## store value of chisqr 87 self.tcChi= None 86 88 87 89 … … 115 117 obj.enable_disp = copy.deepcopy(self.enable_disp) 116 118 obj.disable_disp = copy.deepcopy(self.disable_disp) 117 if self.model !=None and len(self.model._persistency_dict)>0: 118 for k, v in self.model._persistency_dict.iteritems(): 119 obj.model._persistency_dict[k] = copy.deepcopy(v) 119 obj.tcChi = self.tcChi 120 120 121 if len(self._disp_obj_dict)>0: 121 122 for k , v in self._disp_obj_dict.iteritems():
Note: See TracChangeset
for help on using the changeset viewer.