[Thread Prev][Thread Next][Index]

bin averages




Hi,
Hi,

I'm trying to find a good way to bin one data set by values of another data set. 
For example, let's say I have sst and surface pressure on a lat/lon/time grid.  
I want to produce averages of sst, over a given region, in each of several 
pressure bins, e.g., produce mean North Pacific sst separately for pressure 
between 995 and 1000 mb, between 1000 and 1005 mb, etc.

A problem of cumbersome coding arises when there are a lot of bins.  In fortran, 
I would simply have a do loop where the starting and ending pressure values of 
each pressure bin where calculated as some function of the loop index.  However, 
in Ferret, it seems you have to loop over indices of the grid your data set is 
defined on--you can't just say "repeat/i=1:50:1 go calc_bin_avg i", where i is 
some arbitrary loop index which is passed to the script to be used in defining 
the bins, because it will automatically be translated to the i that describes 
the x axis of the data you are trying to manipulate.

To get around this, I've tried the following:
define axis/z=990:1038:2 zstart_bin
define axis/z=992:1040:2 zend_bin
let start_bin = z[gz=zstart_bin]
let end_bin = z[gz=zend_bin]

This way, the bins are defined by my use of a new z axis definition.  This seems 
to solve my problem, since the two data sets I'm manipulating, sst and slp, 
don't have a z axis, therefore I can loop over it, but I can't generalize this 
method to variables that do have a z axis, otherwise I get conflicts over 
ambiguous axis usage in my expressions.

Is there a better way to use Ferret for more fortran-like looping over arbitrary 
indices without these kind of axis conflicts?

Thanks very much,

Chris Weaver


Department of Environmental Sciences
Rutgers University/Cook College
14 College Farm Road
New Brunswick, NJ 08901-8551
USA
(ph) 1 732 932 7902  (int) weaver@gaia.rutgers.edu



[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement