Documentation of getnc_ccm


Global Index (all files) (short | long) | Local Index (files in subdir) (short | long)


Function Synopsis

[varargout] = getnc(filin, varn, lims, lev, tim);

Help text


  [varn_out] = getnc(filin, varn, lims, lev, tim);
  [varn_out, lat, lon] = getnc(filin, varn, lims, lev, tim);
  [varn_out, lat, lon, level] = getnc(filin, varn, lims, lev, tim);

  Input variables:

  filin = full pathname of NETCDF file to read
  varn = variable names (can be cell array)
  lims = limits over which to read
  lev = number index of the level you want (optional)
  tim = time index

  Output variables:

  varargout = list of variables to output, in the same
              order as varn
  lat = latitude 
  lon = longitude 
  level = actual levels 


Cross-Reference Information

This function calls

Listing of function getnc_ccm

function [varargout] = getnc(filin, varn, lims, lev, tim);

if isstr(varn); tem{1} = varn; varn = tem; end
nvars = length(varn);

%  Allow for output of lat, lon, level
if ~iselement(nargout, nvars+[0 2 3])
  error('Number of output arguments do not match number of input arguments')
end


nc = netcdf(filin, 'nowrite');

  %  Get lat, lon, level, and range
  lat = nc{'lat',1}(:);
  lon = nc{'lon',1}(:);
  level = nc{'lev'}(:);

  [xk, yk] = keep_var(lims, lon, lat);

  %  Cycle through input variables
  for i = 1:nvars;

    varnam = varn{i};

    if length(size(var(nc, varnam))) == 3;
      varargout{i} = nc{varnam}(tim, yk, xk);
    elseif length(size(var(nc, varnam))) == 4;
      varargout{i} = nc{varnam, 1}(tim, lev, yk, xk);
    end
  end

nc = close(nc);

%  If lat and lon are output, send those to varargout
if nargout >= nvars+2;
  varargout{nvars+1} = lat(yk);
  varargout{nvars+2} = lon(xk);
end
if nargout == nvars+3;
  varargout{nvars+3} = level(lev);
end