- Timestamp:
- Apr 20, 2009 12:34:13 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:
- 2872035
- Parents:
- d0ce2c30
- Location:
- sansview/perspectives/fitting
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/basepage.py
r9e6c27f r1c1436d 471 471 self.state.orientation_params_disp) 472 472 473 473 474 ## post state to fit panel 474 475 event = PageInfoEvent(page = self) … … 678 679 if len(listtocopy)==0: 679 680 return 680 681 681 682 for item in listtocopy: 682 683 checkbox_state = None … … 1106 1107 Add more item to select user dispersity 1107 1108 """ 1108 if self.model == None: 1109 msg= " Select non - model value:%s !"%self.model 1110 wx.PostEvent(self.parent.parent, StatusEvent(status= msg)) 1111 return 1109 self._reset_dispersity() 1110 1111 if self.enable_disp.GetValue(): 1112 self.model_disp.Show(True) 1113 self.disp_box.Show(True) 1114 ## layout for model containing no dispersity parameters 1115 if len(self.disp_list)==0: 1116 self._layout_sizer_noDipers() 1117 else: 1118 ## set gaussian sizer 1119 self._on_select_Disp(event=None) 1112 1120 else: 1113 1114 if self.enable_disp.GetValue(): 1115 self.model_disp.Show(True) 1116 self.disp_box.Show(True) 1117 ## layout for model containing no dispersity parameters 1118 if len(self.disp_list)==0: 1119 self._layout_sizer_noDipers() 1120 else: 1121 ## set gaussian sizer 1122 self._on_select_Disp(event=None) 1123 else: 1124 self.model_disp.Hide() 1125 self.disp_box.Hide() 1126 self.sizer4_4.Clear(True) 1127 self._reset_dispersity() 1128 1129 1130 ## post state to fit panel 1131 self.save_current_state() 1121 self.model_disp.Hide() 1122 self.disp_box.Hide() 1123 self.sizer4_4.Clear(True) 1124 self._reset_dispersity() 1125 1126 1127 ## post state to fit panel 1128 self.save_current_state() 1132 1129 1133 1130 … … 1142 1139 self.fittable_param=[] 1143 1140 self.fixed_param=[] 1141 self.orientation_params_disp=[] 1142 1144 1143 self.model_disp.Hide() 1145 1144 self.disp_box.Hide() … … 1156 1155 put gaussian dispersity into current model 1157 1156 """ 1157 if len(self.param_toFit)>0: 1158 for item in self.fittable_param: 1159 if item in self.para_toFit: 1160 self.param_toFit.remove(item) 1161 for item in self.orientation_params_disp: 1162 if item in self.para_toFit: 1163 self.param_toFit.remove(item) 1164 1158 1165 self.fittable_param=[] 1159 1166 self.fixed_param=[] 1160 1167 self.orientation_params_disp=[] 1168 1161 1169 from sans.models.dispersion_models import GaussianDispersion 1162 1170 if len(self.disp_cb_dict)==0: … … 1221 1229 draw sizer with array dispersity parameters 1222 1230 """ 1231 self.fittable_param=[] 1232 self.fixed_param=[] 1223 1233 self.orientation_params_disp=[] 1224 1234 self.sizer4_4.Clear(True) -
sansview/perspectives/fitting/fit_thread.py
r179a411 r1c1436d 119 119 120 120 self.done= False 121 wx.PostEvent(self.parent, StatusEvent(status=\ 122 "Start the computation ",curr_thread=self,type="start")) 121 123 122 def isquit(self): 124 123 """ … … 128 127 CalcThread.isquit(self) 129 128 except KeyboardInterrupt: 130 wx.PostEvent(self.parent, StatusEvent(status=\131 "Calc %g interrupted"))132 129 raise KeyboardInterrupt 133 130 134 def update(self):135 """136 Is called when values of result are available137 """138 wx.PostEvent(self.parent, StatusEvent(status="Computing \139 ... " ,curr_thread=self,type="update"))140 141 131 def compute(self): 142 132 """ … … 145 135 try: 146 136 self.starttime = time.time() 147 #Sending a progess message to the status bar 148 wx.PostEvent(self.parent, StatusEvent(status=\ 149 "Computing . ...",curr_thread=self,type="progress")) 137 150 138 #Handler used for park engine displayed message 151 139 handler= ConsoleUpdate(parent= self.parent,improvement_delta=0.1) … … 163 151 # Real code should not print, but this is an example... 164 152 raise 165 except: 166 msg= "Fitting error: %s" % sys.exc_value 167 wx.PostEvent(self.parent, StatusEvent(status=msg, type="stop")) 168 return 153 169 154 -
sansview/perspectives/fitting/fitpage.py
rd0ce2c30 r1c1436d 40 40 self.npts=None 41 41 ## if no dispersity parameters is avaible 42 self.text_disp_1=None42 #self.text_disp_1=None 43 43 ## default fitengine type 44 44 self.engine_type = None … … 435 435 ,None,None, None, None,None]) 436 436 self.orientation_params_disp.append([None,name3, Tctl 437 ,None,None, None, None,None]) 437 ,None,None, None, None,None]) 438 self._copy_parameters_state(self.orientation_params_disp, 439 self.state.orientation_params_disp) 438 440 439 441 wx.PostEvent(self.parent, StatusEvent(status=\ … … 467 469 # Remove or do not allow fitting on the Q=0 point, especially when y(q=0)=None at x[0]. 468 470 #ToDo: Fix this. 469 if float(self.qmin.GetValue())==0.0 and self.data.x[0]==0 and not numpy.isfinite(self.data.y[0]):470 self.qmin_x = min(self.data.x[self.data.x!=0])471 else:472 471 #if float(self.qmin.GetValue())==0.0 and self.data.x[0]==0 and not numpy.isfinite(self.data.y[0]): 472 # self.qmin_x = min(self.data.x[self.data.x!=0]) 473 #else: 474 self.qmin_x = float(self.qmin.GetValue()) 473 475 474 476 self.qmax_x =float( self.qmax.GetValue()) … … 478 480 #single fit 479 481 self.manager.onFit() 480 482 self.btFit.SetFocus() 481 483 self.sizer5.Layout() 482 484 self.SetScrollbars(20,20,55,40) … … 499 501 self.enable_disp.SetValue(False) 500 502 self.disable_disp.SetValue(True) 501 self. _set_dipers_Param(event=None)503 self.set_dispers_sizer() 502 504 503 505 evt = ModelEventbox(model=self.model) … … 589 591 has_error = False 590 592 self.text2_3.Hide() 591 if self.text_disp_1 !=None: 592 self.text_disp_1.Hide() 593 if hasattr(self,"text_disp_1" ): 594 if self.text_disp_1 !=None: 595 self.text_disp_1.Hide() 593 596 #set the panel when fit result are float not list 594 597 if out.__class__==numpy.float64: … … 600 603 if cov !=None : 601 604 self.text2_3.Show(True) 602 if self.text_disp_1 !=None: 603 self.text_disp_1.Show(True) 605 if hasattr(self,"text_disp_1" ): 606 if self.text_disp_1 !=None: 607 self.text_disp_1.Show(True) 604 608 if cov[0]==None: 605 609 self.param_toFit[0][3].Hide() … … 627 631 if(cov !=None)and len(cov)<=len(self.param_toFit)and i < len(cov): 628 632 self.text2_3.Show(True) 629 if self.text_disp_1!=None: 630 self.text_disp_1.Show(True) 633 if hasattr(self,"text_disp_1" ): 634 if self.text_disp_1!=None: 635 self.text_disp_1.Show(True) 631 636 item[3].Show(True) 632 637 item[4].Clear() -
sansview/perspectives/fitting/fitting.py
rda594d0 r1c1436d 442 442 current_pg= page 443 443 except: 444 msg= "%s error: %s" % (engineType,sys.exc_value) 445 wx.PostEvent(self.parent, StatusEvent(status= msg )) 446 return 444 raise 445 return 446 #msg= "%s error: %s" % (engineType,sys.exc_value) 447 #wx.PostEvent(self.parent, StatusEvent(status= msg )) 448 #return 447 449 #Do the simultaneous fit 448 450 try: … … 450 452 if self.calc_fit!= None and self.calc_fit.isrunning(): 451 453 self.calc_fit.stop() 454 455 wx.PostEvent(self.parent, StatusEvent(status="Start the computation", 456 curr_thread=self.calc_fit,type="start")) 457 wx.PostEvent(self.parent, StatusEvent(status="Computing...", 458 curr_thread=self.calc_fit,type="progress")) 452 459 ## perform single fit 453 460 if self._fit_engine=="scipy": … … 458 465 pars= pars, 459 466 completefn= self._single_fit_completed, 460 updatefn= None)467 updatefn=self._updateFit) 461 468 462 469 else: … … 465 472 fn= self.fitter, 466 473 completefn= self._simul_fit_completed, 467 updatefn= None)474 updatefn=self._updateFit) 468 475 self.calc_fit.queue() 469 476 self.calc_fit.ready(2.5) 470 477 471 478 except: 472 msg= "%s error: %s" % (engineType,sys.exc_value) 473 wx.PostEvent(self.parent, StatusEvent(status= msg ,type="stop")) 474 return 479 raise 480 #msg= "%s error: %s" % (engineType,sys.exc_value) 481 #wx.PostEvent(self.parent, StatusEvent(status= msg ,type="stop")) 482 #return 475 483 476 484 … … 556 564 value.clear_model_param() 557 565 except: 558 msg= title +" error: %s" % sys.exc_value 559 wx.PostEvent(self.parent, StatusEvent(status= msg, type="stop")) 566 raise 560 567 return 568 #msg= title +" error: %s" % sys.exc_value 569 #wx.PostEvent(self.parent, StatusEvent(status= msg, type="stop")) 570 #return 561 571 562 572 def _onSelect(self,event): … … 632 642 %sys.exc_value)) 633 643 return 634 644 def _updateFit(self): 645 """ 646 Is called when values of result are available 647 """ 648 ##Sending a progess message to the status bar 649 wx.PostEvent(self.parent, StatusEvent(status="Computing...")) 650 635 651 def _single_fit_completed(self,result,pars,cpage, elapsed=None): 636 652 """ … … 644 660 """ 645 661 wx.PostEvent(self.parent, StatusEvent(status="Single fit \ 646 complete! " , type="stop")) 662 complete! " )) 663 647 664 try: 648 665 for page, value in self.page_finder.iteritems(): … … 669 686 self.draw_model( model=model, data= metadata, smearer= smearer, 670 687 qmin= qmin, qmax= qmax) 671 688 wx.PostEvent(self.parent, StatusEvent(status=" " , type="stop")) 672 689 except: 673 msg= "Single Fit completed but Following error occurred:%s"% sys.exc_value 674 wx.PostEvent(self.parent, StatusEvent(status=msg,type="stop")) 675 return 690 raise 691 #msg= "Single Fit completed but Following error occurred:%s"% sys.exc_value 692 #wx.PostEvent(self.parent, StatusEvent(status=msg,type="stop")) 693 #return 676 694 677 695 … … 684 702 """ 685 703 wx.PostEvent(self.parent, StatusEvent(status="Simultaneous fit \ 686 complete " , type="stop"))704 complete ")) 687 705 688 706 ## fit more than 1 model at the same time … … 703 721 small_out.append(p.value ) 704 722 model.setParam(param_name,p.value) 705 """ 706 if p.stderr==None: 707 p.stderr=numpy.nan 708 small_cov.append(p.stderr) 709 else: 710 small_cov.append(p.stderr) 711 """ 723 712 724 small_cov.append(p.stderr) 713 725 else: 714 726 value= model.getParam(param_name) 715 727 small_out.append(value ) 716 #small_cov.append(numpy.nan)717 728 small_cov.append(None) 718 729 # Display result on each page … … 725 736 self.draw_model( model=model, data= metadata, smearer=smearer, 726 737 qmin= qmin, qmax= qmax) 727 738 wx.PostEvent(self.parent, StatusEvent(status="", type="stop")) 728 739 except: 729 740 msg= "Simultaneous Fit completed" -
sansview/perspectives/fitting/modelpage.py
rfc6ea43 r1c1436d 326 326 self.model = model 327 327 self.set_model_param_sizer(self.model) 328 self._draw_model()328 329 329 ## keep the sizer view consistent with the model menu selecting 330 330 self._set_model_sizer_selection( self.model ) 331 331 self.enable_disp.SetValue(False) 332 332 self.disable_disp.SetValue(True) 333 self. _set_dipers_Param(event=None)333 self.set_dispers_sizer() 334 334 self.model_view.SetFocus() 335 self._draw_model() 335 336 336 337
Note: See TracChangeset
for help on using the changeset viewer.