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

Home » Public Forums » archive » Re: Removing bad data from an array
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
Re: Removing bad data from an array [message #55329] Fri, 10 August 2007 08:55
Melanie is currently offline  Melanie
Messages: 4
Registered: August 2007
Junior Member
Thanks David. I did use WHERE to find the bad points so the first
method you mentioned worked out perfecctly.
Re: Removing bad data from an array [message #55331 is a reply to message #55329] Fri, 10 August 2007 08:25 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

>> I am trying to remove bad data points from an array. I have found the
>> index numbers where the bad data points are located, but I am not sure
>> the most efficient way to go through the array and remove those data
>> points. Does anyone know of a simple way to do this?
>
> It is probably easier to look for the *good* points, but...
> to each his own. :-)
>
> Try something like this:
>
> badpnts = Where( array LT whatever, badcount, $
> COMPLEMENT=goodpnts, NCOMPLEMENT=goodcount)
> IF goodcount GT 0 THEN array = array[goodpnts]

Of course, if you used some other method than WHERE
to find the bad points (what other method is there!?),
you might have to use another method for find the good
points. A SETDIFFERENCE method comes to mind:

http://www.dfanning.com/tips/set_operations.html

Something like this, assuming a vector of "badpixels"
and a 2D array.

s = Size(array, /Dimensions)
allpixels = Indgen(s[0]*s[1])
goodpixels = SetDifference(allpixels, badpixels)
array = array[goodpixels]

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: Removing bad data from an array [message #55332 is a reply to message #55331] Fri, 10 August 2007 08:12 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Melanie writes:

> I am trying to remove bad data points from an array. I have found the
> index numbers where the bad data points are located, but I am not sure
> the most efficient way to go through the array and remove those data
> points. Does anyone know of a simple way to do this?

It is probably easier to look for the *good* points, but...
to each his own. :-)

Try something like this:

badpnts = Where( array LT whatever, badcount, $
COMPLEMENT=goodpnts, NCOMPLEMENT=goodcount)
IF goodcount GT 0 THEN array = array[goodpnts]

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.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Removing bad data from an array
Next Topic: Memory benefit from subroutines

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

Current Time: Wed Oct 08 20:02:32 PDT 2025

Total time taken to generate the page: 0.08412 seconds