Ignore:
Timestamp:
07/30/07 11:59:36 (17 years ago)
Author:
Malte Marquarding
Message:

merge from alma branch to get alma/GBT support. Commented out fluxUnit changes as they are using a chnaged interface to PKSreader/writer. Also commented out progress meter related code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/asapfitter.py

    r1306 r1391  
    2525        self._p = None
    2626        self._selection = None
     27        self.uselinear = False
    2728
    2829    def set_data(self, xdat, ydat, mask=None):
     
    7475        Set the function to be fit.
    7576        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
    7779            gauss:   fit the number of gaussian specified
    7880        Example:
    7981            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
    8184        """
    8285        #default poly order 0
     
    8689            n = kwargs.get('poly')
    8790            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
    8897        elif kwargs.has_key('gauss'):
    8998            n = kwargs.get('gauss')
     
    91100            self.fitfuncs = [ 'gauss' for i in range(n) ]
    92101            self.components = [ 3 for i in range(n) ]
     102            self.uselinear = False
    93103        else:
    94104            msg = "Invalid function type."
     
    146156            if len(fxdpar) and fxdpar.count(0) == 0:
    147157                 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()
    149162            if not converged:
    150163                raise RuntimeError,"Fit didn't converge."
     
    501514                             array(self.data._getmask(self._fittedrow),
    502515                                   copy=False))
    503            
     516                             
    504517            ylab = self.data._get_ordinate_label()
    505518
Note: See TracChangeset for help on using the changeset viewer.