


ECOM_JSLICE: returns a vertical slice along j=jindex, ECOM file
The variable must be 4D.
USAGE:
>> [u,x,z] = ecom_jslice(cdf,var,time,jindex,[irange])
u = the selected variable
x = distance in *km* (assuming x units in netCDF file are in meters)
z = depth in m
jindex = j index along which slice is taken
irange = imin and imax indices along slice (optional). If this
argument is not supplied the default takes all the I indices
except for the first and last, which are always "land" cells.
see also ISLICE, KSLICE, ZSLICE, ZSLICEUV, KSLICEUV

0001 function [u,x,z] = ecom_jslice(cdf,var,time,jindex,irange) 0002 %ECOM_JSLICE: returns a vertical slice along j=jindex, ECOM file 0003 % 0004 % The variable must be 4D. 0005 % 0006 % USAGE: 0007 % >> [u,x,z] = ecom_jslice(cdf,var,time,jindex,[irange]) 0008 % u = the selected variable 0009 % x = distance in *km* (assuming x units in netCDF file are in meters) 0010 % z = depth in m 0011 % jindex = j index along which slice is taken 0012 % irange = imin and imax indices along slice (optional). If this 0013 % argument is not supplied the default takes all the I indices 0014 % except for the first and last, which are always "land" cells. 0015 % 0016 % see also ISLICE, KSLICE, ZSLICE, ZSLICEUV, KSLICEUV 0017 % 0018 if (nargin <4) , 0019 help jslice; 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, nx]=mexcdf('diminq',ncid,'xpos'); 0028 [name, nz]=mexcdf('diminq',ncid,'zpos'); 0029 if(exist('irange')), 0030 irange(1)=max(1,irange(1)); 0031 irange(2)=min(nx-1,irange(2)); 0032 istart=irange(1)-1; 0033 icount=irange(2)-irange(1)+1; 0034 else 0035 istart=1 0036 icount=nx-2; 0037 end 0038 u=mexcdf('varget',ncid,var,[(time-1) 0 (jindex-1) istart],... 0039 [1 nz-1 1 icount],1); 0040 if nargout>1, 0041 d=mexcdf('varget',ncid,'depth',[(jindex-1) istart],[1 icount],1); 0042 ind=find(d==-99999.); 0043 d(ind)=d(ind)*nan; 0044 u(ind,:)=u(ind,:)*NaN; 0045 sigma=mexcdf('varget',ncid,'sigma',0,nz,1); 0046 % assume we are slicing a variable defined at 0047 % at the center of the sigma level (t,s,u,v,km) 0048 sigma=0.5*(sigma(1:nz-1)+sigma(2:nz)); 0049 h1=mexcdf('varget',ncid,'h1',[(jindex-1) istart],[1 icount],1); 0050 x=cumsum(h1)/1000.; 0051 x=x*ones(1,nz-1); 0052 z=d*(sigma'); 0053 ind=find(isnan(z)); 0054 z(ind)=zeros(size(ind)); 0055 end 0056 mexcdf('close',ncid);