thermo#
Dry Variables#
-
float sharp::theta(float pressure, float temperature, float ref_pressure = THETA_REF_PRESSURE)#
Compute the potential temperature.
- Author
John Hart - NSSFC KCMO / NWSSPC OUN
Returns the potential temperature in Kelvin of a parcel given its pressure in Pascals and temperature in Kelvin. The final argument is the reference level, which is usually 100000.0 Pa, conveniently also called sharp::THETA_REF_PRESSURE.
- Parameters:
pressure – (Pa)
temperature – (K)
ref_pressure – (Pa)
- Returns:
potential_temperature (K)
-
float sharp::theta_level(float potential_temperature, float temperature)#
Comute the pressure level given potential temperature and temperature.
- Author
John Hart - NSSFC KCMO / NWSSPC OUN
Returns the pressure level in Pascals (Pa) of a parcel given the potential temperature in Kelvin and the temperature of the parcel in Kelvin.
- Parameters:
potential_temperature – (K)
temperature – (K)
- Returns:
pressure (Pa)
-
float sharp::lapse_rate(HeightLayer layer_agl, const float height[], const float temperature[], const std::ptrdiff_t N)#
compute the lapse rate over the given sharp::HeightLayer (AGL)
- Author
Kelton Halbert - NWS Storm Prediction Center
Computes the lapse rate over a given sharp::HeightLayer above-ground-level. This routine handles converting AGL to MSL by adding the surface height value to the layer.
- Parameters:
layer_agl – (meters AGL)
height – (meters MSL)
temperature – (K)
N – (length of arrays)
- Returns:
Temperature Lapse Rate (K/km)
-
float sharp::lapse_rate(PressureLayer layer, const float pressure[], const float height[], const float temperature[], const std::ptrdiff_t N)#
compute the lapse rate over the given sharp::PressureLayer
- Author
Kelton Halbert - NWS Storm Prediction Center
Computes the lapse rate over a given sharp::PressureLayer. This routine handles converting the pressure layer into a height layer, and then calles the sharp::HeightLayer implementation of this routine.
- Parameters:
layer – (Pa)
pressure – (Pa)
height – (meters MSL)
temperature – (K)
N – (length of arrays)
- Returns:
Temperature Lapse Rate (K/km)
-
float sharp::lapse_rate_max(HeightLayer layer_agl, const float depth, const float height[], const float temperature[], const std::ptrdiff_t N, HeightLayer *max_lyr = nullptr)#
Find the maximum lapse rate within a specified layer/depth (AGL).
- Author
Kelton Halbert - NWS Storm Prediction Center
Given a layer of the atmosphere (e.g. 2 - 6 km), find the maximum lapse rate over the provided depth (e.g. 2 km) within that given layer. Returns the maximum lapse rate, with the optional ability to return the layer that lapse rate exists within.
- Parameters:
layer_agl – (meters AGL)
depth – (meters)
height – (meters MSL)
temperature – (K)
N – (length of arrays)
max_lyr – (The sharp::HeightLayer of the max lapse rate)
- Returns:
Maximum Temperature Lapse Rate (K/km)
-
float sharp::lapse_rate_max(PressureLayer layer, const float depth, const float pressure[], const float height[], const float temperature[], const std::ptrdiff_t N, PressureLayer *max_lyr = nullptr)#
Find the maximum lapse rate within a specified layer/depth (Pres)
- Author
Kelton Halbert - NWS Storm Prediction Center
Given a layer of the atmisphere (e.g. 800 hPa - 500 hPa), find the maximum lapse rate over the provided depth (e.g. 100 hPa) within that given layer. Returns the maximum lapse rate, with the optional ability to return the layer that lapse rate exists within.
- Parameters:
layer – (Pa)
depth – (Pa)
pressure – (Pa)
height – (meters MSL)
temperature – (K)
N – (length of arrays)
max_lyr – (The sharp::PressureLayer of the max lapse rate)
- Returns:
Maximum Temperature Lapse Rate (K/km)
Dry Ascent#
-
void sharp::drylift(float pressure, float temperature, float dewpoint, float &pressure_at_lcl, float &temperature_at_lcl)#
Lift a parcel dry adiabatically to its Lifted Condensation Level (LCL).
- Author
John Hart - NSSFC KCMO / NWSSPC OUN
Given a parcel’s initial pressure (Pa), temperature (K), and dewpoint temperature (K), lift the parcel dry adiabatically to its Lifted Condensation Level and store the resulting LCL pressure (Pa) and LCL temperature (K) in the variables passed by reference to the routine.
The LCL temperature is computed using an approximation. See the sharp::lcl_temperature documentation for more information.
- Parameters:
pressure – (Pa)
temperature – (K)
dewpoint – (K)
pressure_at_lcl – (Pa)
temperature_at_lcl – (K)
-
float sharp::lcl_temperature(float temperature, float dewpoint)#
Compute the temperature of the LCL.
- Author
Kelton Halbert - NWS Storm Prediction Center
Computes the temperature of a parcels LCL in degres Kelvin given the parcel temperature and dewpoint in Kelvin.
This is implemented as in Bolton (1980) eq 15, and is considered to be within a 10th of a degree of the more exact iterative formula.
- Parameters:
temperature – (K)
dewpoint – (K)
- Returns:
lcl_temperature (K)
Moist Variables#
-
float sharp::mixratio(float q)#
Compute the water vapor mixing ratio from specific humidity.
- Author
Kelton Halbert - NWS Storm Prediction Center
Returns the water vapor mixing ratio in kg/kg given the specific humidity in kg/kg.
- Parameters:
q – (kg/kg)
- Returns:
mixratio (kg/kg)
-
float sharp::mixratio(float pressure, float temperature)#
Compute the water vapor mixing ratio.
- Author
Kelton Halbert - NWS Storm Prediction Center
Returns the water vapor mixing ratio in kg/kg given the environmental pressure in Pascals (Pa) and a temperature (dry-bulb or dewpoint) in Kelvin.
This is computed by calling sharp::vapor_pressure, which uses the Bolton (1980) equations.
- Parameters:
pressure – (Pa)
temperature – (K)
- Returns:
mixratio (kg/kg)
-
float sharp::mixratio_ice(float pressure, float temperature)#
Compute the ice water mixing ratio.
- Author
Kelton Halbert - NWS Storm Prediction Center
Returns the ice water mixing ratio in kg/kg given the environmental pressure in Pascals (Pa) and a temperature (dry-bulb or dewpoint) in Kelvin.
This is computed by calling sharp::vapor_pressure_ice, which uses the Bolton (1980) equations.
- Parameters:
pressure – (Pa)
temperature – (K)
- Returns:
mixratio (kg/kg)
-
float sharp::vapor_pressure(float pressure, float temperature)#
Compute the vapor pressure over liquid water.
- Author
Kelton Halbert - NWS Storm Prediction Center
Computes the vapor pressure (or saturation vapor pressure) in Pascals (Pa) over liquid water given the temperature in Kelvin (or dewpoint temperature in Kelvin). The air pressure is used as a minimum floor for extremely cold temperatures and low pressures.
This function uses the formulation by Bolton (1980), and is accurate to 0.3% for the temperature range of -35C <= T <= 35 C
- Parameters:
pressure – (Pa)
temperature – (K)
- Returns:
vapor_pressure (Pa)
-
float sharp::vapor_pressure_ice(float pressure, float temperature)#
Compute the vapor pressure over ice.
- Author
Kelton Halbert - NWS Storm Prediction Center
Computes the vapor pressure (or saturation vapor pressure) in Pascals (Pa) over ice given the temperature in Kelvin (or dewpoint temperature in Kelvin). The air pressure is used as a minimum floor for extremely cold temperatures and low pressures.
This function uses the formulation by Bolton (1980), and is accurate to 0.3% for the temperature range of -35C <= T <= 35C
- Parameters:
pressure – (Pa)
temperature – (K)
- Returns:
vapor_pressure (Pa)
-
float sharp::specific_humidity(float rv)#
Compute specific humidity from a mixing ratio.
- Author
Kelton Halbert - NWS Storm Prediction Center
Returns the specific humidity given the mixing ratio.
- Parameters:
rv – (kg/kg)
- Returns:
specific_humidity (unitless)
-
float sharp::relative_humidity(float pressure, float temperature, float dewpoint)#
Compute the relative humidity of water vapor with respect to liquid.
- Author
Kelton Halbert - NWS Storm Prediction Center
Compute the relative humidity with respect to liquid water given an input pressure (Pa), temperature (K), and dewpoint temperature (K). NOTE: The presssure value is only used to ensure sane values of vapor pressure at extremely cold temperatures/low pressures. If you do not want or need this behavior, you can pass in something like sharp::THETA_REF_PRESSURE instead.
- Parameters:
pressure – (Pa)
temperature – (K)
dewpoint – (K)
- Returns:
Relative Humidity (fraction, unitless)
-
float sharp::temperature_at_mixratio(float wv_mixratio, float pressure)#
Compute the temperature at a given water vapor mixing ratio and pressure level.
- Author
Kelton Halbert - NWS Storm Prediction Center
Computes the temperature in Kelvin of air at the given water vapor mixing ratio in kg/kg and the air pressure in Pa.
The routine is implemented as in Bolton (1980) eq 11, and is considered to be accurate to 0.03 for -35C <= T <= 35C
- Parameters:
wv_mixratio – (kg/kg)
pressure – (Pa)
- Returns:
temperature (K)
-
float sharp::virtual_temperature(float temperature, float rv, float rl = 0.0f, float ri = 0.0f)#
Compute the full virtual temperature.
- Author
Kelton Halbert - NWS Storm Prediction Center
Returns the virtual temperature in Kelvin given the dry-bulb temperature in Kelvin, the water vapor mixing ratio (rv) in kg/kg, the liquid water mixing ratio (rl) in kg/kg, and the ice water mixing ratio (ri) in kg/kg.
For convenience, the rl and ri terms have a default value of zero to easily support returning just the virtual temperature from water vapor.
- Parameters:
temperature – (K)
rv – (kg/kg)
rl – (kg/kg)
ri – (kg/kg)
- Returns:
virtual_temperature (K)
-
float sharp::buoyancy(const float pcl_temperature, const float env_temperature)#
compute buoyancy given parcel and environment temperatures
- Author
Kelton Halbert - NWS Storm Prediction Center
- Parameters:
pcl_temperature – (K)
env_temperature – (K)
- Returns:
buoyancy (m/s^2)
-
void sharp::buoyancy(const float pcl_temperature[], const float env_temperature[], float buoy_arr[], std::ptrdiff_t N)#
Compute buoyancy given arrays of parcel & environment temperatures.
- Author
Kelton Halbert - NWS Storm Prediction Center
- Parameters:
pcl_temperature – (K)
env_temperature – (K)
buoy_arr – Output array to fill with buoyancy
N – Length of arrays
-
float sharp::thetae(float pressure, float temperature, float dewpoint)#
Compute the equivalent potential temperature.
- Author
John Hart - NSSFC KCMO / NWSSPC OUN
Compute the equivalent potential temperature (K) given the pressure (Pa), temperature (K), and dewpoint (K). The equivalent potential temperature is computed as in Bolton 1980. It was found in Davies-Jones 2009 that this is the most accurate non-iterative formulation of ThetaE.
Bolton 1980: https://doi.org/10.1175/1520-0493(1980)108%3C1046:TCOEPT%3E2.0.CO;2 Davies-Jones 2009: https://doi.org/10.1175/2009MWR2774.1
- Parameters:
pressure – (Pa)
temperature – (K)
dewpoint – (K)
- Returns:
equivalent_potential_temperature (K)
-
template<typename Lft>
float sharp::wetbulb(Lft lifter, float pressure, float temperature, float dewpoint)# Compute the wetbulb temperature.
- Author
John Hart - NSSFC KCMO / NWSSPC OUN
Compute the wet bulb temperature (K) given the pressure (Pa), temperature (K), and dewpoint (K).
First, it lifts a parcel with the given pressure, temperature, and dewpoint temperature to its Lifted Condensation Level (LCL). To compute the temperature and pressure of the LCL, an approximation is used. See the sharp::lcl_temperature documentation for more information.
After the parcel has reached the LCL, the lifter passed in lowers the parcel to its initial pressure level along a moist adiabat.
- Parameters:
lifter – (cm1, wobf)
pressure – (Pa)
temperature – (K)
dewpoint – (K)
- Returns:
wetbulb_temperature (K)
-
float sharp::wetbulb(lifter_wobus lifter, float pressure, float temperature, float dewpoint)#
-
float sharp::wetbulb(lifter_cm1 lifter, float pressure, float temperature, float dewpoint)#
-
template<typename Lft>
float sharp::theta_wetbulb(Lft lifter, float pressure, float temperature, float dewpoint)# Compute the wetbulb potential temperature.
- Author
John Hart - NSSFC KCMO / NWSSPC OUN
Compute the wet bulb potential temperature (K) given the pressure (Pa), temperature (K), and dewpoint (K).
First, it lifts a parcel with the given pressure, temperature, and dewpoint temperature to its Lifted Condensation Level (LCL). To compute the temperature and pressure of the LCL, an approximation is used. See the sharp::lcl_temperature documentation for more information.
After the parcel has reached the LCL, the lifter passed in lowers the parcel to the standard reference pressure level (1000.0 hPa) along a moist adiabat.
- Parameters:
lifter – (wobf, cm1)
pressure – (Pa)
temperature – (K)
dewpoint – (K)
- Returns:
wetbulb_potential_temperature (K)
-
float sharp::theta_wetbulb(lifter_wobus lifter, float pressure, float temperature, float dewpoint)#
-
float sharp::theta_wetbulb(lifter_cm1 lifter, float pressure, float temperature, float dewpoint)#
Moist Ascent#
-
enum class sharp::adiabat : int#
Defines the kinds of moist adiabats used by sharp::moist_adiabat_cm1.
Values:
-
enumerator pseudo_liq#
Pseudoadiabatic considering only liquid water.
-
enumerator adiab_liq#
Adiabatic considering only liquid water.
-
enumerator pseudo_ice#
Pseudoadiabatic considering liquid water + ice.
-
enumerator adiab_ice#
Adiabatic considering liquid water + ice.
-
enumerator END#
-
enumerator pseudo_liq#
-
float sharp::wobf(float temperature)#
Computes the difference between the wet-bulb potential temperatures for saturated and dry air given the temperature.
- Author
John Hart - NSSFC KCMO / NWSSPC OUN
The Wobus Function (wobf) is defined as the difference between the wet-bulb potential temperature for saturated air (WBPTS) and the wet-bulb potential temperature for dry air (WBPTD) given an input temperature in Kelvin.
WOBF(T) := WBPTS - WBPTD
Although WBPTS and WBPTD are functions of both pressure and temperature, it is assumed their difference is a function of temperature only. The difference is also proportional to the heat imparted to a parcel.
This function uses a polynomial approximation to the wobus function, fitted to values in Table 78 of PP.319-322 of the Smithsonian Meteorological Tables by Roland List (6th Revised Edition). Herman Wobus, a mathematician for the Navy Weather Research Facility in Norfolk, VA computed these coefficients a very long time ago, as he was retired as of the time of the documentation found on this routine written in 1981.
It was shown by Robert Davies-Jones (2007) that the Wobus function has a slight dependence on pressure, which results in errors of up to 1.2 Kelvin in the temperature of a lifted parcel.
- Parameters:
temperature – (K)
- Returns:
wobf (K)
-
float sharp::wetlift(float pressure, float temperature, float lifted_pressure, float converge = 0.001f)#
Compute the temperature of a parcel lifted moist adiabatically to a new level.
- Author
John Hart - NSSFC KCMO / NWSSPC OUN
With a given parcel defined by a pressure and temperature (in Pascals and Kelvin), lift it moist adiabatically to a new pressure level (in Pascals) and return the temperture of the parcel at that level.
This function relies on the Wobus Function ( sharp::wobf ), and it was shown by Robert Davies-Jones (2007) that the Wobus function has a slight dependence on pressure, which results in errors of up to 1.2 Kelvin in the temperature of a lifted parcel. This function also takes an optional argument that defines the iterative convergence criteria for the solver (default: 0.001 K).
- Parameters:
pressure – (Pa)
temperature – (K)
lifted_pressure – (Pa)
converge – (K)
- Returns:
lifted_temperature (K)
-
float sharp::saturated_lift(float pressure, float theta_sat, float converge = 0.001f)#
Compute the temperature along a moist adiabat (wet-bulb potential temperature) at a given pressure.
- Author
John Hart - NSSFC KCMO / NWSSPC OUN
Compute the temperature at which the moist adiabat intersects a line of constant pressure on a Skew-T log-P diagram. The wet-bulb potential temperature, given by theta_sat, defines a moist adiabat in Kelvin, and the temperature at the given pressure level in Pascals (Pa) is returned.
This function relies on the Wobus Function ( sharp::wobf ), and it was shown by Robert Davies-Jones (2007) that the Wobus function has a slight dependence on pressure, which results in errors of up to 1.2 Kelvin in the temperature of a lifted parcel.
- Parameters:
pressure – (Pa)
theta_sat – (K)
converge – (convergence criteria; default = 0.001f)
- Returns:
lifted_temperature (K)
-
float sharp::moist_adiabat_cm1(float pressure, float temperature, float new_pressure, float &rv_total, float &rv, float &rl, float &ri, float pres_incr, float converge, adiabat ma_type)#
Compute the temperature of a parcel lifted moist adiabatically to a new level.
- Author
Kelton Halbert - NWS Storm Prediction Center
With a given parcel defined by a pressure and temperature (in Pascals and Kelvin), lift it moist adiabatically to a new pressure level (in Pascals) and return the temperature of the parcel at that level.
This function is based on/ripped from George Byran’s (NCAR) routine in CM1. It has several options for convergence criteria, pressure increments, and the type of moist adiabat/assumptions (i.e. pseudoadiabatic, adiabatic, liquid, liquid+ice). The sharp::adiabat defines the types of adiabats, and the float references to qv, ql, and qi are used to keep budgets of the moisture variables.
NOTE: rv_total should most likely be the water vapor mixing ratio either at the parcel’s sharp::LPL, or the water vapor mixing ratio at the LCL (these are going to be the same value). Essentially, the total water vapor before condensation.
If the internal solver reaches 100 iterations without converging, it will return the last computed value and print a warning.
- Parameters:
pressure – (Pa)
temperature – (K)
new_pressure – (Pa)
rv_total – (kg/kg)
rv – (kg/kg)
rl – (kg/kg)
ri – (kg/kg)
pres_incr – (Pa)
converge – (precision)
ma_type – (sharp::adiabat)
- Returns:
pcl_temperature (K)