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

Home » Public Forums » archive » filling in missing values
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: filling in missing values [message #67859 is a reply to message #67719] Tue, 25 August 2009 08:50 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
On Aug 25, 8:34 am, Laura <haixia...@gmail.com> wrote:
> Hi, I'm new to IDL and working on data files that assign a particular
> value for where the data is not available. But I want to replace such
> values with the nearest valid value in the array. Is there an
> efficient way to do that instead of loop?

Yes. If you can tolerate always replacing using the good value on the
left, then this would do the trick.

wh = where(data EQ BAD_VALUE, ct)
while ct GT 0 do begin
data[wh] = data[wh-1]
wh = where(data EQ BAD_VALUE, ct)
endwhile

It keeps on replacing until no values are left.

But if you are trying to replace bad values with local good values,
why not use the median function?

medval = median(data, 5) ;; Sliding 5-point median
wh = where(data EQ BAD_VALUE, ct)
if ct GT 0 then data[wh] = medval[wh]

There are ways to be smarter about that. For example the median
includes the bad values, and one may want to filter them out first.

Craig
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: SKIP the window "press click to continue" using the VIRTUAL MACHINE
Next Topic: use ENVI+IDL together

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

Current Time: Fri Oct 10 08:07:11 PDT 2025

Total time taken to generate the page: 0.00673 seconds