Home > omviz > emean.m

emean

PURPOSE ^

function emean(cdfin,cdfout,tind,tout)

SYNOPSIS ^

function emean(cdfin,cdfout,tind,tout)

DESCRIPTION ^

function emean(cdfin,cdfout,tind,tout)

 EMEAN computes mean elevation over time steps TIND
    of the ecomsi model run CDFIN and saves the resulting
    mean field to time step TOUT in file CDFOUT.
     
  tind is the indices of time steps to average over (1 is first step)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function emean(cdfin,cdfout,tind,tout)
0002 %function emean(cdfin,cdfout,tind,tout)
0003 %
0004 % EMEAN computes mean elevation over time steps TIND
0005 %    of the ecomsi model run CDFIN and saves the resulting
0006 %    mean field to time step TOUT in file CDFOUT.
0007 %
0008 %  tind is the indices of time steps to average over (1 is first step)
0009 %
0010 disp('averaging elevation')
0011   varin='elev';
0012   varout='elev';
0013 cdfid1=mexcdf('open',cdfin,'nowrite');
0014 cdfid2=mexcdf('open',cdfout,'write');
0015 
0016 [nam,nx]=mexcdf('diminq',cdfid1,'xpos');
0017 [nam,ny]=mexcdf('diminq',cdfid1,'ypos');
0018 [nam,nz]=mexcdf('diminq',cdfid1,'zpos');
0019 
0020   etot=zeros(nx,ny);
0021   for i=tind,
0022     e=mexcdf('varget',cdfid1,varin,[i-1 0 0],[1 ny nx]);
0023     etot=etot+e;
0024   end
0025   emean=etot/length(tind);
0026 % store mean elevation field in time step TOUT of CDFOUT
0027   mexcdf('varput',cdfid2,varout,[tout-1  0 0],[1  ny nx],emean);
0028 
0029 mexcdf('close',cdfid1);
0030 mexcdf('close',cdfid2);

Generated on Thu 01-Dec-2005 08:50:35 by m2html © 2003