Package asap :: Module asapfitter :: Class fitter
[show private | hide private]
[frames | no frames]

Class fitter


The fitting class for ASAP.
Method Summary
  __init__(self)
Create a fitter object.
  auto_fit(self, insitu, plot)
Return a scan where the function is applied to all rows for all Beams/IFs/Pols.
  commit(self)
Return a new scan where the fits have been commited (subtracted)
  fit(self, row, estimate)
Execute the actual fitting process.
  get_area(self, component)
Return the area under the fitted gaussian component.
  get_chi2(self)
Return chi^2.
  get_errors(self, component)
Return the errors in the parameters.
  get_estimate(self)
Return the parameter estimates (for non-linear functions).
  get_fit(self)
Return the fitted ordinate values.
  get_parameters(self, component, errors)
Return the fit paramters.
  get_residual(self)
Return the residual of the fit.
  plot(self, residual, components, plotparms, filename)
Plot the last fit.
  set_data(self, xdat, ydat, mask)
Set the absissa and ordinate for the fit.
  set_function(self, **kwargs)
Set the function to be fit.
  set_gauss_parameters(self, peak, centre, fwhm, peakfixed, centerfixed, fwhmfixed, component)
Set the Parameters of a 'Gaussian' component, set with set_function.
  set_parameters(self, *args, **kwargs)
Set the parameters to be fitted.
  set_scan(self, thescan, mask)
Set the 'data' (a scantable) of the fitter.
  store_fit(self, filename)
Save the fit parameters.

Method Details

__init__(self)
(Constructor)

Create a fitter object. No state is set.

auto_fit(self, insitu=None, plot=False)

Return a scan where the function is applied to all rows for all Beams/IFs/Pols.

commit(self)

Return a new scan where the fits have been commited (subtracted)

fit(self, row=0, estimate=False)

Execute the actual fitting process. All the state has to be set.
Parameters:
    row:        specify the row in the scantable
    estimate:   auto-compute an initial parameter set (default False)
                This can be used to compute estimates even if fit was
                called before.
Example:
    s = scantable('myscan.asap')
    s.set_cursor(thepol=1)        # select second pol
    f = fitter()
    f.set_scan(s)
    f.set_function(poly=0)
    f.fit(row=0)                  # fit first row

get_area(self, component=None)

Return the area under the fitted gaussian component.
Parameters:
      component:   the gaussian component selection,
                   default (None) is the sum of all components
Note:
      This will only work for gaussian fits.

get_chi2(self)

Return chi^2.

get_errors(self, component=None)

Return the errors in the parameters.
Parameters:
    component:    get the errors for the specified component
                  only, default is all components

get_estimate(self)

Return the parameter estimates (for non-linear functions).

get_fit(self)

Return the fitted ordinate values.

get_parameters(self, component=None, errors=False)

Return the fit paramters.
Parameters:
     component:    get the parameters for the specified component
                   only, default is all components

get_residual(self)

Return the residual of the fit.

plot(self, residual=False, components=None, plotparms=False, filename=None)

Plot the last fit.
Parameters:
    residual:    an optional parameter indicating if the residual
                 should be plotted (default 'False')
    components:  a list of components to plot, e.g [0,1],
                 -1 plots the total fit. Default is to only
                 plot the total fit.
    plotparms:   Inidicates if the parameter values should be present
                 on the plot

set_data(self, xdat, ydat, mask=None)

Set the absissa and ordinate for the fit. Also set the mask
indicationg valid points.
This can be used for data vectors retrieved from a scantable.
For scantable fitting use 'fitter.set_scan(scan, mask)'.
Parameters:
    xdat:    the abcissa values
    ydat:    the ordinate values
    mask:    an optional mask

set_function(self, **kwargs)

Set the function to be fit.
Parameters:
    poly:    use a polynomial of the order given
    gauss:   fit the number of gaussian specified
Example:
    fitter.set_function(gauss=2) # will fit two gaussians
    fitter.set_function(poly=3)  # will fit a 3rd order polynomial

set_gauss_parameters(self, peak, centre, fwhm, peakfixed=0, centerfixed=0, fwhmfixed=0, component=0)

Set the Parameters of a 'Gaussian' component, set with set_function.
Parameters:
    peak, centre, fwhm:  The gaussian parameters
    peakfixed,
    centerfixed,
    fwhmfixed:           Optional parameters to indicate if
                         the paramters should be held fixed during
                         the fitting process. The default is to keep
                         all parameters flexible.
    component:           The number of the component (Default is the
                         component 0)

set_parameters(self, *args, **kwargs)

Set the parameters to be fitted.
Parameters:
      params:    a vector of parameters
      fixed:     a vector of which parameters are to be held fixed
                 (default is none)
      component: in case of multiple gaussians, the index of the
                 component

set_scan(self, thescan=None, mask=None)

Set the 'data' (a scantable) of the fitter.
Parameters:
    thescan:     a scantable
    mask:        a msk retireved from the scantable

store_fit(self, filename=None)

Save the fit parameters.
Parameters:
    filename:    if specified save as an ASCII file, if None (default)
                 store it in the scnatable

Generated by Epydoc 2.1 on Wed May 2 14:24:33 2007 http://epydoc.sf.net