|
Re: Removing bad data from an array [message #55331 is a reply to message #55329] |
Fri, 10 August 2007 08:25  |
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  |
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.")
|
|
|