PRO ucles_resample, nw, w, fn,fs, wb,wi ; Procedure to resample a 2d echelle frame onto a uniform wavelength scale ; Input ; w nw x no wavelengths ; fn nw x no normalized fluxes ; fs nw x no rectification function ; Output ; wb nw x no wavelengths remapped to constant dx ; wi no vector containing number of wavelengths in each order ; fn nw x no normalized fluxes remapped to wb ; fs nw x no rectification function remapped to wb ; resample all data onto uniform wavelength grid ; nb the smoothing fucntion must also be resampled PRINT,'UCLES_RESAMPLE: resample echelle spectrum' no = n_elements(w)/nw wb = w wi = intarr(no) dwx = (wb(nw-1,*)-wb(0,*)) / (nw-1) dw = max ( dwx ) w0 = wb(0,0) PRINT,'uniform grid, dw =',dw FOR j = 0,no-1 DO BEGIN wl = w0 + floor ( (wb( 0,j)-w0)/dw ) * dw wu = w0 + floor ( (wb(nw-1,j)-w0)/dw ) * dw tw = wb(*,j) & tf = fn(*,j) resample,tw,tf,wl,wu,dw tw = wb(*,j) & ts = fs(*,j) resample,tw,ts,wl,wu,dw tn = n_elements(tw)-2 wb(0:tn,j) = tw(0:tn) & fn(0:tn,j) = tf(0:tn) & fs(0:tn,j) = ts(0:tn) fs(tn+1:nw-1,j) = 0. wi(j) = tn ENDFOR ; remove high frequency noise introduced by resample FOR j = 0,no-1 DO BEGIN tn=wi(j) fs(0:tn,j) = qqsm ( w(0:tn,j),fs(0:tn,j),1.0 ) ENDFOR window,1 shade_surf,fs,zrange=[0,max(fs)] END