Home > omviz > ksliceuv.m

ksliceuv

PURPOSE ^

KSLICEUV

SYNOPSIS ^

function [w,x,y]=ksliceuv(cdf,time,klevel)

DESCRIPTION ^

  KSLICEUV
     returns a matrix containing a horizontal slice of
     velocity at a given sigma level (K level)
     at a given time step from an ECOMSI.CDF file

       USAGE: [u,x,y]=ksliceuv(cdf,time,klevel)

   where klevel is a sigma level (1 is the surface level)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [w,x,y]=ksliceuv(cdf,time,klevel)
0002 %  KSLICEUV
0003 %     returns a matrix containing a horizontal slice of
0004 %     velocity at a given sigma level (K level)
0005 %     at a given time step from an ECOMSI.CDF file
0006 %
0007 %       USAGE: [u,x,y]=ksliceuv(cdf,time,klevel)
0008 %
0009 %   where klevel is a sigma level (1 is the surface level)
0010 %
0011 if (nargin<2 | nargin>3),
0012   help ksliceuv; return
0013 end
0014 mexcdf('setopts',0);
0015 ncid=mexcdf('open',cdf,'nowrite');
0016 if(ncid==-1),
0017   disp(['file ' cdf ' not found'])
0018   return
0019 end
0020 [name, nx]=mexcdf('diminq',ncid,'xpos');
0021 [name, ny]=mexcdf('diminq',ncid,'ypos');
0022 [name, nz]=mexcdf('diminq',ncid,'zpos');
0023 if(nargout==3),
0024   x=mexcdf('varget',ncid,'x',[0 0],[ny nx]);
0025   y=mexcdf('varget',ncid,'y',[0 0],[ny nx]);
0026 end
0027 depth=mexcdf('varget',ncid,'depth',[0 0],[ny nx]);
0028 ang=mexcdf('varget',ncid,'ang',[0 0],[ny nx]);
0029 if(isempty(ang)),
0030   ang=zeros(size(depth)),
0031 end;
0032 u=mexcdf('varget',ncid,'u',[(time-1) klevel-1 0 0],[1 1 ny nx],1); %profile
0033 v=mexcdf('varget',ncid,'v',[(time-1) klevel-1 0 0],[1 1 ny nx],1); %profile
0034 mexcdf('close',ncid);
0035 %
0036 % average u and v to center of grid cells
0037 %
0038 u=u(1:nx-1,:)+.5*diff(u);
0039 u(nx,:)=u(nx-1,:);
0040 v=v(:,1:ny-1)+.5*diff(v')';
0041 v(:,ny)=v(:,ny-1);
0042 w=u+sqrt(-1)*v;
0043  
0044 dind=find(depth==-99999);
0045 w(dind)=w(dind)*NaN;
0046 %
0047 % rotate into east/north components
0048 w=w.*exp(sqrt(-1)*ang);

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