Changeset 975
- Timestamp:
- 04/03/06 16:38:48 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/asapfitter.py
r943 r975 157 157 pars = list(self.fitter.getparameters()) 158 158 fixed = list(self.fitter.getfixedparameters()) 159 self.data._addfit(self._fittedrow, pars, fixed, 160 self.fitfuncs, self.components) 159 from asap.asapfit import asapfit 160 fit = asapfit() 161 fit.setparameters(pars) 162 fit.setfixedparameters(fixed) 163 fit.setfunctions(self.fitfuncs) 164 fit.setcomponents(self.components) 165 fit.setframeinfo(self.data._getcoordinfo()) 166 self.data._addfit(fit,self._fittedrow) 161 167 162 168 def set_parameters(self, params, fixed=None, component=None): … … 232 238 raise ValueError(msg) 233 239 240 def get_area(self, component=None): 241 """ 242 Return the area under the fitted gaussian component. 243 Parameters: 244 component: the gaussian component selection, 245 default (None) is the sum of all components 246 Note: 247 This will only work for gaussian fits. 248 """ 249 if not self.fitted: return 250 if self.fitfunc == "gauss": 251 pars = list(self.fitter.getparameters()) 252 from math import log,pi,sqrt 253 fac = sqrt(pi/log(16.0)) 254 areas = [] 255 for i in range(len(self.components)): 256 j = i*3 257 cpars = pars[j:j+3] 258 areas.append(fac * cpars[0] * cpars[2]) 259 else: 260 return None 261 if component is not None: 262 return areas[component] 263 else: 264 return sum(areas) 265 234 266 def get_parameters(self, component=None): 235 267 """ … … 259 291 cpars = pars 260 292 cfixed = fixed 261 fpars = self._format_pars(cpars, cfixed )293 fpars = self._format_pars(cpars, cfixed, self.get_area(component)) 262 294 if rcParams['verbose']: 263 295 print fpars 264 296 return cpars, cfixed, fpars 265 297 266 def _format_pars(self, pars, fixed ):298 def _format_pars(self, pars, fixed, area): 267 299 out = '' 268 300 if self.fitfunc == 'poly': … … 283 315 ounit = self.data.get_fluxunit() 284 316 while i < len(pars): 285 out += ' % d: peak = %3.3f %s , centre = %3.3f %s, FWHM = %3.3f %s \n' % (c,pars[i],ounit,pars[i+1],aunit,pars[i+2],aunit)317 out += ' %2d: peak = %3.3f %s , centre = %3.3f %s, FWHM = %3.3f %s\n area = %3.3f %s %s\n' % (c,pars[i],ounit,pars[i+1],aunit,pars[i+2],aunit, area,ounit,aunit) 286 318 c+=1 287 319 i+=3 … … 352 384 else: 353 385 raise RuntimeError(msg) 354 if self.data is not scantable: 386 from asap import scantable 387 if not isinstance(self.data, scantable): 355 388 msg = "Not a scantable" 356 389 if rcParams['verbose']:
Note:
See TracChangeset
for help on using the changeset viewer.