FUNCTION HSI_GAUSSFIT, angfreq, ampl, YFIT=yfit ; ; Fits a gaussian to the set of amplitudes measured at specified angular frequencies. ; ; angfreq = vector of 2 or more elements in arcsec^-1 (=1./(2*FWHM)) ; ampl = vector of the same length ; output = vector with flag (=0 if output ok), FWHM of source, peak value ; ; 15-Apr-05 Initial version uses IDL routine GAUSSFIT (ghurford@ssl.berkeley.edu) ; output = FLTARR(3) npt = N_ELEMENTS(angfreq) IF npt LT 2 OR N_ELEMENTS(ampl) NE npt THEN BEGIN ; invalid input PRINT, 'HSI_GAUSSFIT: Illegal input vectors', npt, N_ELEMENTS(ampl) output[0] = 1 RETURN, output ENDIF ; ; Duplicate input data onto -ve spatial frequencies to force GAUSSFIT to return A1=0 y = [ampl,ampl] x = [angfreq,-angfreq] yfit = GAUSSFIT(x,y, coeff, NTERMS=3) IF coeff[0] LE 0 OR coeff[1] GE MIN (angfreq*0.01) THEN BEGIN PRINT, 'HSI_GAUSSFIT: Invalid output', coeff output[0] = 2 RETURN, output ENDIF output[1] = SQRT(2*ALOG(2)) / !PI / ABS(coeff[2]) ; FWHM diameter output[2] = coeff[0] ; peak RETURN, output END