comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » GRIDDATA woes
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: GRIDDATA woes [message #59093 is a reply to message #59063] Wed, 05 March 2008 06:57 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Kenneth P. Bowman writes:

> VALUE_LOCATE finds the index of the point less than or equal to the search
> value. You are trying to interpolate exactly to the last point. This
> code correctly computes the index of that point to be 7, but there
> is no point 8 to use for the interpolation. This can be solved
> like this
>
> IDL> lat = [-87.5, 50, 25, 0, 30, 45, 64, 87.5]
> IDL> y = Scale_Vector(findgen(7), -87.5, 87.499) <------
> IDL> j = Value_Locate(lat, y)
> IDL> yj = j + (y - lat[j])/(lat[j+1] - lat[j])
> IDL> PRINT, yj
> 0.00000 0.212120 0.424240 0.636360 3.97220
> 5.70171 6.99996
>
> Unfortunately, INTERPOLATE does not extrapolate when you are outside
> the domain of the function.

I'm going to agree with Ben, and keep VALUE_LOCATE out of it.
But, I've also used Paolo's suggestion. Here is code that I think
works well for me, and allows me to create any sized grid I
want.

In the code, lat is a 48-element vector that is irregularly
spaced, lon is a 96-element vector, that is regularly
spaced, except for the two end members, and sit is the
2D array I wish to resample. In this code, I am trying to
resample to a 360x180 array, to make it consistent with other
arrays I have available to me.

nx = 360
ny = 180
slon = Scale_Vector(Findgen(nx), 0.5, 359.5)
slat = Scale_Vector(Findgen(ny), Min(lat), Max(lat))
x = Interpol(Findgen(N_Elements(lon)), lon, slon)
y = Interpol(Findgen(N_Elements(lat)), lat, slat)
xx = Rebin(x, nx, ny, /SAMPLE)
yy = Rebin(Reform(y, 1, ny), nx, ny)

resampledArray = Interpolate(sit, xx, yy)

Even in this "worst case" scenario, I seem to get reasonably good
results. I *really* like that INTERPOL way of getting fractional
indices!

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: GRIDDATA woes
Next Topic: widget draw background color

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Mon Dec 01 14:57:14 PST 2025

Total time taken to generate the page: 0.63933 seconds