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

Home » Public Forums » archive » zonal means
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
zonal means [message #11082] Mon, 16 March 1998 00:00 Go to previous message
Martin Schultz is currently offline  Martin Schultz
Messages: 515
Registered: August 1997
Senior Member
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)

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 !!

A: hmmm, we could try REBIN or CONGRID. How about that:
c = reform(rebin(a,1,46,14),46,14)
d = reform(congrid(a,1,46,14),46,14)

Q: That looks much more like IDL! But does it work ?

A: (after running a test with random data) Seems like REBIN is
just what you are looking for. CONGRID somehow screws it up. BTW: I am
sure you want to know the timing of these routines:
loop: 1.3769450 seconds
rebin: 0.15734899 seconds
congrid: 0.085584044 seconds
These results are obtained by repeating each method 100 times.

Q: But can I be ascertained that REBIN does the job correctly ? And does
anyone have an idea why CONGRID screws up ?


Thanks,
Martin.


------------------------------------------------------------ -------
Dr. Martin Schultz
Department for Earth&Planetary Sciences, Harvard University
186 Pierce Hall, 29 Oxford St., Cambridge, MA-02138, USA

phone: (617)-496-8318
fax : (617)-495-4551

e-mail: mgs@io.harvard.edu
IDL-homepage: http://www-as.harvard.edu/people/staff/mgs/idl/
------------------------------------------------------------ -------
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: recursive tag_names
Next Topic: Re: time test MacOC

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

Current Time: Sun Oct 12 05:44:11 PDT 2025

Total time taken to generate the page: 0.31948 seconds