Re: IDL 8.2.2 and PLOT with NaN values [message #83679] |
Fri, 29 March 2013 08:36  |
chris_torrence@NOSPAM
Messages: 528 Registered: March 2007
|
Senior Member |
|
|
On Tuesday, March 26, 2013 9:59:36 AM UTC-6, Karlo Janos wrote:
> Hi group,
>
>
>
> can somebody confirm, that the PLOT function in IDL 8.2.2 produces the
>
> "arithmetic error: Floating illegal operand" when plotting a vector
>
> which contains NaN values?
>
>
>
> Example:
>
> p = PLOT([1,2,3,4,!VALUES.F_NAN,6,7,8,9])
>
>
>
> If I remember correctly, the former versions of IDL just skipped the
>
> NaNs without any error message.
>
>
>
> I am frustrated...
>
>
>
> Thanks
>
>
>
> Karlo
Hi Karlo,
This bug has now been fixed, and will be in the next IDL release. Thanks for reporting it!
In case you're interested, we added code to compute the maximum value of the plot, so that we could adjust the plot margins in case the Y range was huge. We just needed to use /NAN when computing the maximum, so that NaN values would be skipped.
Cheers,
Chris
ExelisVIS
|
|
|
Re: IDL 8.2.2 and PLOT with NaN values [message #83696 is a reply to message #83679] |
Wed, 27 March 2013 14:39   |
Lajos Foldy
Messages: 176 Registered: December 2011
|
Senior Member |
|
|
On Wednesday, March 27, 2013 10:10:23 PM UTC+1, wlandsman wrote:
> Not only are the math errors hardware dependent, but today I came across the fact that it can depend on how the array is ordered.
>
> IDL> print,min([2.,!values.f_nan,3.])
> 2.00000
> IDL> print,min([!values.f_nan,3.,2.])
> NaN
> IDL> print,!version
> { x86_64 linux unix linux 8.2.2 Jan 23 2013 64 64}
>
> The help for MIN says
>
> "Note: If the MIN function is run on an array containing NaN values and the NAN keyword is not set, an invalid result will occur."
>
> but this should probably read
>
> Note: If the MIN function is run on an array containing NaN values and the NAN keyword is not set, an invalid result **may** occur.
This can be explained: a MIN function implementation may look like:
min=arr[0]
for j=1,n_elements(arr)-1 do min=min<arr[j]
so a non-NaN first elements is vital (without /NaN). For small arrays, only this first element counts. For large arrays, multithreading comes into the picture and there are multiple first elements (each thread has one somewhere in the array).
regards,
Lajos
|
|
|
Re: IDL 8.2.2 and PLOT with NaN values [message #83697 is a reply to message #83696] |
Wed, 27 March 2013 14:10   |
wlandsman
Messages: 743 Registered: June 2000
|
Senior Member |
|
|
Not only are the math errors hardware dependent, but today I came across the fact that it can depend on how the array is ordered.
IDL> print,min([2.,!values.f_nan,3.])
2.00000
IDL> print,min([!values.f_nan,3.,2.])
NaN
IDL> print,!version
{ x86_64 linux unix linux 8.2.2 Jan 23 2013 64 64}
The help for MIN says
"Note: If the MIN function is run on an array containing NaN values and the NAN keyword is not set, an invalid result will occur."
but this should probably read
Note: If the MIN function is run on an array containing NaN values and the NAN keyword is not set, an invalid result **may** occur.
On Wednesday, March 27, 2013 5:39:22 AM UTC-4, Fabien wrote:
> Quoting IDL help:
>
>
>
> "The detection of math errors, such as division by zero, overflow, and
>
> attempting to take the logarithm of a negative number, is hardware and
>
> operating system dependent."
>
>
>
> http://www.exelisvis.com/docs/Math_Errors.html
|
|
|
|
|
Re: IDL 8.2.2 and PLOT with NaN values [message #83720 is a reply to message #83719] |
Wed, 27 March 2013 01:21   |
Karlo Janos
Messages: 31 Registered: July 2008
|
Member |
|
|
Here is my output for IDL 8.2.2 and Windows 7 64 bit:
IDL> print, !version
{ x86_64 Win32 Windows Microsoft Windows 8.2.2 Jan 23 2013 64 64}
IDL> p = PLOT([1,2,3,4,!VALUES.F_NAN,6,7,8,9])
% Program caused arithmetic error: Floating illegal operand
And for IDL 8.2.1 and Linux 64 bit:
IDL> print, !version
{ x86_64 linux unix linux 8.2.1 Aug 20 2012 64 64}
IDL> p=PLOT([1,2,3,4,!VALUES.F_NAN,6,7,8,9])
(no error here)
Maybe an issue of the version for Windows?
Karlo
26.03.2013 19:21, Michael Galloy:
> No error appears for me on 8.2.2:
>
> IDL> print, !version
> { x86_64 darwin unix Mac OS X 8.2.2 Jan 23 2013 64 64}
> IDL> p = PLOT([1,2,3,4,!VALUES.F_NAN,6,7,8,9])
> % Loaded DLM: PNG.
>
> Mike
|
|
|
Re: IDL 8.2.2 and PLOT with NaN values [message #83723 is a reply to message #83720] |
Tue, 26 March 2013 11:21   |
Michael Galloy
Messages: 1114 Registered: April 2006
|
Senior Member |
|
|
On 3/26/13 11:05 AM, Karlo Janos wrote:
> Thanks Fabien,
>
> but actually in my program where I have found the error for the first
> time (after the upgrade to IDL 8.2.2) I use FLOAT arrays.
>
> The code line which I have posted was just an example. And it does not
> make any difference whether I use mine or yours.
>
> And in either case the error does not appear in IDL 8.2.1.
>
> Thanks
>
> Karlo
>
>
>
> Am 26.03.2013 17:44, schrieb Fabien:>
>> The error comes because your are putting a NaN float in an integer
>> array. Try:
>>
>> p = PLOT([1.,2,3,4,!VALUES.F_NAN,6,7,8,9])
>>
>> cheers,
>>
>> Fab
>
No error appears for me on 8.2.2:
IDL> print, !version
{ x86_64 darwin unix Mac OS X 8.2.2 Jan 23 2013 64 64}
IDL> p = PLOT([1,2,3,4,!VALUES.F_NAN,6,7,8,9])
% Loaded DLM: PNG.
Mike
--
Michael Galloy
www.michaelgalloy.com
Modern IDL: A Guide to IDL Programming (http://modernidl.idldev.com)
Research Mathematician
Tech-X Corporation
|
|
|
Re: IDL 8.2.2 and PLOT with NaN values [message #83724 is a reply to message #83723] |
Tue, 26 March 2013 10:05   |
Karlo Janos
Messages: 31 Registered: July 2008
|
Member |
|
|
Thanks Fabien,
but actually in my program where I have found the error for the first
time (after the upgrade to IDL 8.2.2) I use FLOAT arrays.
The code line which I have posted was just an example. And it does not
make any difference whether I use mine or yours.
And in either case the error does not appear in IDL 8.2.1.
Thanks
Karlo
Am 26.03.2013 17:44, schrieb Fabien:>
> The error comes because your are putting a NaN float in an integer
> array. Try:
>
> p = PLOT([1.,2,3,4,!VALUES.F_NAN,6,7,8,9])
>
> cheers,
>
> Fab
|
|
|
Re: IDL 8.2.2 and PLOT with NaN values [message #83725 is a reply to message #83724] |
Tue, 26 March 2013 09:44   |
Fabzi
Messages: 305 Registered: July 2010
|
Senior Member |
|
|
The error comes because your are putting a NaN float in an integer
array. Try:
p = PLOT([1.,2,3,4,!VALUES.F_NAN,6,7,8,9])
cheers,
Fab
On 03/26/2013 04:59 PM, Karlo Janos wrote:
> Hi group,
>
> can somebody confirm, that the PLOT function in IDL 8.2.2 produces the
> "arithmetic error: Floating illegal operand" when plotting a vector
> which contains NaN values?
>
> Example:
> p = PLOT([1,2,3,4,!VALUES.F_NAN,6,7,8,9])
>
> If I remember correctly, the former versions of IDL just skipped the
> NaNs without any error message.
>
> I am frustrated...
>
> Thanks
>
> Karlo
>
|
|
|
Re: IDL 8.2.2 and PLOT with NaN values [message #83797 is a reply to message #83679] |
Tue, 02 April 2013 00:13  |
Karlo Janos
Messages: 31 Registered: July 2008
|
Member |
|
|
Thanks Chris,
it is always nice getting to know why things happen.
I am looking forward to the new release.
Ciao
Karlo
29.03.2013 16:36, Chris Torrence:
> Hi Karlo,
>
> This bug has now been fixed, and will be in the next IDL release. Thanks for reporting it!
>
> In case you're interested, we added code to compute the maximum value of the plot,
> so that we could adjust the plot margins in case the Y range was huge.
We just needed
> to use /NAN when computing the maximum, so that NaN values would be
skipped.
>
> Cheers,
> Chris
> ExelisVIS
>
|
|
|