NCL has numerous "dim_*" [dim_*_Wrap] functions.
Generally speaking, they operate on the rightmost dimension ... for
efficiency.
This may require reshaping/reordering the arrays using the variables
named dimensions
Let's say MISR_ASO_2002 (time,lat,lon) [, 2004 and 2006]
[1] if the times on each file are ntim1,ntim2,ntim3
NTIM = ntim1 + ntim2 + ntim3
x = new ( (/ NTIM,nlat,mlon/), typeof(MISR_ASO_2002),
getFillValue(MISR_ASO_2002) )
x(0:ntim1-1,:,:) = (/ MISR_ASO_2002 /)
nStrt = ntim1
nLast = ntim1+ntim2-1
x(nStrt:nLast,:,:) = (/ MISR_ASO_2004 /)
nStrt = nLast+1
nLast = nLast+ ntim2-1
x(nStrt:nLast,:,:) = (/ MISR_ASO_2004 /)
x!0 = "time"
x!1 = "lat"
x!2 = "lon"
MISR = dim_avg(x(lat|:,lat|:,lon|:))
[2] This *may* give a different answer than [1] .... do u know why? :-)
MISR = (dim_avg(MISR_ASO_2002(lat|:,lon|:,time|:)) \
+ dim_avg(MISR_ASO_2003(lat|:,lon|:,time|:)) \
+ dim_avg(MISR_ASO_2004(lat|:,lon|:,time|:)) )/3
[3] or if they are on files and time is unlimites
ncra MISR_ASO_2002.nc MISR_ASO_2003.nc MISR_ASO_2006.nc
MISR_ASO_FOO.nc
Michael Tosca wrote:
> I have a set of arrays (all same month) that contain lat and lon
> points. I wish to compute an average value for each lat/lon point from
> all the arrays, however, some points (different in each array dataset)
> contain missing values, so that when i just add the arrays and divide
> by 'n' any lat/lon point that has at least ONE missing value in one of
> the arrays is essentially "thrown out".
>
> My question is: how can i average over the arrays and simply disregard
> a point when it has a missing value and use the remaining points to
> compute the average. For example, if I have 10 arrays, and one lat/lon
> point only has a vlue in 4 of the 10 arrays, I want the average value
> of that point in the resulting dataset to be an average of the 4
> available data. The "avg" function doesn't work because it averages
> over a single array, whereas I want to average between several arrays.
> Here's a sample of the code I'm using to average:
>
> MISR_ASO_ElNino = MISR_ASO_2002
> MISR_ASO_ElNino = (MISR_ASO_2002 + MISR_ASO_2004 + MISR_ASO_2006 ) / 3
>
> Thanks!
> -Mike
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
-- ====================================================== Dennis J. Shea tel: 303-497-1361 | P.O. Box 3000 fax: 303-497-1333 | Climate Analysis Section | Climate & Global Dynamics Div. | National Center for Atmospheric Research | Boulder, CO 80307 | USA email: shea 'at' ucar.edu | ====================================================== _______________________________________________ ncl-talk mailing list ncl-talk_at_ucar.edu http://mailman.ucar.edu/mailman/listinfo/ncl-talkReceived on Wed Jun 04 2008 - 13:56:25 MDT
This archive was generated by hypermail 2.2.0 : Wed Jun 04 2008 - 15:43:54 MDT