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

Home » Public Forums » archive » Re: Turning off math error checking for a code block
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: Turning off math error checking for a code block [message #28897 is a reply to message #28896] Thu, 17 January 2002 09:26 Go to previous messageGo to previous message
Liam E. Gumley is currently offline  Liam E. Gumley
Messages: 378
Registered: January 2000
Senior Member
Kenneth Bowman wrote:
>
> I have an array x that is likely to have missing values in it, indicated by NaN's.
> I would like to search the array for values less than x_min. Because of the NaN's,
> WHERE generates a floating point error, e.g.,
>
> IDL> print, x
> 0.00000 NaN 2.00000 3.00000
> IDL> print, where(x lt 2.0)
> 0
> % Program caused arithmetic error: Floating illegal operand
>
> As best I understand the interaction between !EXCEPT and CHECK_MATH,
> in order to suppress this error message, while still checking errors elsewhere
> in the code, I must do the following:
>
> error = CHECK_MATH(/PRINT) ;If any errors have occurred, print
> save_except = !EXCEPT ;Save current exception flag
> !EXCEPT = 0 ;Set exception flag to 0
> i = WHERE(x LT x_min, ni) ;Find all x < x_min
> error = CHECK_MATH() ;Clear accumulated error status
> !EXCEPT = save_except ;Restore exception flag
>
> Am I making this harder than it needs to be?

The FINITE function returns 1 where the argument is finite, and 0 where
the argument is infinite *or* NaN (see p. 134 of my book). Try the
following:

x_min = 2.0
index = where(finite(x) eq 1, count)
if (count gt 0) then print, where(x[index] lt x_min)

Cheers,
Liam.
Practical IDL Programming
http://www.gumley.com/
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: load sharing on multiple machines?
Next Topic: Turning off math error checking for a code block

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

Current Time: Sat Oct 11 02:08:16 PDT 2025

Total time taken to generate the page: 0.79462 seconds