|||
参考http://hi.baidu.com/dyqwrp/blog/item/c75b38386c4a61ced56225f9.html
http://hi.baidu.com/dyqwrp/blog/item/74f7505880f1929b800a18bb.html
http://hi.baidu.com/dyqwrp/blog/item/27899f17bfefd71a4a90a79b.html
唯独没有详细的单独说下IDL下遇到NAN时候的处理。
1、 NaN的出现原因
浮点数0除以0的时候。
IDL> print,1./0 Inf % Program caused arithmetic error: Floating divide by 0 IDL> print,0./0 -NaN |
2、 统计或分析时避开NAN
调用函数是加NaN关键字,几乎所有的IDL统计和分析函数都有此关键字。
IDL> a = findgen(4) IDL> a[0]='nan' IDL> a[2]='nan' IDL> print,a NaN 1.00000 NaN 3.00000 IDL> print,mean(a) NaN IDL> print,mean(a,/nan) 2.00000 IDL> print,total(a) NaN IDL> print,total(a,/nan) 4.00000 |
3、 移除数组中的NAN
关键在于判断该值的位置,可以利用finite和where函数。
IDL> print,a NaN 1.00000 NaN 3.00000 IDL> print,finite(a) 0 1 0 1 IDL> newa = a[where(finite(a))] IDL> print,newa 1.00000 3.00000 IDL> a[where(~finite(a))] = -9999 IDL> print,a -9999.00 1.00000 -9999.00 3.00000 |
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-12-23 10:52
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社