Home > omviz > jslice.m

jslice

PURPOSE ^

JSLICE: returns horizontal slice at particular layer.

SYNOPSIS ^

function [u,x,z]=jslice(cdf,var,time,jindex,irange)

DESCRIPTION ^

 JSLICE:  returns horizontal slice at particular layer.

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

 USAGE: 
 >> [u,x,z]=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 JSLICE, KSLICE, ZSLICE, ZSLICEUV, KSLICEUV

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [u,x,z]=jslice(cdf,var,time,jindex,irange)
0002 % JSLICE:  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,x,z]=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 %
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,x,z] = scrum_jslice ( cdf, var, time, jindex );
0041         case 5
0042             [u,x,z] = scrum_jslice ( cdf, var, time, jindex, irange );
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,x,z] = ecom_jslice ( cdf, var, time, jindex );
0056         case 5
0057             [u,x,z] = ecom_jslice ( cdf, var, time, jindex, irange );
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