# function sersic2dsmoothfit

Fit a two-dimensional smoothed 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
The resulting 2D sersic function is then smoothed by convolving with a gaussian with a FWHM given by the smooth parameter.

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

Arguments
 image: The image to be fit errors: The errors in the image values smooth: The FWHM for the gaussian smoothing 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.