Home > omviz > islice.m

islice

PURPOSE ^

ISLICE: returns horizontal slice at particular layer.

SYNOPSIS ^

function [u,y,z]=islice(cdf,var,time,iindex,jrange)

DESCRIPTION ^

 ISLICE:  returns horizontal slice at particular layer.

 The variable must be 4D.  Works on either ECOM or SCRUM files.

 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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [u,y,z]=islice(cdf,var,time,iindex,jrange)
0002 % ISLICE:  returns horizontal slice at particular layer.
0003 %
0004 % The variable must be 4D.  Works on either ECOM or SCRUM files.
0005 %
0006 % USAGE:
0007 % >> [u,y,z]=islice(cdf,var,time,iindex,[jrange])
0008 %      u = the selected variable
0009 %      y = distance in *km* (assuming y units in netCDF file are in meters)
0010 %      z = depth in m
0011 %      iindex = I index along which slice is taken
0012 %      jrange = jmin and jmax indices along slice (optional).  If this
0013 %           argument is not supplied the default takes all the J indices
0014 %           except for the first and last, which are always "land" cells.
0015 %
0016 %
0017 % see also JSLICE, KSLICE, ZSLICE, ZSLICEUV, KSLICEUV
0018 %
0019 if ( nargin<4 | nargin>5),
0020   help kslice; return
0021 end
0022 
0023 % turn off warnings from NetCDf
0024 ncmex('setopts',0);
0025 
0026 ncid = ncmex('open', cdf, 'nowrite');
0027 if ( ncid == -1 )
0028     fprintf ( 'Could not open %s.\n', cdf );
0029     return;
0030 end
0031 
0032 %
0033 % Assume that a SCRUM file will always contain the 'xi_rho' dimension.
0034 % If we find it, assume that we've got a SCRUM file.
0035 [dimid, rcode] = ncmex('dimid', ncid, 'xi_rho');
0036 if ( dimid ~= -1 )
0037     ncmex ( 'close', ncid );
0038     switch ( nargin )
0039         case 4
0040             [u,y,z] = scrum_islice ( cdf, var, time, iindex );
0041         case 5
0042             [u,y,z] = scrum_islice ( cdf, var, time, iindex, jrange );
0043     end
0044     return;
0045 end
0046 
0047 %
0048 % Assume that an ECOM file will always contain the 'xpos' dimensions.
0049 % If we find it, assume it is an ECOM file.
0050 [dimid, rcode] = ncmex('dimid', ncid, 'xpos');
0051 if ( dimid ~= -1 )
0052     ncmex ( 'close', ncid );
0053     switch ( nargin )
0054         case 4
0055             [u,y,z] = ecom_islice ( cdf, var, time, iindex );
0056         case 5
0057             [u,y,z] = ecom_islice ( cdf, var, time, iindex, jrange );
0058     end
0059     return;
0060 end
0061 
0062 
0063 %
0064 % If we get this far, then neither file was recognizable.
0065 fprintf ( 'I can''t make sense out of %s???\n\n', cdf );
0066 help islice;
0067 return;

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