[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: summation problem



Nice one mate, worked a treat.

Thanks,

Manish

"Jaco van Gorkom" <j.c.van.gorkom@fz-juelich.de> wrote in message
3ACC53E1.A396D87C@fz-juelich.de">news:3ACC53E1.A396D87C@fz-juelich.de...
> Manish wrote:
>  ...
> > I have a program which produces an array of values of sunlight flux
during
> > the day.  Unfortunately, it produces crazy numbers before the sunrises
and
> > after it sets(as expected).  I'm summing the values throughout the day
to
> > get a total integrated day flux, but here's the problem - is there a way
of
> > telling the TOTAL function to ignore negative numbers and NaN numbers?
>
> Yes, there is a way:
> IDL> test = [0,-1,3,4,!values.f_nan]
> IDL> print, total(test>0,/nan)
>       7.00000
> % Program caused arithmetic error: Floating illegal operand
>
> The 'illegal operand' error appears to be harmless, caused by comparing
test>0:
> IDL> print, test>0
>       0.00000      0.00000      3.00000      4.00000          NaN
> % Program caused arithmetic error: Floating illegal operand
>
> > I guess this is a simple problem, but would appreciate any help
> It is simple enough, but only once you know the solution.
>
> cheers,
>   Jaco