- Timestamp:
- May 21, 2014 5:18:42 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:
- 278e86f
- Parents:
- 233c121
- Location:
- src/sans
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sans/fit/AbstractFitEngine.py
r8d074d9 rbf5e985 396 396 Base class for scipy and park fit engine 397 397 """ 398 #List of parameter names to fit399 self.param_list = []400 398 #Dictionnary of fitArrange element (fit problems) 401 399 self.fit_arrange_dict = {} … … 444 442 self.fit_arrange_dict[id].vals = [sasmodel.getParam(name) for name in pars] 445 443 self.fit_arrange_dict[id].constraints = constraints 446 447 self.param_list.extend(pars)448 444 449 445 def set_data(self, data, id, smearer=None, qmin=None, qmax=None): -
src/sans/fit/BumpsFitting.py
r233c121 rbf5e985 111 111 for k,p in self._pars.items(): 112 112 p.fixed = (k not in param_list or k in self.constraints) 113 self.fitted_pars = [self._pars[k] for k in param_list if k not in self.constraints]114 113 self.fitted_par_names = [k for k in param_list if k not in self.constraints] 114 self.computed_par_names = [k for k in param_list if k in self.constraints] 115 self.fitted_pars = [self._pars[k] for k in self.fitted_par_names] 116 self.computed_pars = [self._pars[k] for k in self.computed_par_names] 115 117 116 118 # ===== Fitness interface ==== … … 163 165 ftol=1.49012e-8, reset_flag=False): 164 166 # Build collection of bumps fitness calculators 165 models = [ 166 167 168 169 for i,M in enumerate(self.fit_arrange_dict.values())170 if M.get_to_fit() == 1]167 models = [SasFitness(model=M.get_model(), 168 data=M.get_data(), 169 constraints=M.constraints, 170 fitted=M.pars) 171 for M in self.fit_arrange_dict.values() 172 if M.get_to_fit()] 171 173 if len(models) == 0: 172 174 raise RuntimeError("Nothing to fit") … … 177 179 exprs = {} 178 180 for M in models: 179 exprs.update((".".join((M.name, k)),v) for k,v in M.constraints.items())181 exprs.update((".".join((M.name, k)), v) for k, v in M.constraints.items()) 180 182 if exprs: 181 symtab = dict((".".join((M.name, k)),p)183 symtab = dict((".".join((M.name, k)), p) 182 184 for M in models 183 185 for k,p in M.parameters().items()) 184 constraints = compile_constraints(symtab, exprs)186 constraints = compile_constraints(symtab, exprs) 185 187 else: 186 188 constraints = lambda: 0 … … 206 208 fitted_index = [varying.index(p) for p in fitness.fitted_pars] 207 209 R = FResult(model=fitness.model, data=fitness.data, 208 param_list=fitness.fitted_par_names )210 param_list=fitness.fitted_par_names+fitness.computed_par_names) 209 211 R.theory = fitness.theory() 210 212 R.residuals = fitness.residuals() 211 213 R.fitter_id = self.fitter_id 212 214 # TODO: should scale stderr by sqrt(chisq/DOF) if dy is unknown 213 R.stderr = result['stderr'][fitted_index] 214 R.pvec = result['value'][fitted_index] 215 R.stderr = numpy.hstack((result['stderr'][fitted_index], 216 numpy.NaN*numpy.ones(len(fitness.computed_pars)))) 217 R.pvec = numpy.hstack((result['value'][fitted_index], 218 [p.value for p in fitness.computed_pars])) 215 219 R.success = result['success'] 216 220 R.fitness = numpy.sum(R.residuals**2)/(fitness.numpoints() - len(fitted_index)) -
src/sans/perspectives/fitting/basepage.py
r5bf0331 rbf5e985 96 96 self.num_points = None 97 97 ## default fitengine type 98 self.engine_type = ' scipy'98 self.engine_type = 'bumps' 99 99 ## smear default 100 100 self.current_smearer = None … … 2986 2986 self.qmin.SetValue(str(self.qmin_x)) 2987 2987 self.qmax.SetValue(str(self.qmax_x)) 2988 self.s et_npts2fit()2988 self.show_npts2fit() 2989 2989 # At this point, some button and variables satatus (disabled?) 2990 2990 # should be checked such as color that should be reset to … … 3874 3874 to fit if implemented 3875 3875 """ 3876 def s et_npts2fit(self):3876 def show_npts2fit(self): 3877 3877 """ 3878 3878 setValue Npts for fitting if implemented -
src/sans/perspectives/fitting/fitpage.py
r233c121 rbf5e985 661 661 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 662 662 663 if self.engine_type in ("park","bumps"): 664 self.text_disp_max.Show(True) 665 self.text_disp_min.Show(True) 663 self.text_disp_max.Show(True) 664 self.text_disp_min.Show(True) 666 665 667 666 for item in self.model.dispersion.keys(): … … 738 737 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 739 738 740 if self.engine_type in ("park","bumps"): 741 ctl3.Show(True) 742 ctl4.Show(True) 739 ctl3.Show(True) 740 ctl4.Show(True) 743 741 744 742 elif p == "npts": … … 1268 1266 if check_float(tcrtl): 1269 1267 flag = self._onparamEnter_helper() 1270 self.s et_npts2fit()1268 self.show_npts2fit() 1271 1269 if self.fitrange: 1272 1270 temp_smearer = None … … 1468 1466 #self.data.mask = index_data 1469 1467 #self.Npts_fit.SetValue(str(len(self.data.mask))) 1470 self.s et_npts2fit()1468 self.show_npts2fit() 1471 1469 else: 1472 1470 index_data = ((self.qmin_x <= self.data.x) & \ … … 1766 1764 # try re draw the model plot if it exists 1767 1765 self._draw_model() 1768 self.s et_npts2fit()1766 self.show_npts2fit() 1769 1767 elif self.model == None: 1770 1768 self.panel.MakeModal(False) 1771 1769 event.Skip() 1772 self.s et_npts2fit()1770 self.show_npts2fit() 1773 1771 msg = "No model is found on updating MASK in the model plot... " 1774 1772 wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) … … 2056 2054 return npts2fit 2057 2055 2058 def s et_npts2fit(self):2056 def show_npts2fit(self): 2059 2057 """ 2060 2058 setValue Npts for fitting … … 2093 2091 if chisqr != None and numpy.isfinite(chisqr): 2094 2092 #format chi2 2095 if self.engine_type in ("park","bumps"):2096 npt_fit = float(self.get_npts2fit())2097 2093 chi2 = format_number(chisqr, True) 2098 2094 self.tcChi.SetValue(chi2) -
src/sans/perspectives/fitting/fitting.py
r233c121 rbf5e985 1084 1084 batch_inputs = {} 1085 1085 batch_outputs = {} 1086 page = self.fit_panel.get_page_by_id(uid) 1086 if fit_type == "simultaneous": 1087 page = self.sim_page 1088 elif fit_type == "combined_batch": 1089 page = self.batch_page 1090 else: 1091 page = self.fit_panel.get_page_by_id(uid) 1087 1092 if page.batch_on: 1088 1093 calc_fit = FitThread(handler=handler, -
src/sans/perspectives/fitting/simfitpage.py
r233c121 rbf5e985 139 139 break 140 140 141 ## some model or parameters can be constrained142 self._show_constraint()143 self.sizer3.Layout()144 self.Layout()145 self.Refresh()146 141 #self._onAdd_constraint(None) 147 142 … … 820 815 821 816 for fid in self.page_finder[id].iterkeys(): 822 self.page_finder[id].set_model_param(param, 823 constraint, fid=fid) 817 # wrap in param/constraint in str() to remove unicode 818 self.page_finder[id].set_model_param(str(param), 819 str(constraint), fid=fid) 824 820 break 825 821 return True
Note: See TracChangeset
for help on using the changeset viewer.