function gauss2d, x, y, a ;;; How big are the abscissa arrays? xnpix = n_elements(x) ynpix = n_elements(y) ;;; Fan things out xarr = rebin(x, xnpix, ynpix) yarr = rebin(reform(y,1,ynpix), ynpix, xnpix) ;;; Rotate? if n_elements(a) eq 7 then T = a[6] else T = 0. ;;; Advanced mathematical techniques xp = (xarr-a[4]) * cos(T) - (yarr-a[5]) * sin(T) yp = (xarr-a[4]) * sin(T) + (yarr-a[5]) * cos(T) u = (xp / a[2])^2 + (yp / a[3])^2 g = a[0] + a[1] * exp(-U/2.) return, g end