From 65c500b9be11b00e03ef412a6f2cdeb178d6b202 Mon Sep 17 00:00:00 2001 From: XANTRONIX Industrial Date: Tue, 4 Mar 2025 21:49:27 -0500 Subject: [PATCH] Implement pressure_height() --- lib/xmet/thermo.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/xmet/thermo.py b/lib/xmet/thermo.py index f0735d6..4228bfe 100644 --- a/lib/xmet/thermo.py +++ b/lib/xmet/thermo.py @@ -43,6 +43,13 @@ def lcl(temp: float, dewpoint: float) -> float: """ return (temp - dewpoint) / 0.008 +def pressure_height(pressure: float) -> float: + """ + Return the approximate altitude, in meters, for a given pressure in + millibar. + """ + return (1 - (pressure / 1013.25) ** 0.190284) * 145366.45 * 0.3048 + def lapse(temp: float, rate: float, delta: float) -> float: """ Return the temperature of a parcel cooled at either the dry or moist lapse