Changeset 35086c3 in sasview
- Timestamp:
- Jun 3, 2014 4:12:35 PM (10 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:
- 949aa2c
- Parents:
- ddfe1eb7
- Location:
- src/sans
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sans/fit/BumpsFitting.py
r5044543 r35086c3 2 2 BumpsFitting module runs the bumps optimizer. 3 3 """ 4 from datetime import timedelta, datetime 5 4 6 import numpy 5 7 … … 13 15 from .expression import compile_constraints 14 16 17 class Progress(object): 18 def __init__(self, history, max_step, pars, dof): 19 remaining_time = int(history.time[0]*(float(max_step)/history.step[0]-1)) 20 # Depending on the time remaining, either display the expected 21 # time of completion, or the amount of time remaining. Use precision 22 # appropriate for the duration. 23 if remaining_time >= 1800: 24 completion_time = datetime.now() + timedelta(seconds=remaining_time) 25 if remaining_time >= 36000: 26 time = completion_time.strftime('%Y-%m-%d %H:%M') 27 else: 28 time = completion_time.strftime('%H:%M') 29 else: 30 if remaining_time >= 3600: 31 time = '%dh %dm'%(remaining_time//3600, (remaining_time%3600)//60) 32 elif remaining_time >= 60: 33 time = '%dm %ds'%(remaining_time//60, remaining_time%60) 34 else: 35 time = '%ds'%remaining_time 36 chisq = "%.3g"%(2*history.value[0]/dof) 37 step = "%d of %d"%(history.step[0], max_step) 38 header = "=== Steps: %s chisq: %s ETA: %s\n"%(step, chisq, time) 39 parameters = ["%15s: %-10.3g%s"%(k,v,("\n" if i%3==2 else " | ")) 40 for i,(k,v) in enumerate(zip(pars,history.point[0]))] 41 self.msg = "".join([header]+parameters) 42 43 def __str__(self): 44 return self.msg 45 46 15 47 class BumpsMonitor(object): 16 def __init__(self, handler, max_step =0):48 def __init__(self, handler, max_step, pars, dof): 17 49 self.handler = handler 18 50 self.max_step = max_step 51 self.pars = pars 52 self.dof = dof 19 53 20 54 def config_history(self, history): … … 23 57 def __call__(self, history): 24 58 if self.handler is None: return 59 self.handler.set_result(Progress(history, self.max_step, self.pars, self.dof)) 25 60 self.handler.progress(history.step[0], self.max_step) 26 61 if len(history.step)>1 and history.step[1] > history.step[0]: … … 252 287 options = fitopts.options.copy() 253 288 max_step = fitopts.options.get('steps', 0) + fitopts.options.get('burn', 0) 289 pars = [p.name for p in problem._parameters] 254 290 options['monitors'] = [ 255 BumpsMonitor(handler, max_step ),291 BumpsMonitor(handler, max_step, pars, problem.dof), 256 292 ConvergenceMonitor(), 257 293 ] -
src/sans/perspectives/fitting/console.py
r644ca73 r35086c3 128 128 129 129 130 def update_fit(self, msg="",last=False):130 def update_fit(self, last=False): 131 131 """ 132 132 """ … … 135 135 self.update_duration = t1 136 136 self.fit_duration += self.elapsed_time 137 str_time = time.strftime("% a, %d %b %Y%H:%M:%S ", time.localtime(t1))137 str_time = time.strftime("%Y-%m-%d %H:%M:%S ", time.localtime(t1)) 138 138 UPDATE_INTERVAL = 5.0 139 139 u_flag = False … … 141 141 self.fit_duration = 0 142 142 u_flag = True 143 if not last: 144 msg += "Fit Updates ... %s \n" % str_time 145 else: 146 msg += "Final updates ........." 143 msg = str_time 147 144 if u_flag or last: 148 145 if self.result is not None: … … 163 160 msg += str(self.result) 164 161 msg += "\n" 165 if not last:166 msg += "About %s s elapsed......... \n" % \167 str (UPDATE_INTERVAL)168 162 else: 169 163 msg += "No result available\n"
Note: See TracChangeset
for help on using the changeset viewer.