atmos_thermo package¶
Submodules¶
atmos_thermo.atmoslib module¶
-
atmos_thermo.atmoslib.Lv_from_T(T)¶ Calculate latent heat of vaporization for water, Lv.
- Args:
- T: temperature (Kelvin)
- Returns:
- Latent heat of vaporization [J / kg K]
-
atmos_thermo.atmoslib.T_from_p_theta(p, theta, p0=100000.0)¶ Calculate the temperature of air.
Calculate the temperature (T) given pressure (p) and potential temperature (theta).
Formula is : T = theta * (p / p0) ** (R_d / C_pd)
- Args:
- p: total pressure (Pascals) theta: potential temperature (Kelvin) p0: reference pressure used in calculating potential temperature
- Returns:
- temperature in Kelvin
-
atmos_thermo.atmoslib.Tv_from_r_T(r, T)¶ Calculate the virtual temperature.
Calculate the virtual temperature (T_v) given temperature (T) and mixing ratio (r).
- Args:
- r: mixing ratio (dimensionless) T: temperature (Kelvin)
- Returns:
- Virtual Temperature in Kelvin
-
atmos_thermo.atmoslib.e_from_r_p(r, p)¶ Calculate partial pressure of water vapor.
Calculate partial pressure of water vapor (e) from mixing ratio (r) and total pressure (p).
- Args:
- r: Mixing ratio in dimensionless ([kg H2O]/[kg Air]) units. p: Total pressure in Pascals.
- Returns:
- Vapor pressure (e) in Pascals.
-
atmos_thermo.atmoslib.esat_from_T(T)¶ Calculates saturation vapor pressure.
Using the reference Emanuel 1994 (Atmospheric Convection) p.116, equation 4.4.13 , this function calculates the saturation vapor pressure (esat) at the given temperature.
- Args:
- T: Air temperature in Kelvin. Can be numpy array.
- Returns:
- Saturation vapor pressure (esat) in units of Pa.
-
atmos_thermo.atmoslib.h_Em1994_from_r_T_z(r, T, z)¶ Calculate the moist static energy (h).
Using the definition of Emanuel 1994 (Atmospheric Convection). Equation 4.5.23
h = (C_pd + r_t C_pv) T + Lv r + g z
- Args:
- r: mixing ratio (dimensionless) T: temperature (Kelvin) z: height (meters)
- Returns:
- Moist static energy in J/kg (m^2 / s^2)
-
atmos_thermo.atmoslib.h_KF_from_r_T_z_rliq_rfroz(r, T, z, rliq, rfroz)¶ Calculate moist static energy according to the Kain-Fritsch definition.
- The standard frozen MSE formulation is:
- h = cp * T + Lv * r + g * z - Lf * r_froz
- Kain-Fritsch uses:
cp_moist = cp_dry * (1 + 0.887 * r) # this is only the vapor r
Lv = XLV0 - T * XLV1 Lf = XLS0 - T * XLS1
XLV0 = 3.15E6 J/kg XLV1 = 2370 J/(kg K) XLS0 = 2.905E6 J/kg XLS1 = 259.532 J/(kg K)
-
atmos_thermo.atmoslib.h_from_r_T_z(r, T, z)¶ Calculate the moist static energy (h).
Using the classical definiton of moist static energy h = C_pd T + Lv r + g z
- Args:
- r: mixing ratio (dimensionless, or kg/kg) T: temperature (Kelvin) z: height (meters)
- Returns:
- Moist static energy in J/kg (m^2 / s^2)
-
atmos_thermo.atmoslib.hd_Em1994_from_r_T_z(r, T, z)¶ Calculate the dry static energy (hd).
Using the definition of Emanuel 1994 (Atmospheric Convection). Equation 4.5.23. Notice that the mixing ratio is required to calculate the heat capacity correctly.
hd = (C_pd + r_t C_pv) T + g z
- Args:
- r: mixing ratio (dimensionless) p: total pressure (Pascals) T: temperature (Kelvin) z: height (meters).
- Returns:
- Dry static energy in J/kg (m^2 / s^2)
-
atmos_thermo.atmoslib.hd_from_r_T_z(r, T, z)¶ Calculate the classical dry static energy (hd).
- Args:
- p: total pressure (Pascals) T: temperature (Kelvin) z: height (meters).
- Returns:
- Dry static energy in J/kg (m^2 / s^2)
-
atmos_thermo.atmoslib.hstar_Em1994_from_p_T_z(p, T, z)¶ Calculate the saturation moist static energy (h).
Using the definition of Emanuel 1994 (Atmospheric Convection). Equation 4.5.23
h = (C_pd + r_sat C_pv) T + Lv (r_sat) + g z
- Args:
- p: total pressure (Pascals) T: temperature (Kelvin) z: height (meters)
- Returns:
- Saturation moist static energy in J/kg (m^2 / s^2)
-
atmos_thermo.atmoslib.hstar_classical_from_p_T_z(p, T, z)¶ Calculate the saturation moist static energy (h).
Using the definition of Emanuel 1994 (Atmospheric Convection). Equation 4.5.23
h = (C_pd + r_sat C_pv) T + Lv (r_sat) + g z
- Args:
- p: total pressure (Pascals) T: temperature (Kelvin) z: height (meters)
- Returns:
- Saturation moist static energy in J/kg (m^2 / s^2)
-
atmos_thermo.atmoslib.moist_specific_entropy_Emanuel_from_r_p_T(r, p, T, r_rain=0, r_cloud=0, r_ice=0)¶ Calculate the moist specific entropy.
Using the definition of Emanuel 1994 (Atmospheric Convection). Equation 4.5.9
- s = (C_pd + C_pv * r_t) * ln(T)
- R_d ln (pd)
- Lv r / T
- r R_v ln (H)
- Args:
- r: mixing ratio (dimensionless) p: total pressure (Pascals) T: temperature (Kelvin)
- Returns:
- Equivalent potential temperature in Kelvin
-
atmos_thermo.atmoslib.moist_specific_entropy_Emanuel_sat_from_p_T(p, T, r_rain=0, r_cloud=0, r_ice=0)¶ Calculate the moist specific entropy.
Using the definition of Emanuel 1994 (Atmospheric Convection). Equation 4.5.9
- s = (C_pd + C_pv * r_t) * ln(T)
- R_d ln (pd)
- Lv r / T
- r R_v ln (H)
- Args:
- p: total pressure (Pascals) T: temperature (Kelvin)
- Returns:
- Equivalent potential temperature in Kelvin
-
atmos_thermo.atmoslib.moist_specific_entropy_from_r_p_T(r, p, T)¶ Calculate the moist specific entropy.
Calculate moist specific entropy for the mixing ratio (r), total pressure (p), and temperature (T).
Uses the definition given in Benedict et. al 2014 - Gross Moist Stability and MJO Simulation Skill ... Equation 1
- Args:
- r: mixing ratio (dimensionless) p: total pressure (Pascals) T: temperature (Kelvin)
- Returns:
- Moist specific entropy in J / (kg K)
-
atmos_thermo.atmoslib.pd_from_r_p(r, p)¶ Calculate dry pressure without water vapor.
Calculate dry pressure (pd) from mixing ratio (r) and total pressure (p)
- Args:
- r: Mixing ratio in dimensionless ([kg H2O]/[kg Air]) units. p: Total pressure in Pascals.
- Returns:
- Dry pressure (pd) in Pascals.
-
atmos_thermo.atmoslib.q_from_e_p(e, p)¶ Calculates specific humidity.
Calculates specific humidity given vapor pressure (e) and total pressure (p). Typically vapor pressure is e and specific humidity is q in the literature.
q = [mass of H20 vapor] / [mass of total air]
relationship is : q = epsilon * e / (p - e*(1-epsilon))
- Args:
- e: Vapor pressure in Pascals p: Total pressure in Pascals
- Returns:
- Specific humidity in dimensionless ([kg H2O]/[kg Air]) units.
-
atmos_thermo.atmoslib.q_from_r(r)¶ Calculates specific humidity.
Calculates specific humidity given mixing ratio. Typically mixing ratio is r and specific humidity is q in the literature.
r = [mass of H20 vapor] / [mass of dry air] q = [mass of H20 vapor] / [mass of total air]
relationship is : q = r / (1+r)
- Args:
- r: Mixing ratio in dimensionless ([kg H2O]/[kg Air]) units.
- Returns:
- Specific humidity in dimensionless ([kg H2O]/[kg Air]) units.
-
atmos_thermo.atmoslib.r_from_e_p(e, p)¶ Calculate mixing ratio of water vapor.
Calculate mixing ratio of water vapor(r) from vapor pressure (e) and total pressure (p).
- Args:
- r: Mixing ratio in dimensionless ([kg H2O]/[kg Air]) units. p: Total pressure in Pascals.
- Returns:
- Vapor pressure (e) in Pascals.
-
atmos_thermo.atmoslib.relhum_from_e_esat(e, esat)¶ Calculate the relative humidity of air.
Calculate the relative humidity of air (H) given the vapor pressure (e) and saturation vapor pressure (esat).
- Args:
- e: Vapor pressure in Pascals. esat: Saturation vapor pressure in Pascals.
- Returns:
- relative humidity in dimensionless units.
-
atmos_thermo.atmoslib.relhum_from_r_p_T(r, p, T)¶ Calculate the relative humidity of air.
Calculate the relative humidity of air (H) given the mixing ratio (r), pressure (p) and temperature (T).
- Args:
- r: mixing ratio (dimensionless) p: total pressure (Pascals) T: temperature (Kelvin)
- Returns:
- relative humidity in dimensionless units.
-
atmos_thermo.atmoslib.streamfunction_from_v_p(v, p)¶ Calculate streamfunction from v, p
-
atmos_thermo.atmoslib.theta_from_p_T(p, T, p0=100000.0)¶ Calculate the potential temperature of air.
Calculate the potential temperature (theta) given pressure (p) and temperature (T).
Formula is : theta = T * (p0 / p) ** (R_d / C_pd)
- Args:
- p: total pressure (Pascals) T: temperature (Kelvin) p0: reference pressure used in calculating potential temperature
- Returns:
- potential temperature in Kelvin
-
atmos_thermo.atmoslib.thetae_Bolton_from_r_p_T(r, p, T, p0=100000, r_rain=0.0, r_cloud=0.0)¶ Calculate the pseudoadiabatic equivalent potential temperature.
Using the Bolton 1980 definition.
- Args:
- r: mixing ratio (dimensionless) p: total pressure (Pascals) T: temperature (Kelvin)
- Returns:
- Pseudoadibatic equivalent potential temperature in Kelvin
-
atmos_thermo.atmoslib.thetae_from_r_p_T(r, p, T, p0=100000, r_cloud=0.0)¶ Calculate the reversible equivalent potential temperature.
Using the definition of Emanuel 1994 (Atmospheric Convection). Equation 4.5.11
- theta_e = T * [(p0 / pd) ** (R_d / (C_pd + C_pv * r_t))]
- [H ** (-r R_v / (C_pd + C_pv * r_t)) ]
- exp[L_v * r / ((C_pd + C_pv * r_t) * T)]
- Args:
- r: mixing ratio (dimensionless) p: total pressure (Pascals) T: temperature (Kelvin)
- Returns:
- Reversible equivalent potential temperature in Kelvin
-
atmos_thermo.atmoslib.thetae_star_from_p_T(p, T)¶ Calculate the saturation equivalent potential temperature.
Using the definition of Emanuel 1994 (Atmospheric Convection). Equation 4.5.11
- thetaesat = T * [(p0 / pd) ** (R_d / (C_pd + C_pv * r_t))]
- exp[L_v * r / ((C_pd + C_pv * r_t) * T)]
- Args:
- r: mixing ratio (dimensionless) p: total pressure (Pascals) T: temperature (Kelvin)
- Returns:
- Saturation equivalent potential temperature in Kelvin
-
atmos_thermo.atmoslib.thetav_from_r_p_T(r, p, T)¶ Calculate the virtual potential temperature.
Calculate the virtual potential temperature (thetav) given temperature (T) and mixing ratio (r).
- Args:
- r: mixing ratio (dimensionless) p: total pressure (Pascals) T: temperature (Kelvin)
- Returns:
- Virtual Temperature in Kelvin
atmos_thermo.constant module¶
The following constants are accessible as atmos_thermo.catmos. For
example, atmos_thermo.catmos.R_d will return the gas constant for
dry air. All quantities are in SI units.
@readonly
def R_d():
'gas constant of dry air'
return 287.04 # , ureg['J / (kg * degK)']
@readonly
def R_v():
'gas constant of water vapor'
return 461.50 # , ureg['J / (kg * degK)']
@readonly
def epsilon():
'ratio of R_d / R_v'
return 0.6220 # , ureg['dimensionless']
@readonly
def C_vd():
'heat capacity of dry air at constant volume'
return 719.0 # , ureg['J / (kg * degK)']
@readonly
def C_pd():
'heat capacity of dry air at constant pressure'
return 1005.7 # , ureg['J / (kg * degK)']
@readonly
def C_vv():
'heat capacity of water vapor at constant volume'
return 1410.0 # , ureg['J / (kg * degK)']
@readonly
def C_pv():
'heat capacity of water vapor at constant pressure'
return 1870.0 # , ureg['J / (kg * degK)']
@readonly
def C_l():
'heat capacity of liquid water'
return 4190.0 # , ureg['J / (kg * degK)']
@readonly
def Lv0():
'Latent heat of vaporization for water at 0 degrees C'
return 2.501E6 # , ureg['J / (kg * degK)']
@readonly
def L_v():
'Latent heat of vaporization for water at 100 degrees C'
return 2.26E6
Similarly, these two are earth constants. For example atmos_thermo.cearth.g.
@readonly
def R_Earth():
return 6.371E6 # , ureg['m']
@readonly
def g():
return 9.81 # , ureg['m/s/s']