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

Home » Public Forums » archive » Re: IDL's handling of LOGICAL quantities (WHERE)
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: IDL's handling of LOGICAL quantities (WHERE) [message #17407 is a reply to message #17403] Tue, 12 October 1999 00:00 Go to previous messageGo to previous message
Liam Gumley is currently offline  Liam Gumley
Messages: 473
Registered: November 1994
Senior Member
Liam Gumley wrote:
> To filter out non-finite values in an array, I'd use a function:

Now that I think about it, you might want to check an array subset. The
version below will handle an array subset.

FUNCTION CHECK_FINITE, DATA, VALUE=VALUE

;- Check arguments
if n_params() ne 1 then message, 'Usage: RESULT = CHECK_FINITE(DATA)'
if n_elements(data) eq 0 then message, 'DATA is undefined'
if n_elements(value) eq 0 then value = 0.0

;- Set any non-finite elements to VALUE
index = where(finite(data) eq 0, count)
result = data
if count gt 0 then result[index] = value

;- Return the result
return, result

END

For example:

IDL> a = findgen(5)
IDL> a[0:2] = 1.0/0.0
% Program caused arithmetic error: Floating divide by 0
IDL> print, a
Inf Inf Inf 3.00000 4.00000
IDL> a[0:2] = check_finite(a[0:2])
% Compiled module: CHECK_FINITE.
IDL> print, a
0.00000 0.00000 0.00000 3.00000 4.00000

Cheers,
Liam.

--
Liam E. Gumley
Space Science and Engineering Center, UW-Madison
http://cimss.ssec.wisc.edu/~gumley
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: getting a scan along a set of points in an image....
Next Topic: Re: Table widgets

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

Current Time: Wed Oct 08 19:17:17 PDT 2025

Total time taken to generate the page: 0.00412 seconds