| Re: Expand [message #10618 is a reply to message #733] |
Tue, 06 January 1998 00:00   |
Kevin Ivory
Messages: 71 Registered: January 1997
|
Member |
|
|
Kelly Dean wrote:
>
> I am reading some AVHRR LAC data in the Level 1B format. The image
> provides 51 latitude/longitude pairs for each 2048 pixel scan line. They
> are sampled every 40 points starting at point 25 (25, 65, 105,..., 1945,
> 1985, 2025).
>
> I created a simple IDL routine to expand the 51 values to 2048 values
> using FOR loops. I am looking for suggestions to make this more
> efficient.
Look into the 'interpolate' documentation and use 'findgen' instead of the
extrapolation for loops.
I did your job for you: (untested code)
FUNCTION INTER2048, array51
;+
; PURPOSE:
; Interpolate AVHRR LAC data in the Level 1B format to 2048 values.
; The image provides 51 latitude/longitude pairs for each 2048 pixel
; scan line. They are sampled every 40 points starting at point 25
; (25, 65, 105,..., 1945, 1985, 2025).
;-
start = 24
interval = 40
n_pix = 2048
n_in = n_elements(array51) ; should be 51
last = start + (n_in-1) * interval ; this is going to be 2024
array2048 = FLTarr(n_pix)
;
dvalue = (array51(1) - array51(0)) / interval
; extrapolation to the left
array2048(0:start-1) = array51(0) - dvalue * findgen(start)
; interpolation
array2048(start:last-1) = interpolate(array51, findgen(last-start)/interval)
; extrapolation to the right
dvalue = (array51(n_in-1) - array51(n_in-2)) / interval
array2048(last:n_pix-1) = array51(n_in-1) + dvalue * findgen(n_pix-last)
RETURN, array2048
END
--
Kevin Ivory Tel: +49 5556 979 434
Max-Planck-Institut fuer Aeronomie Fax: +49 5556 979 240
Max-Planck-Str. 2 mailto:Kevin.Ivory@linmpi.mpg.de
D-37191 Katlenburg-Lindau, GERMANY http://www.gwdg.de/~kivory2/
|
|
|
|