;*********************************************************************** ; ;*PROCDURE NAME: ; ; GAUSS (General IDL Library 01) Aug 19, 1979 ; ;*PURPOSE: ; ; TO CALCULATE A GAUSSIAN FUNCTION ; ;*CALLING SEQUENCE: ; ; GAUSS,X,X0,DX,YMAX,Y ; ;*PARAMETERS: ; ; X (REQ) (I) (0 1) (I L F D) ; required scalar or vector containing the independent variable(s) ; ; X0 (REQ) (I) (0) (F D) ; required scalar giving the center of the Gaussian function ; This parameter must have the same units as X. ; ; DX (REQ) (I) (0) (F D) ; required scalar giving the one sigma width of the distribution ; This parameter must have the same units as X. ; ; YMAX (REQ) (I) (0) (F D) ; the Gaussian value at the peak of the distribution ; ; Y (REQ) (O) (0 1) (F D) ; required output scalar or vector giving the calculated value ; of the gaussian from the expression: ; Y = YMAX * EXP (-0.5 * ((X-X0)/DX)^2) ; ;*********************************************************************** pro gauss,x,x0,dx,ymax,y ; npar = n_params(0) if npar eq 0 then begin print,' GAUSS,X,X0,DX,YMAX,Y' retall endif ; npar parcheck,npar,5,'GAUSS' pcheck,x,1,110,0011 pcheck,x0,2,100,0011 pcheck,dx,3,100,0011 pcheck,ymax,4,100,0011 if dx ne 0 then begin arg=(abs((x-x0)/dx)<9.) ; set values 9 sigma to 0 to avoid trap errors y=exp(-arg*arg/2)*(arg lt 9.0) endif else y=(0.*x)*(x ne x0)+(x eq x0) ; if dx eq 0 return delta function y=y*ymax return end ; gauss