Interpolate the NaN in 2D array. [message #91507] |
Wed, 22 July 2015 10:14  |
anagetinga
Messages: 1 Registered: July 2015
|
Junior Member |
|
|
Hi everyone,
I have a question about 2D interpolation with NaN inside. My doubt is how I proceed to interpolate NaN inside the 2D array.
Best regards,
Cosme
|
|
|
|
Re: Interpolate the NaN in 2D array. [message #91511 is a reply to message #91508] |
Wed, 22 July 2015 12:11   |
wlandsman
Messages: 743 Registered: June 2000
|
Senior Member |
|
|
On Wednesday, July 22, 2015 at 2:04:53 PM UTC-4, Paul van Delst wrote:
> On 07/22/15 13:14, a**@gmail.com wrote:
>> Hi everyone,
>>
>> I have a question about 2D interpolation with NaN inside. My doubt is
>> how I proceed to interpolate NaN inside the 2D array.
>
> Filter them out?
>
> INTERPOL has a /NAN keyword. But you can do it yourself too.
INTERPOL() is only for 1-d data I believe. But I would probably start by averaging the result of using INTERPOL() over a row, and INTERPOL() over a column. A more "correct' way would be to use the very powerful -- and very complicated -- GRIDDATA() function, but this is only for the ambitious.
For a similar problem I have used the maskinterp package by Joe Harrington ( https://physics.ucf.edu/~jh/ast/software.html ) but again it is not very user-friendly. However, in my case I had to make sure that I did not bias my results when interpolating over multiple NaN values, and this package is good for this.
|
|
|
|
Re: Interpolate the NaN in 2D array. [message #91526 is a reply to message #91516] |
Thu, 23 July 2015 20:40  |
wlandsman
Messages: 743 Registered: June 2000
|
Senior Member |
|
|
On Thursday, July 23, 2015 at 7:58:10 AM UTC-4, Haje Korth wrote:
>
> INTERPOLATE (instead of INTERPOL) does 2D interpolation. It has a MISSING keyword. Try setting MISSING=!value.f_nan.
I don't believe that INTERPOLATE() can deal with NaN values. The MISSING keyword is used to set an *output* value to elements outside of the range of the input array.
And INTERPOLATE() does not have any way to recognize NAN values as special. For example,
IDL> a = dist(5)
IDL> a[2,3] = !values.f_nan
IDL> print,interpolate(a,2,3)
NaN
IDL> print,interpolate(a,2.3,3.3)
NaN
|
|
|