Global Index (short | long) | Local contents | Local Index (short | long)
out1 = atlev(dat, lev, ps, hyam, hybm, P0);
out1 = atlev(dat, lev, ps, hyam, hybm, P0);
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