;+ ; NAME: ; RESAMPLE ; ; PURPOSE: ; Resample a spectrum (or other 1-D data) to new abcissa values. ; ; EXPLANATION: ; Analogous to INTERPOL, but resamples using a Gaussian influence ; function at each new abcissa value, with a full-width equal to ; the data point spacing. Useful primarily for "downsampling" spectral ; data. ; ; CALLING SEQUENCE: ; Result = RESAMPLE(y0, x0, x1) ; ; INPUTS: ; y0 = Ordinate values of input spectrum. ; ; x0 = Abcissa values of input spectrum. ; ; x1 = Abcissa value of output spectrum. ; ; OPTIONAL OUTPUT KEYWORDS: ; wt = Influence function matrix (N0 x N1) used for resampling. ; ; MODIFICATION HISTORY: ; Original version written Mar. 2007, A.H. Bouchez, Caltech Opt. Obs. ;- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FUNCTION RESAMPLE, y0, x0, x1, wt=wt nx0 = N_ELEMENTS(x0) nx1 = N_ELEMENTS(x1) xx0 = REBIN(x0, nx0, nx1) xx1 = REBIN(REFORM(x1, 1, nx1), nx0, nx1) dx1 = DERIV(x1) sig = REBIN(REFORM(dx1,1,nx1) / (2d * SQRT(-2*ALOG(0.5))), nx0, nx1) wt0 = EXP(-0.5*((xx0-xx1)/sig)^2) / (sig * SQRT(2*!pi)) wt = wt0 / REBIN(REBIN(wt0, 1, nx1) * nx0, nx0, nx1) yy0 = REBIN(y0, nx0, nx1) y1 = REFORM(REBIN(yy0 * wt, 1, nx1) * nx0) if SIZE(y0, /type) eq 4 then y1 = FLOAT(y1) RETURN, y1 END