Package pytools :: Module gfit
[hide private]
[frames] | no frames]

Module gfit

source code

Return the gaussian fit of a 1D array.

Uses mpfit.py - a python implementation of the Levenberg-Marquardt least-squares minimization, based on MINPACK-1. See nmpfit.py for the history of this module (fortran -> idl -> python). nmpfit.py is a version of mpfit.py which uses numarray.


Author: Nadia Dencheva

Version: '1.0 (2007-02-20)'

Functions [hide private]
 
_gauss_funct(p, fjac=None, x=None, y=None, err=None, weights=None)
Defines the gaussian function to be used as the model.
source code
 
test_gaussfit() source code
 
gfit1d(y, x=None, err=None, weights=None, par=None, parinfo=None, maxiter=200, quiet=0)
Return the gaussian fit as an object.
source code
 
plot_fit(y, mfit, x=None) source code
 
test() source code
Variables [hide private]
  __version__ = '1.0'
  __vdate__ = '2007-02-20'

Imports: numerixenv, nmpfit, N, random


Function Details [hide private]

gfit1d(y, x=None, err=None, weights=None, par=None, parinfo=None, maxiter=200, quiet=0)

source code 

Return the gaussian fit as an object.

@type  y:   1D Numarray array
@param y:   The data to be fitted
@type  x:   1D Numarray array
@param x:   (optional) The x values of the y array. x and y must
                        have the same shape.
@type  err: 1D Numarray array
@param err: (optional) 1D array with measurement errors, must be
                        the same shape as y
@type weights: 1D Numarray array
@param weights: (optiional) 1D array with weights, must be the same
                                shape as y
@type par:  List
@param par: (optional) Starting values for the parameters to be fitted
@type parinfo: Dictionary of lists
@param parinfo: (optional) provides additional information for the
                                parameters. For a detailed description see nmpfit.py.
                                Parinfo can be used to limit parameters or keep
                                some of them fixed.
@type maxiter: number
@param maxiter: Maximum number of iterations to perform
                                Default: 200
@type quiet: number
@param quiet: if set to 1, nmpfit does not print to the screen
                                Default: 0

>>> x=N.arange(10,20, 0.1)
>>> y= 10*N.e**(-(x-15)**2/4)
>>> print gfit1d(y,x=x, maxiter=20,quiet=1).params
[ 10.          15.           1.41421356]