Home > atmlab > geographical > full_pressure_levels.m

full_pressure_levels

PURPOSE ^

% FULL_PRESSURE_LEVELS Calculate Pressure matrix based on surface pressure

SYNOPSIS ^

function P = full_pressure_levels(sp,A,B)

DESCRIPTION ^

% FULL_PRESSURE_LEVELS Calculate Pressure matrix based on surface pressure

 Calculate Pressure matrix based on surface pressure and number of model
 levels. 

 Note: Assumes the bottom of the atmosphere is at level 60/91
       A and B coincide to half pressure levels, and the output is in full pressure levels

 IN
     sp     [%f,...]              surface pressure matrix (2D)
     A,B    %f                    A-B coefficients values vecs on the
                                  pressure interval levels.
                                  i.e. length(A) = nlvls-1 

 OUT
     out = p(lvls,:,:)            Pressure values on model levels

 USAGE: P = full_pressure_levels(sp,A,B)

 $Id: full_pressure_levels.m 7095 2011-08-03 06:32:00Z seliasson $
 Created Marston Johnston

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

full_pressure_levels.m

SOURCE CODE ^

0001 function P = full_pressure_levels(sp,A,B)
0002 %% FULL_PRESSURE_LEVELS Calculate Pressure matrix based on surface pressure
0003 %
0004 % Calculate Pressure matrix based on surface pressure and number of model
0005 % levels.
0006 %
0007 % Note: Assumes the bottom of the atmosphere is at level 60/91
0008 %       A and B coincide to half pressure levels, and the output is in full pressure levels
0009 %
0010 % IN
0011 %     sp     [%f,...]              surface pressure matrix (2D)
0012 %     A,B    %f                    A-B coefficients values vecs on the
0013 %                                  pressure interval levels.
0014 %                                  i.e. length(A) = nlvls-1
0015 %
0016 % OUT
0017 %     out = p(lvls,:,:)            Pressure values on model levels
0018 %
0019 % USAGE: P = full_pressure_levels(sp,A,B)
0020 %
0021 % $Id: full_pressure_levels.m 7095 2011-08-03 06:32:00Z seliasson $
0022 % Created Marston Johnston
0023 
0024 sp = squeeze(sp);
0025 assert(ndims(sp)==2,'atmlab:full_pressure_levels:BadInput','sp must be 2D')
0026 nlev = length(A)-1;
0027 ph = zeros([size(sp),nlev+1]);
0028 P = zeros([nlev,size(sp)]);
0029 
0030 for lev = nlev:-1:1 % begin from bottom
0031     ph(:,:,lev+1) = A(lev+1) + B(lev+1)*sp(:,:);
0032     ph(:,:,lev) = A(lev) + B(lev)*sp(:,:);
0033     P(lev,:,:) = (ph(:,:,lev) + ph(:,:,lev+1))*0.5; % Full pressure level
0034 end

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005