% ------------------------------------------------------------------------
% Compute equivalent potential temperature
%
% Author:  Xin-Zhong Liang @ UMD
% Coded:   2012/08/25
%
% ------------------------------------------------------------------------
function [theta_e] = theta_e(temp, pres, wvmr)
%
%  Input:
%     temp = temperature [K]
%     pres = pressure [Pa]
%     wvmr = water vapor mixing ratio [kg/kg]
%
%  Output:
%     theta_e = potential temperature [K]
%
%  set constants
%
   p0 = 100000.;         % standard reference pressure [Pa]
   rd = 287.04;          % gas constant for dry air [J/kg/K]
   cp = 1005.7;          % specific heat of dry air [J/kg/K]
   lv = 2.501E6;         % latent heat of evaporation [J/kg] 
%
%  compute equivalent potential temperature
%
   temp_e = temp + (lv/cp)*wvmr; 
   theta_e = temp_e .* (p0 ./ pres) .^ (rd/cp);
%
%  all done
%
end