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

Home » Public Forums » archive » About INTERPOLATE function.
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
About INTERPOLATE function. [message #91564] Wed, 29 July 2015 18:21 Go to next message
Dae-Kyu Shin is currently offline  Dae-Kyu Shin
Messages: 25
Registered: February 2015
Junior Member
Example 1.

a = findgen(4)
a[1] = !values.f_nan
print, a
0.000000 NaN 2.00000 3.00000

print, interpolate(a, [0, 1, 2, 3])
NaN NaN 2.00000 3.00000

Example 2.
a = transpose(a)
print, interpolate(a, 0, [0, 1, 2, 3], /grid)
0.000000
NaN
2.00000
3.00000

different result~!!
is this right output?
Re: About INTERPOLATE function. [message #91565 is a reply to message #91564] Wed, 29 July 2015 20:55 Go to previous message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
I think this a case of the location values being interpreted as floating point, and you are on a knife-edge when next to an NaN value

if a = [0,!values.f_nan,2,3]

then one expects interpolate(a,0) = 0 and interpolate(a,2) = 2

because the zeroth element has value of 0 and the second element has a value of 2.

But one also expects interpolate(a,0.00000000001)=NaN
and interpolate(a,1.99999999999(=NaN

because any type of interpolation/calculation involving an NaN value -- no matter how tiny -- should give NaN as an answer. If the location values are interpreted as floating point then inputing a 0 could mean a value very slightly smaller or larger. Thus IDL gives

IDL> print,interpolate(a,0),interpolate(a,2)
NaN 2.00000

though evidently with the /grid keyword the rounding works differently

My advice is -- don't use INTERPOLATE() when you have NaN values.




On Wednesday, July 29, 2015 at 9:21:04 PM UTC-4, Dae-Kyu Shin wrote:
> Example 1.
>
> a = findgen(4)
> a[1] = !values.f_nan
> print, a
> 0.000000 NaN 2.00000 3.00000
>
> print, interpolate(a, [0, 1, 2, 3])
> NaN NaN 2.00000 3.00000
>
> Example 2.
> a = transpose(a)
> print, interpolate(a, 0, [0, 1, 2, 3], /grid)
> 0.000000
> NaN
> 2.00000
> 3.00000
>
> different result~!!
> is this right output?
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Draw a shapefile with label from attribute table
Next Topic: FG bug

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

Current Time: Wed Oct 08 11:53:49 PDT 2025

Total time taken to generate the page: 0.00404 seconds