From a186f629d81247841eebd4ede202402b7481a86d Mon Sep 17 00:00:00 2001
From: XANTRONIX Industrial <xan@xantronix.com>
Date: Fri, 14 Mar 2025 19:29:48 -0400
Subject: [PATCH] Implement virtual_temp()

---
 lib/xmet/thermo.py | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/lib/xmet/thermo.py b/lib/xmet/thermo.py
index cbed4cd..f91c39a 100644
--- a/lib/xmet/thermo.py
+++ b/lib/xmet/thermo.py
@@ -17,6 +17,17 @@ def kelvin(c: float) -> float:
 def celsius(k: float) -> float:
     return k - 273.15
 
+def virtual_temp(temp: float, dewpoint: float, pressure: float) -> float:
+    a = 7.5 * dewpoint
+    b = 237.3 + dewpoint
+    c = a / b
+
+    d = 6.11 * (10**c)
+    e = d / pressure
+    f = 1 - 0.379 * e
+
+    return celsius((temp + 273.15) / f)
+
 def vapor_pressure(dewpoint: float) -> float:
     """
     Return the pressure, in millibar, of vapor in a parcel of a given