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

Home » Public Forums » archive » Re: 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 #59112 is a reply to message #59031] Tue, 04 March 2008 18:55 Go to previous messageGo to previous message
Kenneth P. Bowman is currently offline  Kenneth P. Bowman
Messages: 585
Registered: May 2000
Senior Member
In article <MPG.223755c5d615d3ab98a2aa@news.frii.com>,
David Fanning <news@dfanning.com> wrote:

> Kenneth P. Bowman writes:
>
>> This problem looks just like the one David Fanning was working
>> on recently, and here is an outline of the solution
>>
>>> Assuming that your data is 2-D (x = longitude and y = latitude), create
>>> the grids that you want to interpolate to
>>> nx = 360
>>> ny = 181
>>> x �= FINDGEN(nx)
>>> y �= -90.0 + FINDGEN(ny)
>>> Compute the "interpolation coordinates" from the original grid
>>> j �= VALUE_LOCATE(y_original, y)
>>> yj = j + (y - y_original[j])/(y_original[j+1] - y_original[j])
>
> This works OK, I think, if the values you wish to interpolate
> to are completely contained within the bounds of the original
> vectors. But, suppose the original array was 180x90 and
> I want to interpolate from 360x180. Then, the beginning
> and ending values in the vectors I want to interpolate to
> are outside the bounds of the original vectors. When
> I go to find the "interpolation coordinates", I encounter
> divide by zero errors and get infinities in my vectors.
>
> Do you have a way of handling this situation? I mention
> this because in the perverse CCCMA climate model I am
> using, the longitude vector is evenly spaced, *except*
> for the two values at either end of the vector. (Don't
> ask me, I have no idea.) My "regularly spaced" interpolation
> vector blows up on me at either end.

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.

Ken
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Speeding up a call to the where function
Next Topic: GRIDDATA woes

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

Current Time: Sun Oct 12 09:41:54 PDT 2025

Total time taken to generate the page: 1.99917 seconds