


DEPAVEUV computes the depth-averaged value of velocity at
a given time step of a ECOM or SCRUM model run.
Usage: [wmean,x,y]=depaveuv(cdf,[tstep],[bounds])
where: cdf = ecomsi.cdf run
var = variable to depth-average
tstep = time step (default = 1)
bounds = [imin imax jmin jmax] limits
(default = [1 nx 1 ny])
wmean = depth-averaged velocity
x = x locations of the returned array wmean
y = y locations of the returned array wmean
Example 1: [wmean,x,y]=depaveuv('ecomsi.cdf');
computes the depth-averaged velocity at the 1st time step
over the entire domain.
Example 2: [wmean,x,y]=depaveuv('ecomsi.cdf',10);
computes the depth-averaged velocity at the 10th time step
over the entire domain.
Example 3: [wmean,x,y]=depaveuv('ecomsi.cdf',10,[10 30 30 50]);
computes the depth-averaged velocity at the 10th time step
in the subdomain defined by i=10:30 and j=30:50.

0001 function [wmean,x,y]=depaveuv(cdf,tind,bounds) 0002 % DEPAVEUV computes the depth-averaged value of velocity at 0003 % a given time step of a ECOM or SCRUM model run. 0004 % 0005 % Usage: [wmean,x,y]=depaveuv(cdf,[tstep],[bounds]) 0006 % 0007 % where: cdf = ecomsi.cdf run 0008 % var = variable to depth-average 0009 % tstep = time step (default = 1) 0010 % bounds = [imin imax jmin jmax] limits 0011 % (default = [1 nx 1 ny]) 0012 % 0013 % wmean = depth-averaged velocity 0014 % x = x locations of the returned array wmean 0015 % y = y locations of the returned array wmean 0016 % 0017 % Example 1: [wmean,x,y]=depaveuv('ecomsi.cdf'); 0018 % 0019 % computes the depth-averaged velocity at the 1st time step 0020 % over the entire domain. 0021 % 0022 % Example 2: [wmean,x,y]=depaveuv('ecomsi.cdf',10); 0023 % 0024 % computes the depth-averaged velocity at the 10th time step 0025 % over the entire domain. 0026 % 0027 % Example 3: [wmean,x,y]=depaveuv('ecomsi.cdf',10,[10 30 30 50]); 0028 % 0029 % computes the depth-averaged velocity at the 10th time step 0030 % in the subdomain defined by i=10:30 and j=30:50. 0031 % 0032 % 0033 0034 if (nargin<2 | nargin>3), 0035 help depaveuv; return 0036 end 0037 0038 % turn off warnings from NetCDf 0039 ncmex('setopts',0); 0040 0041 ncid = ncmex('open', cdf, 'nowrite'); 0042 if ( ncid == -1 ) 0043 fprintf ( 'Could not open %s.\n', cdf ); 0044 return; 0045 end 0046 0047 % 0048 % Assume that a SCRUM file will always contain the 'xi_rho' dimension. 0049 % If we find it, assume that we've got a SCRUM file. 0050 [dimid, rcode] = ncmex('dimid', ncid, 'xi_rho'); 0051 if ( dimid ~= -1 ) 0052 ncmex ( 'close', ncid ); 0053 switch ( nargin ) 0054 case 2 0055 [wmean,x,y] = scrum_depaveuv(cdf,tind); 0056 case 3 0057 [wmean,x,y] = scrum_depaveuv(cdf,tind,bounds); 0058 end 0059 return; 0060 end 0061 0062 % 0063 % Assume that an ECOM file will always contain the 'xpos' dimensions. 0064 % If we find it, assume it is an ECOM file. 0065 [dimid, rcode] = ncmex('dimid', ncid, 'xpos'); 0066 if ( dimid ~= -1 ) 0067 ncmex ( 'close', ncid ); 0068 switch ( nargin ) 0069 case 2 0070 [wmean,x,y] = ecom_depaveuv(cdf,tind); 0071 case 3 0072 [wmean,x,y] = ecom_depaveuv(cdf,tind); 0073 end 0074 return; 0075 end 0076 0077 0078 % 0079 % If we get this far, then neither file was recognizable. 0080 fprintf ( 'I can''t make sense out of %s???\n', cdf ); 0081 help depaveuv; 0082 return;