Changeset 1391 for trunk/python/asapfitter.py
- Timestamp:
- 07/30/07 11:59:36 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/asapfitter.py
r1306 r1391 25 25 self._p = None 26 26 self._selection = None 27 self.uselinear = False 27 28 28 29 def set_data(self, xdat, ydat, mask=None): … … 74 75 Set the function to be fit. 75 76 Parameters: 76 poly: use a polynomial of the order given 77 poly: use a polynomial of the order given with nonlinear least squares fit 78 lpoly: use polynomial of the order given with linear least squares fit 77 79 gauss: fit the number of gaussian specified 78 80 Example: 79 81 fitter.set_function(gauss=2) # will fit two gaussians 80 fitter.set_function(poly=3) # will fit a 3rd order polynomial 82 fitter.set_function(poly=3) # will fit a 3rd order polynomial via nonlinear method 83 fitter.set_function(lpoly=3) # will fit a 3rd order polynomial via linear method 81 84 """ 82 85 #default poly order 0 … … 86 89 n = kwargs.get('poly') 87 90 self.components = [n] 91 self.uselinear = False 92 elif kwargs.has_key('lpoly'): 93 self.fitfunc = 'poly' 94 n = kwargs.get('lpoly') 95 self.components = [n] 96 self.uselinear = True 88 97 elif kwargs.has_key('gauss'): 89 98 n = kwargs.get('gauss') … … 91 100 self.fitfuncs = [ 'gauss' for i in range(n) ] 92 101 self.components = [ 3 for i in range(n) ] 102 self.uselinear = False 93 103 else: 94 104 msg = "Invalid function type." … … 146 156 if len(fxdpar) and fxdpar.count(0) == 0: 147 157 raise RuntimeError,"No point fitting, if all parameters are fixed." 148 converged = self.fitter.fit() 158 if self.uselinear: 159 converged = self.fitter.lfit() 160 else: 161 converged = self.fitter.fit() 149 162 if not converged: 150 163 raise RuntimeError,"Fit didn't converge." … … 501 514 array(self.data._getmask(self._fittedrow), 502 515 copy=False)) 503 516 504 517 ylab = self.data._get_ordinate_label() 505 518
Note: See TracChangeset
for help on using the changeset viewer.