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.ndarray2-dimensional data array
err :
numpy.ndarrayor Noneerror 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 errorreturnfitimage : 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
Falseusemoment :
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.ndarrayIf returnfitimage==True, the last return will be a 2D array holding the best-fit model
mpfit :
mpfitobjectIf
returnmp==Truereturns ampfitobject. This object contains acovarattribute which is the 7x7 covariance array generated by the mpfit class in thempfit_custom.pymodule. It contains aparamattribute that contains a list of the best fit parameters in the same order as the optional input parameterparams.