Calculations

Copyright (c) 2024 MPI-M, Clara Bayley

—– Microphysics Test Cases —– File: calcs.py Project: thermo Created Date: Friday 1st March 2024 Author: Clara Bayley (CB) Additional Contributors: —– Last Modified: Monday 2nd September 2024 Modified By: CB —– License: BSD 3-Clause “New” or “Revised” License https://opensource.org/licenses/BSD-3-Clause —– File Description: functions for calculations of some quantities e.g. potential temperature(s)

libs.thermo.formulae.dry_potential_temperature(temp: ndarray, press: ndarray)[source]

Calculate the potential temperature for dry air.

This function calculates the potential temperature for dry air given the temperature and pressure.

\[\theta_{\rm{dry}} = T \left( \frac{P_{\rm ref}}{P} \right) ^{ \frac{R_{\rm{dry}}}{c_{\rm{p, dry}}} }\]

where \(P_{\rm ref}\) is the first pressure in press array.

Args:
temp (array-like):

Temperature values (K).

press (array-like):

Pressure values (Pa).

Returns:

array-like: The dry potential temperature (K).

libs.thermo.formulae.moist_equiv_potential_temperature(temp: ndarray, press: ndarray, qvap: ndarray)[source]

Calculate the moist potential temperature.

\[heta_e = heta \cdot \exp\left(\]

rac{L_v cdot q}{c_p cdot T} ight)

Args:
temp (array-like):

Temperature values (K).

press (array-like):

Pressure values (Pa).

qvap (array-like):

Mixing ratio of water vapour (kg/kg)

Returns:

array-like: The moist potential temperature (K).

libs.thermo.formulae.moist_static_energy(temp: ndarray, qvap: ndarray, height: ndarray | None = None)[source]

Calculate the moist static energy [kilojoule / kilogram]

\[heta_e = heta \cdot \exp\left(\]

rac{L_v cdot q}{c_p cdot T} ight)

Args:
temp (array-like):

Temperature values (K).

press (array-like):

Pressure values (Pa).

qvap (array-like):

Mixing ratio of water vapour (kg/kg)

Returns:

array-like: The moist potential temperature (K).

libs.thermo.formulae.supersaturation(temp: ndarray, press: ndarray, qvap: ndarray)[source]

Calculate supersaturation based on the method described in PyMPDATA-examples

This function uses the calculations in the Shipway and Hill (2012) example from PyMPDATA-examples library to compute the supersaturation.

Parameters: temp (float): Temperature in Kelvin. press (float): Pressure in Pascals. qvap (float): Specific humidity (kg/kg).

Returns: float: Supersaturation value.