function sersic2dsimplefit

Fit a two-dimensional sersic function to a rectangular grid (i.e. an image) without any given estimates.
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 = sersic2dsimplefit(image, x_cen, y_cen, width [, chisq [, n]])

Arguments
 image: The image to be fit x_cen: The x-position of the fit center y_cen: The x-position of the fit center width: The half-width of the fitting window chisq: If set to a named variable, the variable is overwritten with the chi-squared of the fit. n: If n should be fixed and not fitted.

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. Angle is in degrees. When the negative reciprocal value in q is returned, then the angle is also increased by 90 degrees.