Changeset 2bb37c3 in sasview
- Timestamp:
- Oct 20, 2011 1:23:44 PM (13 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:
- e947cd4
- Parents:
- dbbdf11
- Location:
- fittingview/src/sans/perspectives/fitting
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
fittingview/src/sans/perspectives/fitting/console.py
rafa0a31 r2bb37c3 36 36 self.progress_delta = progress_delta 37 37 self.improvement_delta = improvement_delta 38 self.elapsed_time = self.progress_time 38 self.elapsed_time = time.time() 39 self.update_duration = time.time() 40 self.fit_duration = 0 41 39 42 40 43 def progress(self, k, n): … … 50 53 dt = t - self.improvement_time 51 54 if self.isbetter and dt > self.improvement_delta: 52 self.result.print_summary() 55 #self.result.print_summary() 56 self.update_fit() 53 57 self.isbetter = False 54 58 self.improvement_time = t 55 56 wx.PostEvent(self.parent, StatusEvent(status=\57 "%d%% complete ..."%(p),type="progress"))58 59 59 60 # Update percent complete … … 65 66 self.progress_percent = p 66 67 self.progress_time = t 67 wx.PostEvent(self.parent, StatusEvent(status=\ 68 "%d%% complete ..."%(p), 69 type="progress")) 70 68 self.update_fit() 71 69 elif 2 < dp <= 5: 72 70 if p//5 != self.progress_percent//5: 73 wx.PostEvent(self.parent, StatusEvent(status=\74 "%d%% complete ..."%(5*(p//5)),type="progress"))75 71 self.progress_percent = p 76 72 self.progress_time = t … … 79 75 self.progress_percent = p 80 76 self.progress_time = t 81 wx.PostEvent(self.parent, StatusEvent(status=\ 82 "%d%% complete ..."%(10*(p//10)),type="progress")) 77 self.update_fit() 83 78 84 79 def improvement(self): … … 89 84 self.isbetter = True 90 85 86 def print_result(self): 87 """ 88 Print result object 89 """ 90 msg = " \n %s \n" % self.result.__str__() 91 wx.PostEvent(self.parent, StatusEvent(status=msg)) 92 91 93 def error(self, msg): 92 94 """ … … 94 96 """ 95 97 if self.isbetter: 96 self.result.print_summary() 97 message = "Fit Abort:" 98 message = str(msg)+ " \n %s"%self.result.__str__() 98 #self.result.print_summary() 99 self.update_fit() 100 101 message = str(msg) + " \n %s \n" % self.result.__str__() 99 102 wx.PostEvent(self.parent, StatusEvent(status=message, 100 103 info="error", type="stop")) … … 103 106 """ 104 107 if self.isbetter: 105 self.result.print_summary() 108 #self.result.print_summary() 109 self.update_fit() 106 110 107 111 def abort(self): … … 109 113 """ 110 114 if self.isbetter: 111 self.result.print_summary() 115 #self.result.print_summary() 116 self.update_fit() 112 117 113 118 114 def update_fit(self, msg="" ):119 def update_fit(self, msg="", last=False): 115 120 """ 116 121 """ 117 self.elapsed_time = time.time() - self.elapsed_time 118 dt = self.elapsed_time - self.progress_time 119 if dt > 5: 120 msg = " Updating fit... \n Chi2/Npts = %s \n"\ 121 % (self.result.fitness) 122 t1 = time.time() 123 self.elapsed_time = t1 - self.update_duration 124 self.update_duration = t1 125 self.fit_duration += self.elapsed_time 126 str_time = time.strftime("%a, %d %b %Y %H:%M:%S ", time.localtime(t1)) 127 UPDATE_INTERVAL = 0.5 128 u_flag = False 129 if self.fit_duration >= UPDATE_INTERVAL: 130 self.fit_duration = 0 131 u_flag = True 132 133 if not last: 134 msg += "About %s s elapsed......... \n" % str (UPDATE_INTERVAL) 135 msg += "Fit Updates ........... %s \n" % str_time 136 else: 137 msg = "Final updates ........." 138 if u_flag or last: 139 if self.result is not None: 140 data_name, model_name = None, None 141 d_flag = (hasattr(self.result, "data") and \ 142 self.result.data is not None and \ 143 hasattr(self.result.data, "sans_data") and 144 self.result.data.sans_data is not None) 145 m_flag = (hasattr(self.result, "model") and \ 146 self.result.model is not None) 147 if d_flag: 148 data_name = self.result.data.sans_data.name 149 if m_flag: 150 model_name = str(self.result.model.name) 151 if m_flag and d_flag: 152 msg += "Data : %s , Model : %s \n" % (str(data_name), 153 str(model_name)) 154 msg += str(self.result) 155 msg += "\n" 156 else: 157 msg += "No result available\n" 122 158 wx.PostEvent(self.parent, StatusEvent(status=msg, info="info", 123 159 type="progress")) 124 #time.sleep(0.001) 125 160 126 161 def starting_fit(self): 127 162 """ -
fittingview/src/sans/perspectives/fitting/fit_thread.py
rc935fac r2bb37c3 1 1 2 2 import sys 3 import time 3 4 from data_util.calcthread import CalcThread 4 5 … … 39 40 self.batch_outputs = batch_outputs 40 41 self.page_id = page_id 41 self.starttime = 042 self.starttime = time.time() 42 43 self.updatefn = updatefn 43 44 #Relative error desired in the sum of squares. … … 82 83 list_reset_flag) 83 84 result = map(map_apply, inputs) 85 84 86 self.complete(result=result, 85 87 batch_inputs=self.batch_inputs, 86 88 batch_outputs=self.batch_outputs, 87 89 page_id=self.page_id, 88 pars = self.pars) 90 pars = self.pars, 91 elapsed=time.time()-self.starttime) 89 92 90 93 except KeyboardInterrupt, msg: … … 94 97 #Stop on exception during fitting. Todo: need to put 95 98 #some mssg and reset progress bar. 96 raise97 #if self.handler is not None:98 #self.handler.error(msg=msg)99 100 if self.handler is not None: 101 self.handler.error(msg=msg) 99 102 except: 100 raise101 103 if self.handler is not None: 102 104 self.handler.error(msg=str(sys.exc_value)) -
fittingview/src/sans/perspectives/fitting/fitting.py
re80e704 r2bb37c3 1095 1095 1096 1096 self._update_fit_button(page_id) 1097 msg = "Single Fitting complete " 1097 t1 = time.time() 1098 str_time = time.strftime("%a, %d %b %Y %H:%M:%S ", time.localtime(t1)) 1099 msg = "Fit completed on %s \n" % str_time 1100 msg += "Duration time: %s s.\n" % str(elapsed) 1098 1101 wx.PostEvent(self.parent, StatusEvent(status=msg, info="info", 1099 1102 type="stop")) … … 1289 1292 :param elapsed: time spent at the fitting level 1290 1293 """ 1294 t1 = time.time() 1295 str_time = time.strftime("%a, %d %b %Y %H:%M:%S ", time.localtime(t1)) 1296 msg = "Fit completed on %s \n" % str_time 1297 msg += "Duration time: %s s.\n" % str(elapsed) 1298 wx.PostEvent(self.parent, StatusEvent(status=msg, info="info", 1299 type="stop")) 1291 1300 # reset fit_engine if changed by simul_fit 1292 1301 self._on_change_engine(self._gui_engine) 1302 self._update_fit_button(page_id) 1293 1303 result = result[0] 1294 1304 self.fit_thread_list = {} … … 1312 1322 self._update_fit_button(page_id) 1313 1323 else: 1324 1314 1325 cpage = self.fit_panel.get_page_by_id(uid) 1315 1326 # Make sure we got all results … … 1319 1330 index += 1 1320 1331 cpage._on_fit_complete() 1321 if res.fitness == None:1322 msg = "Fit Abort: "1323 else:1324 msg = "Fitting: "1325 msg += "Completed!!!"1326 wx.PostEvent(self.parent, StatusEvent(status=msg))1327 1332 except ValueError: 1328 raise1329 self._update_fit_button(page_id)1330 1333 msg = "Fitting did not converge!!!" 1331 1334 wx.PostEvent(self.parent, StatusEvent(status=msg, info="error", 1332 1335 type="stop")) 1333 1336 except: 1334 raise1335 self._update_fit_button(page_id)1336 1337 msg = "Fit completed but Following" 1337 1338 msg += " error occurred:%s" % sys.exc_value
Note: See TracChangeset
for help on using the changeset viewer.