Re: zonal means [message #11080] |
Mon, 16 March 1998 00:00 |
Dan Bergmann
Messages: 2 Registered: February 1998
|
Junior Member |
|
|
Martin Schultz wrote:
>
> Hi everyone,
>
> this is part question, part answer - I just want to make sure there
> is nothing wrong with this:
>
> Q: How do you compute zonal means from a 3D data cube ?
> (example: A(72,46,14) is a data array with longitude, latitude, altitude
> as dimensions, and I want to compute the averages over longitude for
> each latitude and altitude)
>
bunch of complicated solutions deleted .....
Why not try
b = total(a,1)/72.
--
************************************************************ ***
** Dan Bergmann dbergmann@llnl.gov **
** Atmospheric Science Division fax (510) 423-4908 **
** Lawrence Livermore National Lab human (510) 423-6765 **
************************************************************ ***
|
|
|
Re: zonal means [message #11081 is a reply to message #11080] |
Mon, 16 March 1998 00:00  |
Evilio del Rio
Messages: 17 Registered: December 1997
|
Junior Member |
|
|
Martin Schultz wrote:
> ...
> Q: How do you compute zonal means from a 3D data cube ?
> (example: A(72,46,14) is a data array with longitude, latitude, altitude
> as dimensions, and I want to compute the averages over longitude for
> each latitude and altitude)
>
> A: well, you can do it in a loop (buuuuuhh!!)
> for j=0,13 do begin
> for i=0,45 do begin
> b(i,j) = total(a(*,i,j)) / 72.
> endfor
> endfor
>
> Q: but I hate loops !!
Hi Martin,
In my opinion you should use the TOTAL function with a second argument:
IDL> help,a
A FLOAT = Array[72, 46, 14]
IDL> b = TOTAL(A,1) ; The argument 1 tells TOTAL to sum just in the
first dim.
B FLOAT = Array[46, 14]
then the average is just b/72.0 in this case.
Cheers,
P.S.: I also hate loops! ;-)
____________________________________________________________ ________
Evilio Jose del Rio Silvan Institut de Ciencies del Mar
E-mail: edelrio@icm.csic.es URL: http://www.ieec.fcr.es/~evilio/
"Anywhere you choose,/ Anyway, you're gonna lose"- Mike Oldfield
|
|
|