gaussfit

gaussfitter.gaussfit(data, err=None, params=(), autoderiv=True, return_error=False, circle=False, fixed=array([False, False, False, False, False, False, False], dtype=bool), limitedmin=[False, False, False, False, True, True, True], limitedmax=[False, False, False, False, False, False, True], usemoment=array([], dtype=bool), minpars=array([0, 0, 0, 0, 0, 0, 0]), maxpars=[0, 0, 0, 0, 0, 0, 180], rotate=True, vheight=True, quiet=True, returnmp=False, returnfitimage=False, **kwargs)[source] [edit on github]

Gaussian fitter with the ability to fit a variety of different forms of 2-dimensional gaussian.

Parameters:

data : numpy.ndarray

2-dimensional data array

err : numpy.ndarray or None

error array with same size as data array. Defaults to 1 everywhere.

params : (height, amplitude, x, y, width_x, width_y, rota)

Initial input parameters for Gaussian function. If not input, these will be determined from the moments of the system, assuming no rotation

autoderiv : bool

Use the autoderiv provided in the lmder.f function (the alternative is to us an analytic derivative with lmdif.f: this method is less robust)

return_error : bool

Default is to return only the Gaussian parameters. If True, return fit params & fit error

returnfitimage : bool

returns (best fit params,best fit image)

returnmp : bool

returns the full mpfit struct

circle : bool

The default is to fit an elliptical gaussian (different x, y widths), but the input is reduced by one parameter if it’s a circular gaussian.

rotate : bool

Allow rotation of the gaussian ellipse. Can remove last parameter of input & fit by setting rotate=False. Angle should be specified in degrees.

vheight : bool

Allows a variable height-above-zero, i.e. an additive constant background for the Gaussian function. Can remove the first fitter parameter by setting this to False

usemoment : numpy.ndarray, dtype=’bool’

Array to choose which parameters to use a moment estimation for. Other parameters will be taken from params.

Returns:

(params, [parerr], [fitimage]) | (mpfit, [fitimage])

parameters : list

The default output is a set of Gaussian parameters with the same shape as the input parameters

fitimage : numpy.ndarray

If returnfitimage==True, the last return will be a 2D array holding the best-fit model

mpfit : mpfit object

If returnmp==True returns a mpfit object. This object contains a covar attribute which is the 7x7 covariance array generated by the mpfit class in the mpfit_custom.py module. It contains a param attribute that contains a list of the best fit parameters in the same order as the optional input parameter params.