Re: Floating point error [message #34740 is a reply to message #34734] |
Sat, 12 April 2003 13:20  |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
Kenneth Bowman <k-bowman@null.tamu.edu> writes:
> I am trying to scatter a vector "data" into an array "array" using array
> subscripts. "data" contains some NaNs.
>
> This causes floating point exceptions, even though no "operation" is
> taking place.
>
> IDL> help, i, j, h, data, array
> I LONG = Array[176779]
> J LONG = Array[176779]
> H LONG = Array[176779]
> DATA FLOAT = Array[176779]
> ARRAY FLOAT = Array[720, 160, 24]
> IDL> array[i,j,h] = data
> % Program caused arithmetic error: Floating illegal operand
> IDL> q = data ;Copy data
> IDL> q[*] = 0.0 ;Get rid of NaNs
> IDL> array[i,j,h] = q ;No problem
>
> If this is a feature, it is going to make using NaNs very difficult.
How about,
wh = where(finite(data), ct)
if ct GT 0 then array(i(wh), j(wh), h(wh)) = data(wh)
If you have repeats in your I,J,H data, and you want to sum over those
repeats, then you should use the dirty tricks that JD, I, et al. have
discussed in the past, primarily using the evil HISTOGRAM.
Craig
--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
|
|
|