FUNCTION fwhm_g1dfit, xdata, ydata, sky, param ; Description: This function is designed for use by the function "fwhm_g2dfit.pro" and it fits a ; one-dimensional Gaussian function to input data. The model that is fitted is: ; ; G(x) = A + B*exp(-0.5*(x/C)) ; ; The parameter A corresponds to the sky background (ADU). ; The parameter B corresponds to the Gaussian peak value (ADU). ; The parameter C is the sigma of the Gaussian (pix). ; The function returns a value of "1" if the fit was successful and a value of "0" ; otherwise. The parameter "param" is used to record the fitted parameters A, B and C ; as a three-element vector. ; This function assumes that all values of the independent variable "xdata" are ; positive and represent the distance of each data point from the centre of the ; Gaussian function at x = 0. It is assumed that the parameter B is positive, since ; this function is modelling a positive brightness profile when called from ; "fwhm_g2dfit.pro". If the fitted value of B is negative, then the function reports ; that the fit has failed. ; ; Input Parameters: ; ; xdata - FLOAT/DOUBLE VECTOR - A one-dimensional vector containing the set of data values for ; the independent variable. ; ydata - FLOAT/DOUBLE VECTOR - A one-dimensional vector containing the set of data values for ; the dependent variable. ; sky - FLOAT/DOUBLE - An initial and reliable estimate of the parameter A. ; ; Output Parameters: ; ; param - DOUBLE VECTOR - This parameter is returned as a three-element vector of DOUBLES with ; the fitted values of A, B and C in order. ; ; Return value: ; ; The function returns a status value as an INTEGER. If the status value is "0", then the fit ; has failed. If the status value is "1", then the fit was successful. ; ; Author: Dan Bramich (dan.bramich@hotmail.co.uk) ; ; History: ; ; 06/05/2008 - Module created (dmb) ;Check that "xdata" and "ydata" are vectors of the correct number type ;Check that "xdata" and "ydata" have the same number of elements, and that they have at least ;three elements ;Check that "sky" is a number of the correct type ;Compute an initial estimate of the sigma of the gaussian to be fitted ;Fit a one-dimensional Gaussian to the input data ;If the fit was unsuccessful, then return the status of the fit ;Force the sigma of the fitted gaussian to be positive ;If the height of the fitted Gaussian is positive and the sigma of the fitted Gaussian is non-zero, ;then record that the fit was successful ;Return the status of the fit