tephpy.transforms#
Coordinate transforms for the tephigram projection.
Pure numpy functions between the three coordinate frames of the tephigram (spec §3.1): pressure/temperature (p, T), temperature/potential-temperature (T, theta), and the rotated tephigram (x, y) plane, where
x = MA * ln(theta_K) + T y = MA * ln(theta_K) - T
with MA = 300 and theta_K the potential temperature in Kelvin. The
construction is derived from Met Office Factsheet 13 and Stull,
Practical Meteorology ch. 5, and cross-validated against tephi as an
oracle (tests/test_oracle.py) — not ported from it.
This module is the documented exemption to the pint units policy (spec §5):
bare float64 arrays in diagram-native units — pressure in hPa,
temperatures in degrees Celsius, x/y dimensionless. Out-of-domain input
(non-positive pressure, potential temperatures theta at or below absolute
zero) propagates NaN; exception-carrying validation lives at the
quantified boundaries above this module (spec §6).
Functions#
Convert pressure and temperature to potential temperature. |
|
Convert temperature and potential temperature to pressure. |
|
Convert temperature and potential temperature to tephigram (x, y). |
|
Convert tephigram (x, y) coordinates back to temperature and theta. |
Module Contents#
- tephpy.transforms.theta_from_pressure_temperature(pressure: numpy.typing.ArrayLike, temperature: numpy.typing.ArrayLike) numpy.typing.NDArray[numpy.float64][source]#
Convert pressure and temperature to potential temperature.
Poisson’s equation:
theta_K = T_K * (P_REF / p) ** kappa.- Parameters:
- Returns:
numpy.ndarrayPotential temperature in degrees Celsius,
float64, broadcast over the inputs.
- tephpy.transforms.pressure_from_temperature_theta(temperature: numpy.typing.ArrayLike, theta: numpy.typing.ArrayLike) numpy.typing.NDArray[numpy.float64][source]#
Convert temperature and potential temperature to pressure.
Inverse of
theta_from_pressure_temperature():p = P_REF * (T_K / theta_K) ** (1 / kappa).- Parameters:
- Returns:
numpy.ndarrayPressure in hPa,
float64, broadcast over the inputs.
- tephpy.transforms.xy_from_temperature_theta(temperature: numpy.typing.ArrayLike, theta: numpy.typing.ArrayLike) tuple[numpy.typing.NDArray[numpy.float64], numpy.typing.NDArray[numpy.float64]][source]#
Convert temperature and potential temperature to tephigram (x, y).
The rotated tephigram mapping:
x = MA * ln(theta_K) + Tandy = MA * ln(theta_K) - T, which renders isotherms and dry adiabats as exactly perpendicular straight lines.- Parameters:
- Returns:
tupleofnumpy.ndarrayThe tephigram
(x, y)coordinates (the axes’ data space),float64, broadcast over the inputs.
- tephpy.transforms.temperature_theta_from_xy(x: numpy.typing.ArrayLike, y: numpy.typing.ArrayLike) tuple[numpy.typing.NDArray[numpy.float64], numpy.typing.NDArray[numpy.float64]][source]#
Convert tephigram (x, y) coordinates back to temperature and theta.
Inverse of
xy_from_temperature_theta():T = (x - y) / 2andtheta_K = exp((x + y) / (2 * MA)).- Parameters:
- Returns:
tupleofnumpy.ndarray(temperature, theta)in degrees Celsius,float64, broadcast over the inputs.