- Timestamp:
- May 6, 2014 11:34:46 AM (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:
- f121904
- Parents:
- 644ca73
- Location:
- src/sans
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sans/fit/BumpsFitting.py
r85f17f6 red4aef2 16 16 self.handler = handler 17 17 self.max_step = max_step 18 18 19 def config_history(self, history): 19 20 history.requires(time=1, value=2, point=1, step=1) 21 20 22 def __call__(self, history): 21 23 self.handler.progress(history.step[0], self.max_step) … … 23 25 self.handler.improvement() 24 26 self.handler.update_fit() 27 28 class ConvergenceMonitor(object): 29 """ 30 ConvergenceMonitor contains population summary statistics to show progress 31 of the fit. This is a list [ (best, 0%, 25%, 50%, 75%, 100%) ] or 32 just a list [ (best, ) ] if population size is 1. 33 """ 34 def __init__(self): 35 self.convergence = [] 36 37 def config_history(self, history): 38 history.requires(value=1, population_values=1) 39 40 def __call__(self, history): 41 best = history.value[0] 42 try: 43 p = history.population_values[0] 44 n,p = len(p), numpy.sort(p) 45 QI,Qmid, = int(0.2*n),int(0.5*n) 46 self.convergence.append((best, p[0],p[QI],p[Qmid],p[-1-QI],p[-1])) 47 except: 48 self.convergence.append((best, )) 25 49 26 50 class SasProblem(object): … … 257 281 run_bumps(problem, result, ftol, 258 282 handler, curr_thread, msg_q) 259 else: 283 else: # scipy levenburg marquardt 260 284 problem = SasProblem(param_list=self.param_list, 261 285 model=model.model, … … 292 316 if 'monitors' not in options: 293 317 options['monitors'] = [BumpsMonitor(handler, max_steps)] 318 options['monitors'] += [ ConvergenceMonitor() ] 294 319 options['ftol'] = ftol 295 320 fitdriver = fitters.FitDriver(fitclass, problem=problem, … … 312 337 result.success = True 313 338 result.theory = problem.theory 339 # For the convergence plot 340 pop = numpy.asarray(options['monitors'][-1].convergence) 341 result.convergence = 2*pop/problem.dof 342 # Bumps uncertainty state 343 try: result.uncertainty_state = fitdriver.fitter.state 344 except AttributeError: pass 314 345 315 346 def run_levenburg_marquardt(problem, result, ftol): -
src/sans/perspectives/fitting/fitting.py
r644ca73 red4aef2 36 36 from .fitproblem import FitProblemDictionary 37 37 from .fitpanel import FitPanel 38 from .resultpanel import ResultPanel, PlotResultEvent 39 38 40 from .fit_thread import FitThread 39 41 from .pagestate import Reader … … 221 223 self.bumps_options_menu = self.menu1.FindItemById(self.id_bumps_options) 222 224 self.bumps_options_menu.Enable(True) 225 226 self.id_result_panel = wx.NewId() 227 self.menu1.AppendItem(self.id_result_panel, "Fit Results", 228 "Show fit results panel") 229 wx.EVT_MENU(owner, self.id_result_panel, 230 lambda ev: self.result_frame.Show(not self.result_frame.IsShown())) 223 231 self.menu1.AppendSeparator() 224 232 … … 525 533 self.perspective = [] 526 534 self.perspective.append(self.fit_panel.window_name) 535 536 self.result_frame = MDIFrame(self.parent, None, ResultPanel.window_caption, (220, 200)) 537 self.result_panel = ResultPanel(parent=self.result_frame, manager=self) 538 self.perspective.append(self.result_panel.window_name) 527 539 528 540 #index number to create random model name … … 539 551 #Send the fitting panel to guiframe 540 552 self.mypanels.append(self.fit_panel) 553 self.mypanels.append(self.result_panel) 541 554 return self.mypanels 542 555 … … 1589 1602 wx.PostEvent(self.parent, StatusEvent(status=msg, info="info", 1590 1603 type="stop")) 1604 wx.PostEvent(self.result_panel, PlotResultEvent(result=result)) 1591 1605 # reset fit_engine if changed by simul_fit 1592 1606 if self._fit_engine != self._gui_engine:
Note: See TracChangeset
for help on using the changeset viewer.