Changeset 7db52f1 in sasview
- Timestamp:
- Oct 12, 2011 1:40:24 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:
- 7643ba2
- Parents:
- 18253cd
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
fittingview/src/sans/perspectives/fitting/fit_thread.py
r6a4002d r7db52f1 27 27 yieldtime = 0.01, 28 28 worktime = 0.01, 29 ftol = None): 29 ftol = None, 30 reset_flag = False): 30 31 CalcThread.__init__(self,completefn, 31 32 updatefn, … … 42 43 #Relative error desired in the sum of squares. 43 44 self.ftol = ftol 45 self.reset_flag = reset_flag 44 46 45 47 def isquit(self): … … 63 65 list_curr_thread = [] 64 66 list_ftol = [] 67 list_reset_flag = [] 65 68 list_map_get_attr = [] 66 69 list_fit_function = [] … … 71 74 list_curr_thread.append(None) 72 75 list_ftol.append(self.ftol) 76 list_reset_flag.append(self.reset_flag) 73 77 list_fit_function.append('fit') 74 78 list_map_get_attr.append(map_getattr) 75 79 #from multiprocessing import Pool 76 80 inputs = zip(list_map_get_attr,self.fitter, list_fit_function, 77 list_handler, list_q, list_curr_thread,list_ftol) 81 list_handler, list_q, list_curr_thread,list_ftol, 82 list_reset_flag) 78 83 result = map(map_apply, inputs) 79 84 self.complete(result=result, -
fittingview/src/sans/perspectives/fitting/fitproblem.py
ra3c8e8f r7db52f1 595 595 self.fit_data = None 596 596 # original data: should not be modified 597 self.original_data = copy.deepcopy(data)597 self.original_data = data 598 598 # fit data: used for fit and can be modified for convenience 599 599 self.fit_data = copy.deepcopy(data) … … 609 609 return self.fit_data 610 610 611 def get_origin_data(self): 612 """ 613 """ 614 return self.original_data 615 611 616 def set_weight(self, is2d, flag=None): 612 617 """ -
fittingview/src/sans/perspectives/fitting/fitting.py
r47d9be79 r7db52f1 86 86 ## Fit engine 87 87 self._fit_engine = 'scipy' 88 self._gui_engine = None 88 89 ## Relative error desired in the sum of squares (float); scipy only 89 90 self.ftol = SANS_F_TOL 91 self.batch_reset_flag = True 90 92 #List of selected data 91 93 self.selected_data_list = [] … … 705 707 if value.get_scheduled() == 1: 706 708 fitproblem_count += 1 707 709 self._gui_engine = self._return_engine_type() 708 710 self.fitproblem_count = fitproblem_count 709 711 if self._fit_engine == "park": … … 721 723 fitter_list.append(sim_fitter) 722 724 is_single_fit = False 725 723 726 724 727 self.fitproblem_count = fitproblem_count … … 818 821 page_id=list_page_id, 819 822 completefn=self._batch_fit_complete, 820 ftol=self.ftol) 823 ftol=self.ftol, 824 reset_flag=self.batch_reset_flag) 821 825 else: 822 826 # single fit: not batch and not simul fit … … 1096 1100 msg += "Data %s and Model %s did not fit.\n" % (data_name, 1097 1101 model_name) 1098 #print msg1102 print msg 1099 1103 wx.PostEvent(self.parent, StatusEvent(status=msg, 1100 1104 error="error", … … 1156 1160 flag = issubclass(data.__class__, Data2D) 1157 1161 if not flag: 1158 #print "Batch complete", len(res.theory), len(res.index)1159 1162 self._complete1D(x=data.x, y=res.theory, page_id=pid, 1160 1163 elapsed=None, … … 1163 1166 toggle_mode_on=False, state=None, 1164 1167 data=data, update_chisqr=False, 1165 source=' model')1168 source='fit') 1166 1169 else: 1167 1170 self._complete2D(image=data.data, data=data, … … 1173 1176 toggle_mode_on=False, state=None, 1174 1177 update_chisqr=False, 1175 source=' model')1178 source='fit') 1176 1179 1177 1180 self.on_set_batch_result(page_id=pid, … … 1204 1207 cell.label = data.name 1205 1208 cell.value = index 1206 theory_data.id = wx.NewId()1207 theory_data.name = data.name + "[%s]" % str(model.__class__.__name__)1209 theory_data.id = str(page_id) + "model" 1210 theory_data.name = model.name + "[%s]" % str(model.__class__.__name__) 1208 1211 cell.object = [data, theory_data] 1209 1212 batch_outputs["Data"].append(cell) … … 1233 1236 :param elapsed: time spent at the fitting level 1234 1237 """ 1238 # reset fit_engine if changed by simul_fit 1239 self._on_change_engine(self._gui_engine) 1235 1240 result = result[0] 1236 1241 self.fit_thread_list = {} … … 1450 1455 caption = current_pg.window_caption 1451 1456 self.page_finder[page_id].set_fit_tab_caption(caption=caption) 1452 1457 new_plot.id = str(page_id) + "model" 1453 1458 self.page_finder[page_id].set_theory_data(data=new_plot, 1454 1459 fid=data.id) -
fittingview/src/sans/perspectives/fitting/simfitpage.py
r1153d0e r7db52f1 622 622 self.btFit.SetToolTipString("Perform fit.") 623 623 624 text= "Hint: Park fitting engine will be selected automatically. \n"624 text= "Hint: Park fitting engine will be used automatically. \n" 625 625 #text+= "automatically for more than 2 combinations checked" 626 626 text_hint = wx.StaticText(self,-1,text) -
park_integration/src/sans/fit/AbstractFitEngine.py
rd8661fb r7db52f1 459 459 #import thread 460 460 self.model.set_params(self.paramlist, params) 461 461 print "params", params 462 462 self.true_res, theory = self.data.residuals(self.model.eval) 463 463 self.theory = copy.deepcopy(theory) … … 548 548 #Dictionnary of fitArrange element (fit problems) 549 549 self.fit_arrange_dict = {} 550 550 551 551 def set_model(self, model, id, pars=[], constraints=[], data=None): 552 552 """ … … 611 611 fitproblem.pars = pars 612 612 self.fit_arrange_dict[id] = fitproblem 613 613 vals = [] 614 for name in pars: 615 vals.append(new_model.model.getParam(name)) 616 self.fit_arrange_dict[id].vals = vals 614 617 else: 615 618 raise ValueError, "park_integration:missing parameters" … … 698 701 self.data_list = [] 699 702 self.pars = [] 703 self.vals = [] 700 704 #self.selected is zero when this fit problem is not schedule to fit 701 705 #self.selected is 1 when schedule to fit -
park_integration/src/sans/fit/Fitting.py
r634ca14 r7db52f1 50 50 raise ValueError, "enter the keyword scipy or park" 51 51 52 def fit(self, q=None, handler=None, curr_thread=None, ftol=1.49012e-8): 52 def fit(self, q=None, handler=None, 53 curr_thread=None, 54 ftol=1.49012e-8, 55 reset_flag=False): 53 56 """Perform the fit """ 54 57 return self._engine.fit(q, handler, curr_thread=curr_thread, 55 ftol=ftol )58 ftol=ftol, reset_flag=reset_flag) 56 59 57 60 def set_model(self, model, id, pars=[], constraints=[], data=None): -
park_integration/src/sans/fit/ParkFitting.py
r444c900e r7db52f1 338 338 self.param_list = [] 339 339 340 def create_assembly(self, curr_thread ):340 def create_assembly(self, curr_thread, reset_flag=False): 341 341 """ 342 342 Extract sansmodel and sansdata from … … 358 358 for item in fitproblems: 359 359 parkmodel = item.get_model() 360 if reset_flag: 361 # reset the initial value; useful for batch 362 for name in item.pars: 363 ind = item.pars.index(name) 364 parkmodel.model.setParam(name, item.vals[ind]) 365 360 366 for p in parkmodel.parameterset: 361 367 ## does not allow status change for constraint parameters … … 374 380 375 381 376 def fit(self, q=None, handler=None, curr_thread=None, ftol=1.49012e-8): 382 def fit(self, q=None, handler=None, curr_thread=None, 383 ftol=1.49012e-8, reset_flag=False): 377 384 """ 378 385 Performs fit with park.fit module.It can perform fit with one model … … 395 402 396 403 """ 397 self.create_assembly(curr_thread=curr_thread )404 self.create_assembly(curr_thread=curr_thread, reset_flag=reset_flag) 398 405 localfit = SansFitSimplex() 399 406 localfit.ftol = ftol -
park_integration/src/sans/fit/ScipyFitting.py
rd8661fb r7db52f1 56 56 # return profile(self._fit, *args, **kw) 57 57 58 def fit(self, q=None, handler=None, curr_thread=None, ftol=1.49012e-8): 58 def fit(self, q=None, handler=None, curr_thread=None, 59 ftol=1.49012e-8, reset_flag=False): 59 60 """ 60 61 """ … … 70 71 raise RuntimeError, "No Assembly scheduled for Scipy fitting." 71 72 return 72 73 model = fitproblem[0].get_model() 74 if reset_flag: 75 # reset the initial value; useful for batch 76 for name in fitproblem[0].pars: 77 ind = fitproblem[0].pars.index(name) 78 model.model.setParam(name, fitproblem[0].vals[ind]) 73 79 listdata = [] 74 model = fitproblem[0].get_model()75 80 listdata = fitproblem[0].get_data() 76 81 # Concatenate dList set (contains one or more data)before fitting
Note: See TracChangeset
for help on using the changeset viewer.