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

Home » Public Forums » archive » Using Minimum operator with NaN 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
Using Minimum operator with NaN values [message #86252] Mon, 21 October 2013 17:25 Go to previous message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
Most of this information is in the IDL docs http://www.exelisvis.com/docs/Minimum_and_Maximum_Oper.html# expressions_2976722315_1032669 but it is easy to forget. The minimum and maximum operators do not work nicely with NaN values.

IDL> print,!Version
{ x86_64 darwin unix Mac OS X 8.2.3 May 2 2013 64 64}
IDL> a = findgen(5)
IDL> a[2] = !values.f_nan
IDL> print,a
0.00000 1.00000 NaN 3.00000 4.00000
IDL> print,a>2
2.00000 2.00000 2.00000 3.00000 4.00000
% Program caused arithmetic error: Floating illegal operand

I think most people would say that the proper behavior would be for the NaN value to be preserved. The IDL doc says the behavior is actually hardware dependent, and on some machines the NaN is preserved! It suggests instead using WHERE and FINITE() instead of ">", whenever NaN values are present. This also eliminates the annoying "illegal operand" error message. The ">" operator does not check for NaN values for speed reasons, and the syntax does not allow having a /NaN keyword with ">" ;-)

A related problem occurs with the HIST_EQUAL() function.
IDL> print,hist_equal(a)
0 85 0 170 255
% Program caused arithmetic error: Floating illegal operand

In this case, it is correct that the NaN is not preserved, since the output of HIST_EQUAL() is a byte array. But I think it is a bug that the illegal operand error occurs. HIST_EQUAL() *does* check for NaN values internally -- for example, HISTOGRAM() is called with the NaN keyword. It is only at the last step in HIST_EQUAL() where a ">" operator is used, that the NaN value are ignored. In this case, I think ITTVIS should follow their own advice and use WHERE and FINITE() rather than the ">" operator.

--Wayne
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: object argument passing behaviour changed in v8.2.2?
Next Topic: How to obtain contour data through contour command?

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

Current Time: Fri Oct 10 00:05:06 PDT 2025

Total time taken to generate the page: 0.24304 seconds