saltfit

SALTFIT is a Module to provide general fitting of arrays by SALT talks. The task will provide non-interactiving fitting of 1- and 2-D arrays and allow fitting of general functions to the parameters.

It will provide an easy function to call to fit 1-D arrays of data including fitting with errors in both dimensions, iterative fitting, and fitting an array of functions. The functions to allow fitting include legendry, chebyshev, polynomial, and spline functions.

Author Version Date

    1. Crawford (SAAO) 1.0 10 Oct 2009

TODO

  1. Add 2-D fitting options
  2. SALTBIAS uses poly and this should be updated and renamed

LIMITATIONS

class saltfit.Parameter(value)
set(value)
class saltfit.curfit(x, y, yerr=None, coef=None, function='poly', order=3)

Given an x and y data arrays, find the best fitting curve

  • x - list or array of x data

  • y - list or array of y data

  • yerr - error on y data

  • coef - Initial coefficients for fit

  • function - function to be fit to the data:

    options include polynomial, legendre, chebyshev, or spline

  • order - order of the function that is fit

chisq(x, y, err)

Return the chi^2 of the fit

erf(coef, x, y, v)

Error function to be minimized in least-squares fit

fit(task=0, s=None, t=None, full_output=1, warn=False)

Fit the function to the data

set_coef(coef=None)

Set the coefficients for the fits for poly, legendre, and chebyshev

set_func(function)

Set the function that will be used. * function - name of function to be used

It will throw an error if an inappropriate function is given

set_weight(err)

Set the weighting for spline fitting

sigma(x, y)

Return the RMS of the fit

saltfit.fit(function, parameters, y, x=None, var=1, warn=False)
class saltfit.interfit(x, y, yerr=None, coef=None, function='poly', order=3, thresh=3, niter=5)

Bases: saltfit.curfit

Given an x and y data arrays, find the best fitting curve.
After the initial fit, iterate on the solution to reject any points which are away from the solution
  • x - list or array of x data

  • y - list or array of y data

  • yerr - error on y data

  • coef - Initial coefficients for fit

  • function - function to be fit to the data:

    options include polynomial, legendre, chebyshev, or spline

  • order - order of the function that is fit

  • thresh - threshold for rejection

  • niter - number of times to iterate

interfit()

Fit a function and then iterate it to reject possible outlyiers

set_arrays(x, y, mask, err=None)

set the arrays using a mask

set_mask(init=False)

Set the mask according to the values for rejecting points

saltfit.poly(x, y, order, rej_lo, rej_hi, niter)

linear least square polynomial fit with sigma-clipping

  • x = list of x data
  • y = list of y data
  • order = polynomial order
  • rej_lo = lower rejection threshold (units=sigma)
  • rej_hi = upper rejection threshold (units=sugma)
  • niter = number of sigma-clipping iterations

This is currently used in SALTBIAS and should be made obselete

class saltfit.power(n)

A class to produce a polynomial term of power n.

This has similar behavior to scipy.special.legendre

Table Of Contents

Previous topic

salterror

Next topic

saltgui

This Page