The thermodynamics module.¶
This module implements thermodynamics functions for subfilter
.
Note: Functions can be used to provide derived variables
where Derived variable name:
is defined.
New at 0.5
Relocated to
subfilter.thermodynamics
.
Detailed Module Contents¶
The entire module is documented below.
General Thermodynamics functions.
Peter Clark
- subfilter.thermodynamics.thermodynamics.esat(T)¶
Saturation Vapour Pressure over Water.
Derived variable name: esat
- Parameters
T (numpy array or xarray DataArray) – Temperature (K)
- Returns
res – Vapour pressure over water (Pa)
- Return type
numpy array or xarray DataArray
- subfilter.thermodynamics.thermodynamics.esat_ice(T)¶
Saturation Vapour Pressure over Ice.
Derived variable name: esat_ice
Magnus Teten, Murray (1967)
- Parameters
T (numpy array or xarray DataArray.) – Temperature (K)
- Returns
res – Vapour pressure over ice(Pa)
- Return type
numpy array or xarray DataArray
- subfilter.thermodynamics.thermodynamics.inv_esat(es)¶
Temperature for given Saturation Vapour Pressure over Water.
- Parameters
es (numpy array or xarray DataArray) – Vapour pressure over water (Pa)
- Returns
T – Temperature (K)
- Return type
numpy array or xarray DataArray
- subfilter.thermodynamics.thermodynamics.inv_esat_ice(es)¶
Temperature for given Saturation Vapour Pressure over Water.
Magnus Teten, Murray (1967)
- Parameters
es (numpy array or xarray DataArray) – Vapour pressure over water (Pa)
- Returns
T – Temperature (K)
- Return type
numpy array or xarray DataArray
- subfilter.thermodynamics.thermodynamics.esat_over_Tkappa(T)¶
Computes
(es in Pa).
From Bolton 1980.
- Parameters
T (numpy array or xarray DataArray) – Temperature (K)
- Returns
res
- Return type
numpy array or xarray DataArray
- subfilter.thermodynamics.thermodynamics.exner(p)¶
Compute Exner Pressure.
Derived variable name: exner
- Parameters
p (numpy array or xarray DataArray) – Pressure (Pa).
- Returns
p_exner
- Return type
numpy array or xarray DataArray
- subfilter.thermodynamics.thermodynamics.inv_exner(p)¶
Compute 1/(Exner Pressure).
- Parameters
p (numpy array or xarray DataArray) – Pressure (Pa).
- Returns
inv_p_exner
- Return type
numpy array or xarray DataArray
- subfilter.thermodynamics.thermodynamics.temperature(theta, p)¶
Compute Potential Temperature.
Derived variable name: T
- Parameters
theta (numpy array or xarray DataArray) – Potential temperature of dry air (K),
p (numpy array or xarray DataArray) – Pressure (Pa).
- Returns
T – Temperature (K).
- Return type
numpy array or xarray DataArray
- subfilter.thermodynamics.thermodynamics.potential_temperature(T, p)¶
Compute Potential Temperature.
Derived variable name: th
- Parameters
T (numpy array or xarray DataArray) – Temperature (K).
p (numpy array or xarray DataArray) – Pressure (Pa).
- Returns
theta – Potential temperature of dry air (K),
- Return type
numpy array or xarray DataArray
- subfilter.thermodynamics.thermodynamics.moist_potential_temperature(T, p, m)¶
Compute Moist Potential Temperature.
- Parameters
T (numpy array or xarray DataArray) – Temperature (K).
p (numpy array or xarray DataArray) – Pressure (Pa).
m (numpy array or xarray DataArray) – Mixing ratio(kg/kg).
- Returns
theta – Potential temperature of moist air (K) .
- Return type
numpy array or xarray DataArray
- subfilter.thermodynamics.thermodynamics.q_to_mix(q)¶
Convert specific humidity to mixing ratio.
Derived variable name: m_x where input is q_x
- Parameters
q (numpy array or xarray DataArray) – Specific humidity (kg/kg).
- Returns
m – Mixing Ratio(kg/kg)
- Return type
numpy array or xarray DataArray
- subfilter.thermodynamics.thermodynamics.mix_to_q(m)¶
Convert mixing ratio to specific humidity.
Derived variable name: q_x where input is m_x
- Parameters
m (numpy array or xarray DataArray) – Mixing Ratio(kg/kg)
- Returns
q – Specific humidity (kg/kg).
- Return type
numpy array or xarray DataArray
- subfilter.thermodynamics.thermodynamics.q_p_to_e(q, p)¶
Convert specific humidity and pressure to vapour pressure.
- Parameters
q (numpy array or xarray DataArray) – Specific humidity (kg/kg)
p (numpy array or xarray DataArray) – Total Pressure (Pa)
- Returns
e – Vapour pressure (Pa)
- Return type
numpy array or xarray DataArray
- subfilter.thermodynamics.thermodynamics.e_p_to_q(e, p)¶
Convert vapour pressure and total pressure to specific humidity.
- Parameters
e (numpy array or xarray DataArray) – Vapour pressure (Pa)
p (numpy array or xarray DataArray) – Pressure (Pa)
- Returns
q – Specific humidity (kg/kg)
- Return type
numpy array or xarray DataArray
- subfilter.thermodynamics.thermodynamics.t_lcl_td(T, TD)¶
T at lifting condensation level from Dewpoint.
Derived variable name: t_lcl_td
From Bolton 1980
- Parameters
T (numpy array or xarray DataArray) – Temperature (K).
TD (numpy array or xarray DataArray) – Dew point Temperature (K).
- Returns
Tlcl – temperature at lifting condensation level (K)
- Return type
numpy array or xarray DataArray
- subfilter.thermodynamics.thermodynamics.t_lcl_e(T, e)¶
T at lifting condensation level from vapour presssure.
Derived variable name: t_lcl_e
From Bolton 1980
- Parameters
T (numpy array or xarray DataArray) – Temperature (K).
e (numpy array or xarray DataArray) – Vapour pressure (Pa).
- Returns
Tlcl – temperature at lifting condensation level (K)
- Return type
numpy array or xarray DataArray
- subfilter.thermodynamics.thermodynamics.t_lcl_rh(T, RH)¶
T at lifting condensation level from RH.
Derived variable name: t_lcl_rh
From Bolton 1980
- Parameters
T (numpy array or xarray DataArray) – Temperature (K).
RH (numpy array or xarray DataArray) – Relative humidity (%)
- Returns
Tlcl – temperature at lifting condensation level (K)
- Return type
numpy array or xarray DataArray
- subfilter.thermodynamics.thermodynamics.latheat(T, sublim=0, model=0, focwil_T=None)¶
Latent heat of condensation or sublimation.
- Parameters
T (numpy array or xarray DataArray) – Temperature (K).
sublim (int (optional)) – = 1 return Latent heat of sublimation
Model (int (optional)) – = 1 use UM fixed values
focwil_T (float (optional)) – use linear ramp in ice fraction from focwil_T to freezing.
- Returns
latheat – Latent heat of condensation(K)
- Return type
numpy array or xarray DataArray
- subfilter.thermodynamics.thermodynamics.dewpoint(T, p, q)¶
Dewpoint.
Derived variable name: T_dew
- Parameters
T (numpy array or xarray DataArray) – Temperature.
p (numpy array or xarray DataArray) – Pressure (Pa).
q (numpy array or xarray DataArray) – specific humidity (kg/kg)
- Returns
TD – Dew-point temperature (K).
- Return type
Nnmpy array
- subfilter.thermodynamics.thermodynamics.qsat(T, p)¶
Saturation vapour pressure.
Derived variable name: qsat
- Parameters
T (numpy array or xarray DataArray) – Temperature. (K)
p (numpy array or xarray DataArray) – Pressure (Pa).
- Returns
qs – Saturation specific humidity (kg/kg) over water.
- Return type
numpy array or xarray DataArray
- subfilter.thermodynamics.thermodynamics.dqsatbydT(T, p)¶
.
Derived variable name: alpha
- Parameters
T (numpy array or xarray DataArray) – Temperature. (K)
p (numpy array or xarray DataArray) – Pressure (Pa).
- Returns
alpha
- Return type
numpy array or xarray DataArray
- subfilter.thermodynamics.thermodynamics.equiv_potential_temperature_approx(T, p, q)¶
Equivalent potential temperature.
From Bolton 1980
- Parameters
T (numpy array or xarray DataArray) – Temperature. (K)
p (numpy array or xarray DataArray) – Pressure (Pa).
q (numpy array or xarray DataArray) – specific humidity (kg/kg)
- Returns
theta_e – Fast estimate of equivalent potential temperature (K).
- Return type
numpy array or xarray DataArray
- subfilter.thermodynamics.thermodynamics.equiv_potential_temperature(T, p, q)¶
Equivalent potential temperature.
Derived variable name: th_e
From Bolton 1980
- Parameters
T (numpy array or xarray DataArray) – Temperature. (K)
p (numpy array or xarray DataArray) – Pressure (Pa).
q (numpy array or xarray DataArray) – specific humidity (kg/kg)
- Returns
theta_e – Accurate estimate of equivalent potential temperature (K).
- Return type
numpy array or xarray DataArray
- subfilter.thermodynamics.thermodynamics.wet_bulb_potential_temperature(T, p, q)¶
Wet-bulb potential temperature.
Derived variable name: th_w
From Davies-Jones 2007
- Parameters
T (numpy array or xarray DataArray) – Temperature. (K)
p (numpy array or xarray DataArray) – Pressure (Pa).
q (numpy array or xarray DataArray) – specific humidity (kg/kg)
- Returns
theta_w – Wet-bulb potential temperature (K) numpy array or xarray DataArray
- Return type
numpy array or xarray DataArray
- subfilter.thermodynamics.thermodynamics.wet_bulb_temperature(T, p, q)¶
Wet-bulb temperature.
Derived variable name: T_w
From Davies-Jones 2007
- Parameters
T (numpy array or xarray DataArray) – Temperature. (K)
p (numpy array or xarray DataArray) – Pressure (Pa).
q (numpy array or xarray DataArray) – specific humidity (kg/kg)
- Returns
theta_w – Wet-bulb temperature (K) numpy array or xarray DataArray
- Return type
numpy array or xarray DataArray
- subfilter.thermodynamics.thermodynamics.liquid_water_potential_temperature(theta, q_cl, pi)¶
Liquid water potential temperature.
Derived variable name: th_L
Approximate form as in MONC
- Parameters
theta (numpy array or xarray DataArray) – Potential Temperature. (K)
q_cl (numpy array or xarray DataArray) – q_cloud_liquid_mass.
pi (numpy array or xarray DataArray) – Exner pressure.
- Returns
theta_w – Wet-bulb potential temperature (K) numpy array or xarray DataArray
- Return type
numpy array or xarray DataArray
- subfilter.thermodynamics.thermodynamics.virtual_potential_temperature(theta, q_v, q_cl)¶
Virtual potential temperature.
Derived variable name: th_v
- Parameters
theta (numpy array or xarray DataArray) – Potential Temperature. (K)
q_v (numpy array or xarray DataArray) – specific humidity
q_cl (numpy array or xarray DataArray) – specific cloud liquid water content.
- Returns
theta_v – Virtual potential temperature (K)
- Return type
numpy array or xarray DataArray
- subfilter.thermodynamics.thermodynamics.virtual_potential_temperature_monc(theta, thref, q_v, q_cl)¶
Virtual potential temperature.
Derived variable name: th_v_monc
Approximate form as in MONC
- Parameters
theta (numpy array or xarray DataArray) – Potential Temperature. (K)
thref (numpy array or xarray DataArray) – Reference Potential Temperature (usually 1D). (K)
q_v (numpy array or xarray DataArray) – specific humidity
q_cl (numpy array or xarray DataArray) – specific cloud liquid water content.
- Returns
theta_v – Virtual potential temperature (K)
- Return type
numpy array or xarray DataArray
- subfilter.thermodynamics.thermodynamics.q_total(*args)¶
Specfic Total Water Content.
Derived variable name: q_total
- Parameters
args (list of numpy array or xarray DataArrays) – specific water variables (e.g.[ q_v, q_cl]).
- Returns
q_total – sum of args
- Return type
numpy array or xarray DataArray
- subfilter.thermodynamics.thermodynamics.buoyancy(th_v)¶
Buoyancy from theta_v.
Derived variable name: buoyancy
- Parameters
th_v (numpy array or xarray DataArray) – Virtual potential temperature.
- Returns
buoyancy
- Return type
numpy array or xarray DataArray
- subfilter.thermodynamics.thermodynamics.buoyancy_monc(th_v, thref)¶
Buoyancy from theta_v.
Derived variable name: buoyancy_monc
MONC approximation.
- Parameters
th_v (numpy array or xarray DataArray) – Virtual potential temperature.
- Returns
buoyancy
- Return type
numpy array or xarray DataArray
- subfilter.thermodynamics.thermodynamics.dbdz(th, p, q_v, q_cl, z, zn)¶
Vertical Gradient of Buoyancy from theta_v.
Derived variable name: dbdz
- Parameters
theta (numpy array or xarray DataArray) – Potential Temperature. (K)
thref (numpy array or xarray DataArray) – Reference Potential Temperature (usually 1D). (K)
p (numpy array or xarray DataArray) – Pressure (Pa).
q_v (numpy array or xarray DataArray) – specific humidity
q_cl (numpy array or xarray DataArray) – specific cloud liquid water content.
th_v (numpy array or xarray DataArray) – Virtual potential temperature.
- Returns
dbuoyancy/dz
- Return type
numpy array or xarray DataArray
- subfilter.thermodynamics.thermodynamics.dbdz_monc(th, thref, p, q_v, q_cl, z, zn)¶
Vertical Gradient of Buoyancy from theta_v.
Derived variable name: db_moncdz
MONC approximation
- Parameters
theta (numpy array or xarray DataArray) – Potential Temperature. (K)
thref (numpy array or xarray DataArray) – Reference Potential Temperature (usually 1D). (K)
p (numpy array or xarray DataArray) – Pressure (Pa).
q_v (numpy array or xarray DataArray) – specific humidity
q_cl (numpy array or xarray DataArray) – specific cloud liquid water content.
th_v (numpy array or xarray DataArray) – Virtual potential temperature.
- Returns
buoyancy
- Return type
numpy array or xarray DataArray
- subfilter.thermodynamics.thermodynamics.rh(T, p, q)¶
Relative Humidity.
Derived variable name: rh
- Parameters
T (numpy array or xarray DataArray) – Temperature (K).
p (numpy array or xarray DataArray) – Pressure (Pa).
q (numpy array or xarray DataArray) – specific humidity (kg/kg)
- Returns
rh – Relative Humidity.
- Return type
numpy array or xarray DataArray
- subfilter.thermodynamics.thermodynamics.rh_ice(T, p, q)¶
Relative Humidity wrt Ice.
Derived variable name: rh_ice
- Parameters
T (numpy array or xarray DataArray) – Temperature.
p (numpy array or xarray DataArray) – Pressure (Pa).
q (numpy array or xarray DataArray) – specific humidity (kg/kg)
- Returns
rh – Relative Humidity.
- Return type
numpy array or xarray DataArray
- subfilter.thermodynamics.thermodynamics.a_L_monc(T, p)¶
Cloud Factor.
Derived variable name: a_L
- Parameters
T (numpy array or xarray DataArray) – Temperature.
p (numpy array or xarray DataArray) – Pressure (Pa).
- Returns
a_L – Factor used in calculating liqid water content.
- Return type
numpy array or xarray DataArray
- subfilter.thermodynamics.thermodynamics.cloud_params_monc(th_ref, p_ref)¶
Cloud Parameters.
MONC Approximation
- Parameters
th_ref (numpy array or xarray DataArray) – Reference Potential Temperature.
p_ref (numpy array or xarray DataArray) – Reference Pressure (Pa).
- Returns
Factors used in calculating liqid water content. “T_ref”,”pi_ref”, “qs_ref”, “a_L”, “alpha_L”.
- Return type
dict
- subfilter.thermodynamics.thermodynamics.betas_monc(th, p)¶
Beta factors in cloudy buoyancy calculation.
- Parameters
th (numpy array or xarray DataArray) – Potential Temperature. (K)
p (numpy array or xarray DataArray) – Pressure (Pa).
- Returns
(bt, bq, bc, alpha_L, a_L).
- Return type
tuple of numpy array or xarray DataArrays
- subfilter.thermodynamics.thermodynamics.buoyancy_moist(th, th_ref, p, q_v, q_cl, thresh=1e-05)¶
Buoyancy including cloud condensation.
Derived variable name: buoyancy_moist
MONC approximation
- Parameters
th (numpy array or xarray DataArray) – Potential Temperature. (K)
thref (numpy array or xarray DataArray) – Reference Potential Temperature (usually 1D). (K)
p (numpy array or xarray DataArray) – Pressure (Pa).
q_v (numpy array or xarray DataArray) – specific humidity
q_cl (numpy array or xarray DataArray) – specific cloud liquid water content.
- Returns
buoyancy
- Return type
numpy array or xarray DataArray
- subfilter.thermodynamics.thermodynamics.dmoist_bdz(th, th_ref, p, q_v, q_cl, z, zn, thresh=1e-05)¶
Vertical Gradient of (buoyancy including cloud condensation).
Derived variable name: dmoist_bdz
MONC approximation. This is db/dz with b = beta_t theta_l + beta_q q_t. Note - not to be used for vertical buoyancy flux.
- Parameters
th (numpy array or xarray DataArray) – Potential Temperature. (K)
th_ref (numpy array or xarray DataArray) – Reference Potential Temperature (usually 1D). (K)
p (numpy array or xarray DataArray) – Pressure (Pa).
q_v (numpy array or xarray DataArray) – specific humidity
q_cl (numpy array or xarray DataArray) – specific cloud liquid water content.
z (xarray coord.) –
zn (xarray coord.) –
thresh ((Optional) float. Default is 1E-5.) – Threshold for cloud water.
- Returns
buoyancy
- Return type
numpy array or xarray DataArray
- subfilter.thermodynamics.thermodynamics.moist_dbdz(th, th_ref, p_ref, q_v, q_cl, z, zn, thresh=1e-05)¶
Vertical Gradient of buoyancy (including cloud condensation).
Derived variable name: moist_dbdz
MONC approximation This is db/dz = beta_t dtheta_l/dz + beta_q dq_t/dz. Note - to be used for vertical buoyancy flux.
- Parameters
theta (numpy array or xarray DataArray) – Potential Temperature. (K)
thref (numpy array or xarray DataArray) – Reference Potential Temperature (usually 1D). (K)
p (numpy array or xarray DataArray) – Pressure (Pa).
q_v (numpy array or xarray DataArray) – specific humidity
q_cl (numpy array or xarray DataArray) – specific cloud liquid water content.
z (xarray coord.) –
zn (xarray coord.) –
thresh ((Optional) float. Default is 1E-5.) – Threshold for cloud water.
- Returns
buoyancy
- Return type
numpy array or xarray DataArray
- subfilter.thermodynamics.thermodynamics.saturation(th, th_ref, p_ref, q_v, q_cl)¶
Effective saturation.
Derived variable name: saturation
MONC approximation
- Parameters
th (numpy array or xarray DataArray) – Potential Temperature. (K)
th_ref (numpy array or xarray DataArray) – Reference Potential Temperature (usually 1D). (K)
p_ref (numpy array or xarray DataArray) – Reference Pressure (Pa).
q_v (numpy array or xarray DataArray) – specific humidity
q_cl (numpy array or xarray DataArray) – specific cloud liquid water content.
- Returns
saturation
- Return type
numpy array or xarray DataArray
- subfilter.thermodynamics.thermodynamics.cloud_fraction(q_cl, thresh=1e-05)¶
Compute indicator function on cloud.
Derived variable name: cloud_fraction
- Parameters
q_cl (numpy array or xarray DataArray) – specific cloud liquid water content.
thresh ((Optional) float. Default is 1E-5.) – Threshold for cloud water.
- Returns
- Return type
numpy array or xarray DataArray