Documentation of atlev


Global Index (short | long) | Local contents | Local Index (short | long)


Function Synopsis

out1 = atlev(dat, lev, ps, hyam, hybm, P0);

Help text


  out1 = atlev(dat, lev, ps, hyam, hybm, P0);


Cross-Reference Information

This function calls This function is called by

Listing of function atlev

function out1 = atlev(dat, lev, ps, hyam, hybm, P0);

dims = ndims(dat);

if (dims == 3);                %  Assume no time dimension

  [nlev, nlat, nlon] = size(dat);
  dat = reshape(dat, nlev, nlat*nlon);
  ps = reshape(ps, 1, nlat*nlon);

elseif (dims == 4);            %  Assume time dependence is first

  [ntim, nlev, nlat, nlon] = size(dat);
  dat = reshape(shiftdim(dat, 1), nlev, nlat*nlon*ntim);
  ps = reshape(shiftdim(ps, 1), 1, nlat*nlon*ntim);

end;

[nvpts, nhpts] = size(dat);

if isvector(lev);
  if size(lev, 1) == 1;
    lev = lev';
  end;
end;

nvpt_out = length(lev);

plevs = P0 * hyam * ones(1, nhpts) + hybm * ps;
lev = lev*100;

out1 = NaN * ones(nvpt_out, nhpts);
for i = 1:nhpts
  out1(:, i) = interp1(plevs(:,i), dat(:,i), lev);
end

if dims == 3;
  if (nvpt_out == 1);
    out1 = reshape(out1, nlat, nlon);
  else
    out1 = reshape(out1, nvpt_out, nlat, nlon);
  end
elseif dims == 4;
  if (nvpt_out == 1);
    out1 = shiftdim(reshape(out1, nlat, nlon, ntim), 2);
  else
    out1 = shiftdim(reshape(out1, nvpt_out, nlat, nlon, ntim), 3);
  end
end