“IDL中的系统变量”的版本间差异
跳到导航
跳到搜索
无编辑摘要 |
无编辑摘要 |
||
(未显示同一用户的2个中间版本) | |||
第1行: | 第1行: | ||
* !Values |
*[[特殊值 !Values]] |
||
:NAN and Infinity value |
|||
IDL> help,!Values,/str |
|||
** Structure !VALUES, 4 tags, length=24, data length=24: |
|||
F_INFINITY FLOAT Inf |
|||
F_NAN FLOAT NaN |
|||
D_INFINITY DOUBLE Infinity |
|||
D_NAN DOUBLE NaN |
|||
Inf还可取负 |
|||
IDL> print,-1*!Values.F_INFINITY |
|||
-Inf |
|||
问题:如何给一个整数变量赋一个NAN 或者 INFINITY |
|||
:F_INFINITY可以和浮点数做比较 F_NAN不能 |
|||
B = [1.0, 2.0, !VALUES.F_NAN] |
|||
IDL> PRINT, WHERE(B EQ !VALUES.F_NAN |
|||
-1 |
|||
:在求平均等计算时,设置/NAN开关,可将这些数忽略 |
|||
IDL> print,mean(B) |
|||
NaN |
|||
IDL> print,mean(B,/NAN) |
|||
1.50000 |
|||
第38行: | 第17行: | ||
PRINT, WHERE(FINITE(A) EQ 1) |
PRINT, WHERE(FINITE(A) EQ 1) |
||
在程序中如果设置!EXCEPT=0,可以用CHECK_MATH加以监控 |
在程序中如果设置!EXCEPT=0,可以用CHECK_MATH加以监控 |
||
PRINT, CHECK_MATH() |
|||
:result= check_math,check_math的数值如下 |
|||
0 |
0 |
||
No errors detected since the last interactive prompt or call to CHECK_MATH |
No errors detected since the last interactive prompt or call to CHECK_MATH |
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