Delete bad data and interplate the new data [message #52950] |
Mon, 12 March 2007 02:23  |
duxiyu@gmail.com
Messages: 88 Registered: March 2007
|
Member |
|
|
I have a data array.
But there is some bad data in it.
I want to use the interpolative data to replace these bad points.
It is easy to make a procedure to do it, but I wonder whether there is
internal procedure in IDL.
Best regards,
Du Jian
|
|
|
Re: Delete bad data and interplate the new data [message #53022 is a reply to message #52950] |
Tue, 13 March 2007 10:26  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
JD Smith writes:
> Yes, INTERPOL:
>
> data=[1,2,3,42,5,6,7]
> badval=42
> bad=where(data eq badval,nbad,COMPLEMENT=good,NCOMPLEMENT=ngood)
> if nbad gt 0 && ngood gt 1 then data[bad]=interpol(data[good],good,bad)
>
> If you want to do 2D or higher-dimension interpolation, you'll need a
> bit more magic.
Yikes! If you showed us the 2D case we would have the makings
of a nice little article here. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
Re: Delete bad data and interplate the new data [message #53023 is a reply to message #52950] |
Tue, 13 March 2007 09:18  |
JD Smith
Messages: 850 Registered: December 1999
|
Senior Member |
|
|
On Mon, 12 Mar 2007 02:23:54 -0700, duxiyu@gmail.com wrote:
> I have a data array.
> But there is some bad data in it.
> I want to use the interpolative data to replace these bad points.
>
> It is easy to make a procedure to do it, but I wonder whether there is
> internal procedure in IDL.
Yes, INTERPOL:
data=[1,2,3,42,5,6,7]
badval=42
bad=where(data eq badval,nbad,COMPLEMENT=good,NCOMPLEMENT=ngood)
if nbad gt 0 && ngood gt 1 then data[bad]=interpol(data[good],good,bad)
If you want to do 2D or higher-dimension interpolation, you'll need a
bit more magic.
JD
|
|
|