function sersic2dfit

Fit a two-dimensional sersic function to a rectangular grid (i.e. an image).
The 2D sersic function is defined as I(x,y) = c + Ie * exp(-bn * (R/Re)^(1/n) - 1).
R is an elliptical equation: R = sqrt(xp^2 + (yp / q)^2).
xp and yp describe a rotation: xp = (x - x0) * cos(angle) + (y - y0) * sin(angle), yp = - (x - x0) * sin(angle) + (y - y0) * cos(angle) and bn = 1.9992 * n - 0.3271

Syntax
result = sersic2dfit(image, errors, estimate [, chisq])

Arguments
image:   The image to be fit
errors:   The errors in the image values
estimate:   Initial estimate for the fit of the form [c, Ie, Re, x0, y0, angle, q, n]. If n is provided with a negative sign, it won't be fitted and assumed as fixed (with positive sign, of course).
chisq:   If set to a named variable, the variable is overwritten with the chi-squared of the fit.


Returns
The returned vector contains the best-fit parameters in the form [c, Ie, Re, x0, y0, angle, q, n] or [c, Ie, Re, x0, y0, angle, q] if n was kept fixed.

See also
function sersic2dsimplefit