- Timestamp:
- Apr 11, 2014 5:26:08 PM (11 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:
- 499639c
- Parents:
- 042f065
- Location:
- src/sans
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sans/fit/BumpsFitting.py
r042f065 r85f17f6 11 11 from sans.fit.AbstractFitEngine import FitEngine 12 12 from sans.fit.AbstractFitEngine import FResult 13 14 class BumpsMonitor(object): 15 def __init__(self, handler, max_step=0): 16 self.handler = handler 17 self.max_step = max_step 18 def config_history(self, history): 19 history.requires(time=1, value=2, point=1, step=1) 20 def __call__(self, history): 21 self.handler.progress(history.step[0], self.max_step) 22 if len(history.step)>1 and history.step[1] > history.step[0]: 23 self.handler.improvement() 24 self.handler.update_fit() 13 25 14 26 class SasProblem(object): … … 240 252 241 253 if True: # bumps 242 def abort_test():243 try: curr_thread.isquit()244 except KeyboardInterrupt:245 if handler is not None:246 handler.stop("Fitting: Terminated!!!")247 return True248 return False249 250 254 problem = SasProblem(param_list=self.param_list, 251 255 model=model.model, 252 256 data=data) 253 run_bumps(problem, result, ftol, abort_test) 257 run_bumps(problem, result, ftol, 258 handler, curr_thread, msg_q) 254 259 else: 255 260 problem = SasProblem(param_list=self.param_list, … … 263 268 264 269 if handler is not None: 265 handler.set_result(result=result)266 270 handler.update_fit(last=True) 267 271 if q is not None: … … 272 276 return [result] 273 277 274 def run_bumps(problem, result, ftol, abort_test): 278 def run_bumps(problem, result, ftol, handler, curr_thread, msg_q): 279 def abort_test(): 280 if curr_thread is None: return False 281 try: curr_thread.isquit() 282 except KeyboardInterrupt: 283 if handler is not None: 284 handler.stop("Fitting: Terminated!!!") 285 return True 286 return False 287 275 288 fitopts = fitters.FIT_OPTIONS[fitters.FIT_DEFAULT] 276 289 fitclass = fitopts.fitclass 277 290 options = fitopts.options.copy() 291 max_steps = fitopts.options.get('steps', 0) + fitopts.options.get('burn', 0) 292 if 'monitors' not in options: 293 options['monitors'] = [BumpsMonitor(handler, max_steps)] 278 294 options['ftol'] = ftol 279 295 fitdriver = fitters.FitDriver(fitclass, problem=problem, … … 297 313 result.theory = problem.theory 298 314 299 def run_levenburg_marquardt( model, result, ftol):315 def run_levenburg_marquardt(problem, result, ftol): 300 316 # This import must be here; otherwise it will be confused when more 301 317 # than one thread exist. 302 318 from scipy import optimize 303 319 304 out, cov_x, _, mesg, success = optimize.leastsq( model.residuals,305 model.getp(),320 out, cov_x, _, mesg, success = optimize.leastsq(problem.residuals, 321 problem.getp(), 306 322 ftol=ftol, 307 323 full_output=1) … … 310 326 else: 311 327 stderr = [] 312 result.fitness = model.chisq()328 result.fitness = problem.chisq() 313 329 result.stderr = stderr 314 330 result.pvec = out 315 331 result.success = success 316 result.theory = model.theory317 332 result.theory = problem.theory 333 -
src/sans/perspectives/fitting/console.py
r6fe5100 r85f17f6 87 87 Print result object 88 88 """ 89 msg = " \n %s \n" % s elf.result.__str__()89 msg = " \n %s \n" % str(self.result) 90 90 wx.PostEvent(self.parent, StatusEvent(status=msg)) 91 91 … … 136 136 self.fit_duration += self.elapsed_time 137 137 str_time = time.strftime("%a, %d %b %Y %H:%M:%S ", time.localtime(t1)) 138 UPDATE_INTERVAL = 0.5138 UPDATE_INTERVAL = 5.0 139 139 u_flag = False 140 140 if self.fit_duration >= UPDATE_INTERVAL: … … 171 171 type="progress")) 172 172 173 def starting_fit(self):173 def _DEAD_starting_fit(self): 174 174 """ 175 175 """
Note: See TracChangeset
for help on using the changeset viewer.