“IDL中的系统变量”的版本间差异

来自Shiyin's note
跳到导航 跳到搜索
(以“*特殊值 !Values”替换内容)
无编辑摘要
 
第1行: 第1行:
*[[特殊值 !Values]]
*[[特殊值 !Values]]



*!EXCEPT
:数学错误
!EXCEPT=0 不报错.
!EXCEPT=1 (默认值,在程序结束后回到交互控制台报错)
!EXCEPT=2 (在出错的地方报错)
在涉及到NaN的数据运算时,容易出现数学错误,比如
A = [1.0, 2.0, !VALUES.F_NAN]
PRINT, WHERE(A GT 1.0)
IDL prints:
1
% Program caused arithmetic error: Floating illegal operand
:该问题可利用FINITE函数加以解决。如
PRINT, WHERE(FINITE(A) EQ 1)
在程序中如果设置!EXCEPT=0,可以用CHECK_MATH加以监控
PRINT, CHECK_MATH()
0
No errors detected since the last interactive prompt or call to CHECK_MATH
1
Integer divided by zero
2
Integer overflow
16
Floating-point divided by zero
32
Floating-point underflow
64
Floating-point overflow
128
Floating-point operand error. An illegal operand was encountered, such as a negative operand to the SQRT or ALOG functions, or an attempt to convert to integer a number whose absolute value is greater than 231 - 1

2017年6月5日 (一) 13:56的最新版本


  • !EXCEPT
数学错误
  !EXCEPT=0 不报错.
  !EXCEPT=1 (默认值,在程序结束后回到交互控制台报错)
  !EXCEPT=2 (在出错的地方报错)

在涉及到NaN的数据运算时,容易出现数学错误,比如

   A = [1.0, 2.0, !VALUES.F_NAN]
   PRINT, WHERE(A GT 1.0)
   IDL prints:
     1
   % Program caused arithmetic error: Floating illegal operand
该问题可利用FINITE函数加以解决。如
PRINT, WHERE(FINITE(A) EQ 1)

在程序中如果设置!EXCEPT=0,可以用CHECK_MATH加以监控

PRINT, CHECK_MATH() 
     0     
     No errors detected since the last interactive prompt or call to CHECK_MATH
     1     
     Integer divided by zero
     2     
     Integer overflow
     16     
     Floating-point divided by zero
     32     
     Floating-point underflow
     64     
     Floating-point overflow
     128     
     Floating-point operand error. An illegal operand was encountered, such as a negative operand to the SQRT or ALOG functions, or an attempt to convert to integer a number whose absolute value is greater than 231 - 1