


ECOM_ISLICE returns a vertical slice along i=iindex
from an ECOMxx.CDF or POM.CDF file.
The variable must be a function of x, y, z and time: (e.g. salinity)
USAGE: [u,y,z]=islice(cdf,var,time,iindex,[jrange])
u = the selected variable
y = distance in *km* (assuming y units in netCDF file are in meters)
z = depth in m
iindex = I index along which slice is taken
jrange = jmin and jmax indices along slice (optional). If this
argument is not supplied the default takes all the J indices
except for the first and last, which are always "land" cells.
see also JSLICE, KSLICE, ZSLICE, ZSLICEUV, KSLICEUV

0001 function [u,y,z] =ecom_islice(cdf,var,time,iindex,jrange) 0002 %ECOM_ISLICE returns a vertical slice along i=iindex 0003 % from an ECOMxx.CDF or POM.CDF file. 0004 % 0005 % The variable must be a function of x, y, z and time: (e.g. salinity) 0006 % USAGE: [u,y,z]=islice(cdf,var,time,iindex,[jrange]) 0007 % u = the selected variable 0008 % y = distance in *km* (assuming y units in netCDF file are in meters) 0009 % z = depth in m 0010 % iindex = I index along which slice is taken 0011 % jrange = jmin and jmax indices along slice (optional). If this 0012 % argument is not supplied the default takes all the J indices 0013 % except for the first and last, which are always "land" cells. 0014 % 0015 % 0016 % see also JSLICE, KSLICE, ZSLICE, ZSLICEUV, KSLICEUV 0017 % 0018 if (nargin < 4) , 0019 help islice; return 0020 end 0021 mexcdf('setopts',0); 0022 ncid=mexcdf('open',cdf,'nowrite'); 0023 if(ncid==-1), 0024 disp(['file ' cdf ' not found']) 0025 return 0026 end 0027 [name, ny]=mexcdf('diminq',ncid,'ypos'); 0028 [name, nz]=mexcdf('diminq',ncid,'zpos'); 0029 if(exist('jrange')), 0030 jrange(1)=max(1,jrange(1)); 0031 jrange(2)=min(ny-1,jrange(2)); 0032 jstart=jrange(1)-1; 0033 jcount=jrange(2)-jrange(1)+1; 0034 else 0035 jstart=1 0036 jcount=ny-2; 0037 end 0038 u=mexcdf('varget',ncid,var,[(time-1) 0 jstart (iindex-1)],... 0039 [1 nz-1 jcount 1],1); 0040 if nargout>1, 0041 d=mexcdf('varget',ncid,'depth',[jstart (iindex-1)],[jcount 1],1); 0042 ind=find(d==-99999.); 0043 d(ind)=d(ind)*0; 0044 u(ind,:)=u(ind,:)*NaN; 0045 sigma=mexcdf('varget',ncid,'sigma',0,nz,1); 0046 sigma=0.5*(sigma(1:nz-1)+sigma(2:nz)); 0047 h2=mexcdf('varget',ncid,'h2',[jstart (iindex-1)],[jcount 1],1); 0048 y=cumsum(h2)/1000.; 0049 y=y*ones(1,nz-1); 0050 z=d*(sigma'); 0051 ind=find(isnan(z)); 0052 z(ind)=zeros(size(ind)); 0053 end 0054 mexcdf('close',ncid);