function interp_2pt,x,y,y2,miss ;------------------------------------------------------------------ ; ; Do a 2 point linear interpolation of x, from the y grid to the ; y2 point (or grid) ; ; input: ; x......x axis variables ; y......y axis variables ; y2.....interpolate to this value or grid ; miss...missing data value ; ; output: ; result...the data value from x at y2 ; ; source: Mark Hervig ;------------------------------------------------------------------ if (n_elements(x) ne n_elements(y)) then begin print,'x and y arrays are not the same size in interp_2pt.pro!!!' stop endif n = n_elements(y) n2 = n_elements(y2) x2 = fltarr(n2) + miss ok = where(x ne miss,nok) if (nok gt 1) then begin xa = x(ok) ya = y(ok) for i = 0,n2-1 do begin for j = 0,nok-2 do begin if (ya(j) ge y2(i) and ya(j+1) le y2(i)) then begin term = (y2(i)-ya(j)) / (ya(j+1)-ya(j)) x2(i) = term * (xa(j+1)-xa(j)) + xa(j) goto,jump1 endif if (ya(j) le y2(i) and ya(j+1) ge y2(i))then begin term = (y2(i)-ya(j)) / (ya(j+1)-ya(j)) x2(i) = term * (xa(j+1)-xa(j)) + xa(j) goto,jump1 endif endfor jump1: endfor endif return,x2 end