- Timestamp:
- Jun 30, 2008 2:56:01 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:
- bd30f4a5
- Parents:
- e96a852
- Location:
- prview/perspectives/pr
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
prview/perspectives/pr/inversion_panel.py
ra4bd2ac r35adaf6 149 149 ## Estimates 150 150 self.alpha_estimate_ctl = None 151 self.nterms_estimate_ctl = None 151 152 152 153 ## Data manager … … 194 195 #self.alpha_estimate_ctl.Show() 195 196 #self.label_sugg.Show() 197 elif name=='nterms_estimate': 198 self.nterms_estimate_ctl.SetToolTipString("Click to accept value.") 199 self.nterms_estimate_ctl.Enable(True) 200 self.nterms_estimate_ctl.SetLabel("%-g" % value) 196 201 elif name=='plotname': 197 202 if self.standalone==False: … … 274 279 elif name=='alpha_estimate': 275 280 return self.alpha_estimate_ctl.GetLabel() 281 elif name=='nterms_estimate': 282 return self.nterms_estimate_ctl.GetLabel() 276 283 elif name=='plotname': 277 284 if self.standalone==False: … … 400 407 self.alpha_estimate_ctl.SetToolTipString("Waiting for estimate...") 401 408 409 id = wx.NewId() 410 self.nterms_estimate_ctl = wx.Button(self, id, "") 411 #self.nterms_estimate_ctl.Hide() 412 self.Bind(wx.EVT_BUTTON, self._on_accept_nterms, id = id) 413 self.nterms_estimate_ctl.Enable(False) 414 #self.nterms_estimate_ctl.SetBackgroundColour('#ffdf85') 415 #self.nterms_estimate_ctl.SetBackgroundColour(self.GetBackgroundColour()) 416 self.nterms_estimate_ctl.SetToolTipString("Waiting for estimate...") 417 402 418 # EVT_TEXT would trigger an event for each character entered 403 419 #self.nfunc_ctl.Bind(wx.EVT_KILL_FOCUS, self._on_pars_changed) … … 420 436 sizer_params.Add(label_nfunc, (iy,0), (1,1), wx.LEFT, 15) 421 437 sizer_params.Add(self.nfunc_ctl, (iy,1), (1,1), wx.RIGHT, 0) 438 sizer_params.Add(self.nterms_estimate_ctl, (iy,2), (1,1), wx.LEFT, 15) 422 439 iy += 1 423 440 sizer_params.Add(label_alpha, (iy,0), (1,1), wx.LEFT, 15) … … 593 610 print "InversionControl._on_accept_alpha: %s" % sys.exc_value 594 611 pass 612 613 def _on_accept_nterms(self, evt): 614 """ 615 User has accepted the estimated number of terms, 616 set it as part of the input parameters 617 """ 618 try: 619 nterms = self.nterms_estimate_ctl.GetLabel() 620 tmp = float(nterms) 621 self.nfunc_ctl.SetValue(nterms) 622 except: 623 # No estimate or bad estimate, either do nothing 624 import sys 625 print "InversionControl._on_accept_nterms: %s" % sys.exc_value 626 pass 595 627 596 628 def _on_reset(self, evt): … … 613 645 self.alpha_estimate_ctl.Enable(False) 614 646 self.alpha_estimate_ctl.SetLabel("") 647 self.nterms_estimate_ctl.Enable(False) 648 self.nterms_estimate_ctl.SetLabel("") 615 649 self._on_pars_changed() 616 650 -
prview/perspectives/pr/pr.py
ra4bd2ac r35adaf6 403 403 if not message==None: 404 404 wx.PostEvent(self.parent, StatusEvent(status=str(message))) 405 406 self.perform_estimateNT() 407 408 409 410 def _estimateNT_completed(self, nterms, alpha, message, elapsed): 411 """ 412 Parameter estimation completed, 413 display the results to the user 414 @param alpha: estimated best alpha 415 @param nterms: estimated number of terms 416 @param elapsed: computation time 417 """ 418 # Save useful info 419 print "Number of terms =", nterms 420 self.elapsed = elapsed 421 self.control_panel.nterms_estimate = nterms 422 self.control_panel.alpha_estimate = alpha 423 if not message==None: 424 wx.PostEvent(self.parent, StatusEvent(status=str(message))) 405 425 406 426 def _completed(self, out, cov, pr, elapsed): … … 613 633 self.estimation_thread = EstimatePr(pr, self.nfunc, error_func=self._thread_error, 614 634 completefn = self._estimate_completed, 635 updatefn = None) 636 self.estimation_thread.queue() 637 self.estimation_thread.ready(2.5) 638 639 def perform_estimateNT(self): 640 from pr_thread import EstimateNT 641 from copy import deepcopy 642 643 wx.PostEvent(self.parent, StatusEvent(status='')) 644 # If a thread is already started, stop it 645 if self.estimation_thread != None and self.estimation_thread.isrunning(): 646 self.estimation_thread.stop() 647 648 pr = self.pr.clone() 649 self.estimation_thread = EstimateNT(pr, self.nfunc, error_func=self._thread_error, 650 completefn = self._estimateNT_completed, 615 651 updatefn = None) 616 652 self.estimation_thread.queue() … … 746 782 """ 747 783 self.parent.set_perspective(self.perspective) 748 784 785 if __name__ == "__main__": 786 i = Plugin() 787 print i.perform_estimateNT() 788 789 790 791 -
prview/perspectives/pr/pr_thread.py
r7cb0353 r35adaf6 75 75 CalcThread.isquit(self) 76 76 except KeyboardInterrupt: 77 printEVT(" P(r) calcinterrupted")77 printEVT("Alpha estimator thread interrupted") 78 78 raise KeyboardInterrupt 79 79 … … 84 84 try: 85 85 alpha, message, elapsed = self.pr.estimate_alpha(self.nfunc) 86 self.isquit() 86 87 self.complete(alpha=alpha, message=message, elapsed=elapsed) 87 88 except: … … 89 90 printEVT("EstimatePr.compute: %s" % sys.exc_value) 90 91 92 class EstimateNT(CalcThread): 91 93 94 def __init__(self, pr, nfunc=5, error_func=None, 95 completefn = None, 96 updatefn = None, 97 yieldtime = 0.01, 98 worktime = 0.01 99 ): 100 CalcThread.__init__(self,completefn, 101 updatefn, 102 yieldtime, 103 worktime) 104 self.pr = pr 105 self.nfunc = nfunc 106 self.error_func = error_func 107 self.starttime = 0 108 109 def isquit(self): 110 try: 111 CalcThread.isquit(self) 112 except KeyboardInterrupt: 113 printEVT("Number of terms thread interrupted") 114 raise KeyboardInterrupt 115 116 def compute(self): 117 """ 118 Calculates the estimate 119 """ 120 import time 121 try: 122 t_0 = time.time() 123 nterms, alpha, message = self.pr.estimate_numterms(self.isquit) 124 t_1 = time.time()-t_0 125 self.isquit() 126 self.complete(nterms=nterms, alpha=alpha, message=message, elapsed=t_1) 127 except: 128 if not self.error_func==None: 129 printEVT("EstimatePr2.compute: %s" % sys.exc_value) 130 131
Note: See TracChangeset
for help on using the changeset viewer.