Interpolation of missing data [message #10751] |
Tue, 20 January 1998 00:00  |
rkj
Messages: 66 Registered: February 1996
|
Member |
|
|
I have a 2-D array with missing data. Is there an easy way to
interpolate the missing values?
I would like to replace a missing value with the average of
its neighbors.
Kyle J.
|
|
|
Re: interpolation of missing data [message #70019 is a reply to message #10751] |
Wed, 10 March 2010 06:42  |
Kenneth P. Bowman
Messages: 585 Registered: May 2000
|
Senior Member |
|
|
In article
<dd2beff8-b525-486a-a89b-ed308d1e506b@v20g2000yqv.googlegroups.com>,
a <oxfordenergyservices@googlemail.com> wrote:
> Hi
>
> I have a quick question...
>
> I have some data
>
> a=[-99.9,-99.9,-99.9,1,-99.9,2,-99.9,-99.9,3,4,6,-99.9,2,-99 .9,-99.9,-99.9]
>
> for example. I want all the -99.9s to be replaced with an
> interpolation of the existent data surrounding them (linear interp or
> other) but not the -99.9s at each end.
>
> I could do myself in a way that will work but may not be elegant. But
> then I might not learn something new, interesting and efficient!
>
> Thanks
>
> Russ
I think the easy way to do this is something like this.
x = FINDGEN(N_ELEMENTS(a))
i = WHERE(a NE -99.9, count)
IF (count GT 0) THEN $
ainterp = INTERPOL(a[i], x[i], x)
Because I don't understand what you want to do with the endpoints,
that is left as an exercise to the reader. :-)
Ken Bowman
|
|
|