Changeset ed2ea6a in sasview for sansview/perspectives/fitting/fit_thread.py
- Timestamp:
- Feb 27, 2009 6:53:16 PM (15 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:
- b491d6e
- Parents:
- 6d920cd
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/fit_thread.py
rc138160 red2ea6a 8 8 DEFAULT_BEAM = 0.005 9 9 import time 10 11 import thread12 print "main",thread.get_ident()13 14 10 15 11 class ConsoleUpdate(FitHandler): … … 53 49 54 50 wx.PostEvent(self.parent, StatusEvent(status=\ 55 "%d%% complete ..."%(p) ))51 "%d%% complete ..."%(p),type="update")) 56 52 57 53 # Update percent complete … … 61 57 if dt > self.progress_delta: 62 58 if 1 <= dp <= 2: 63 print "%d%% complete"%p64 59 self.progress_percent = p 65 60 self.progress_time = t 66 61 wx.PostEvent(self.parent, StatusEvent(status=\ 67 "%d%% complete ..."%(p) ))62 "%d%% complete ..."%(p),type="update")) 68 63 69 64 elif 2 < dp <= 5: 70 65 if p//5 != self.progress_percent//5: 71 print "%d%% complete"%(5*(p//5))72 66 wx.PostEvent(self.parent, StatusEvent(status=\ 73 "%d%% complete ..."%(5*(p//5)) ))67 "%d%% complete ..."%(5*(p//5)),type="update")) 74 68 self.progress_percent = p 75 69 self.progress_time = t 76 70 else: 77 71 if p//10 != self.progress_percent//10: 78 print "%d%% complete"%(10*(p//10))79 80 72 self.progress_percent = p 81 73 self.progress_time = t 82 74 wx.PostEvent(self.parent, StatusEvent(status=\ 83 "%d%% complete ..."%(10*(p//10)) ))75 "%d%% complete ..."%(10*(p//10)),type="update")) 84 76 85 77 def improvement(self): … … 107 99 108 100 class FitThread(CalcThread): 109 """ Compute 2D data"""101 """Thread performing the fit """ 110 102 111 103 def __init__(self,parent, fn,pars=None,cpage=None, qmin=None,qmax=None,ymin=None, ymax=None, … … 135 127 "Start the computation ",curr_thread=self,type="start")) 136 128 def isquit(self): 129 """ 130 @raise KeyboardInterrupt: when the thread is interrupted 131 """ 137 132 try: 138 133 CalcThread.isquit(self) 139 134 except KeyboardInterrupt: 140 #printEVT("Calc %s interrupted" % self.model.name)141 135 wx.PostEvent(self.parent, StatusEvent(status=\ 142 "Calc %g interrupted" % time.time())) 143 136 "Calc %g interrupted")) 144 137 raise KeyboardInterrupt 145 138 146 139 def update(self): 147 print "updatting" 148 elapsed = time.time()-self.starttime 140 """ 141 Is called when values of result are available 142 """ 149 143 wx.PostEvent(self.parent, StatusEvent(status="Computing \ 150 144 ... " ,curr_thread=self,type="update")) 151 145 152 146 def compute(self): 147 """ 148 Perform a fit 149 """ 153 150 try: 154 151 self.starttime = time.time() 152 #Sending a progess message to the status bar 155 153 wx.PostEvent(self.parent, StatusEvent(status=\ 156 154 "Computing . ...",curr_thread=self,type="progress")) 155 #Handler used for park engine displayed message 157 156 handler= ConsoleUpdate(parent= self.parent,improvement_delta=0.1) 157 #Result from the fit 158 158 result = self.fitter.fit(handler= handler) 159 print "result", result 160 161 print "in my compute function" 159 162 160 elapsed = time.time()-self.starttime 163 161 self.complete(result= result, … … 174 172 # Thread was interrupted, just proceed and re-raise. 175 173 # Real code should not print, but this is an example... 176 print "Thread stopped. "177 174 raise 178 175 except:
Note: See TracChangeset
for help on using the changeset viewer.