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

Home » Public Forums » archive » Re: Reverse interpolation?
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: Reverse interpolation? [message #21278 is a reply to message #21201] Wed, 16 August 2000 00:00 Go to previous messageGo to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
Martin Schultz <martin.schultz@dkrz.de> writes:

> Simon de Vet wrote:
...
>> I want to get better results. Instead of finding that entry #5 is the
>> closest match to my known altitude, and using #5 as the subscript in my
>> data array, I'd like to find that, based on a linear interpolation,
>> entry #5.32850 is an exact match, and using this value in an
>> interpolation on my data array.
>>
>> I understand how to use a subscript to find an interpolated value. How
>> would I go in the opposite direction, using a value to find a subscript?
>>
>> Thanks. I hope this isn't too confusing. I'm having a bad brane day.
>>
>> Simon
>
>
> Hi Simon,
>
> I have dealt with similar problems (vertical regridding, to
> give the kid a name), and I tend to resort on the spline routine
> in these instances. Please find attached a piece of code that I
> used to vertically regrid OH concentration fields. Just be
> careful about end effects. For this application I overwrote the
> topmostfour levels of the target grid with the values from the
> top level of the old grid.
>
...
> newxx = Spline( oldy, oldx, newy, 5. )
...

If you are trying to match a lot of values, then I agree that the
spline interpolation is one of the best solutions. However, I have
had bad experiences with the SPLINE function. It tends to have
problems when the points are too far apart, and it's also pretty slow.
I found the Numerical Recipes version of spline interpolation to be
much better (built in functions SPL_INTERP and SPL_INIT).

If v1 is vector of values sampled at original altitudes a1, and you
want to resample at new altitudes a2, then you do something like this:

v2 = spl_interp(a1, v1, spl_init(a1, v1), a2)

Now v2 has the newly sampled values. In principle a2 can be one value
so even if you want a single value the spline interpolation can be
useful, and even pretty fast.

IDL version 5.3 apparently has a new function called VALUE_LOCATE
which can do fast search of a reference array. From there you can do
a linear interpolation. The IDL Astronomy Library procedure called
TABINV may do what you want. The versions that use VALUE_LOCATE and
don't use it are here, and here, respectively:

http://idlastro.gsfc.nasa.gov/ftp/v53/tabinv.pro
http://idlastro.gsfc.nasa.gov/ftp/pro/math/tabinv.pro

Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Coastal boundaries over sat data
Next Topic: Re: VIRUS ALERT (was: Ghost object)

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

Current Time: Sat Oct 11 02:32:22 PDT 2025

Total time taken to generate the page: 1.60469 seconds