Documentation of area_mean

Global Index (all files) (short | long) | Local Index (files in subdir) (short | long)

Function Synopsis

[a2,lat2,lon2] = area_mean(a, inc, lat, lon);

Help text

  [a2, lat2, lon2] = area_mean(in1, inc, lat, lon);

  Thin will condense the matrix in1 by averaging
  over every inc element in each direction.  This
  program assumes the input data is three-
  dimensional, with time, lat, lon, as the dimensions.

Cross-Reference Information

This function calls

Listing of function area_mean

function [a2,lat2,lon2] = area_mean(a, inc, lat, lon);

[ntim, nlat, nlon] = size(a);
nlat2 = floor(nlat/inc(1));
nlon2 = floor(nlon/inc(2));
a2 = repmat(NaN, [ntim, nlat2, nlon2]);

%  Average the data
for i = 1:nlat2;
  ind1 = inc(1)*(i-1)+[1:inc(1)];
  for j = 1:nlon2;
    ind2 = inc(2)*(j-1)+[1:inc(2)];
    a2(:,i,j) = squeeze(mean2(mean2(shiftdim(a(:,ind1,ind2),1))))';

%  Do the same for lat and lon
if nargin == 4;
  lat2 = repmat(NaN, [nlat2, 1]);
  for i = 1:nlat2;
    ind1 = inc(1)*(i-1)+[1:inc(1)];
    lat2(i) = mean(lat(ind1));

  lon2 = repmat(NaN, [nlon2, 1]);
  for i = 1:nlon2;
    ind1 = inc(2)*(i-1)+[1:inc(2)];
    lon2(i) = mean(lon(ind1));