comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » TOTAL gives totally different result on identical array
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
TOTAL gives totally different result on identical array [message #76904] Fri, 08 July 2011 03:22
M. Suklitsch is currently offline  M. Suklitsch
Messages: 12
Registered: August 2008
Junior Member
Hi everybody,


I don't exactly know how to start this question, so I'll probably just
tell you the workflow which leads to a very disturbing result.

I have a netCDF file which contains temperature data for a decade on
daily time resolution. And I have two different versions of an IDL
based evaluation tool which should read in the data and do some stuff
with it.

Now, although I read in exactly the same data (the data array has the
same size in both IDL sessions with both versions of my tool), TOTAL
and MEAN give completely different results. And I do not understand
how that can be, since the data does not contain any NaN values, and
MIN and MAX of the array are identical in both IDL sessions. The only
difference between the two IDL sessions are different source codes
that lead to the point where I do the stuff below. Here is what I get:

Session 1:
=======
IDL> ncid=NCDF_OPEN('my_input_file.nc')
IDL> ncdf_varget, ncid, 'tas', testa
IDL> help, mean(testa), min(testa), max(testa)
<Expression> FLOAT = 270.284
<Expression> FLOAT = 232.614
<Expression> FLOAT = 317.723
IDL> print, total(testa)/n_elements(testa)
270.284
IDL> print, n_elements(testa)
127124400
IDL> print, total(testa)
3.43597e+10
IDL> idx=where(testa lt 275., countidx, ncomplement=countnidx)
IDL> help, countidx, countnidx
COUNTIDX LONG = 22074445
COUNTNIDX LONG = 105049955


Session 2:
=======
IDL> ncid=NCDF_OPEN('my_input_file.nc')
IDL> ncdf_varget, ncid, 'tas', testa
IDL> help, mean(testa), min(testa), max(testa)
<Expression> FLOAT = 67.5711
<Expression> FLOAT = 232.614
<Expression> FLOAT = 317.723
IDL> print, total(testa)/n_elements(testa)
67.5711
IDL> print, n_elements(testa)
127124400
IDL> print, total(testa)
8.58993e+09
IDL> idx=where(testa lt 275., countidx, ncomplement=countnidx)
IDL> help, countidx, countnidx
COUNTIDX LONG = 22074445
COUNTNIDX LONG = 105049955


So, the values within the arrays seem to be the same (since the
counting gives the identical number of elements), yet the TOTAL (and
MEAN) deviate completely from each other. How can that be? I am really
confused right now. And insecure about any results I got so far.


Regards,
Martin
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Variable is undefined: Actually a function
Next Topic: Re: Aw: Re: TOTAL gives totally different result on identical array

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Thu Oct 09 15:19:38 PDT 2025

Total time taken to generate the page: 0.00609 seconds