From ce494aa7cb8a7505d0cb037c8397cae557718c3d Mon Sep 17 00:00:00 2001 From: Bjarne Riis Date: Sun, 8 Oct 2023 07:45:09 +0200 Subject: [PATCH] Added absolute Humidity --- pyweatherflow_forecast/data.py | 10 ++++++++++ test_module.py | 1 + 2 files changed, 11 insertions(+) diff --git a/pyweatherflow_forecast/data.py b/pyweatherflow_forecast/data.py index e191b4a..6afd699 100644 --- a/pyweatherflow_forecast/data.py +++ b/pyweatherflow_forecast/data.py @@ -443,6 +443,16 @@ def __init__( self._precip_minutes_local_day_final = precip_minutes_local_day_final self._precip_minutes_local_yesterday_final = precip_minutes_local_yesterday_final + @property + def absolute_humidity(self) -> float: + """Aboslute Humidity (g.m-3).""" + if self._air_temperature is None or self._relative_humidity is None: + return None + + kelvin = self._air_temperature * 273.16 + humidity = self._relative_humidity / 100 + return (1320.65 / kelvin) * humidity * (10 ** ((7.4475 * (kelvin - 273.14)) / (kelvin - 39.44))) + @property def air_density(self) -> float: """Air Density.""" diff --git a/test_module.py b/test_module.py index f11b764..4c5de27 100644 --- a/test_module.py +++ b/test_module.py @@ -30,6 +30,7 @@ print("WIND DIRECTION: ", sensor_data.wind_direction) print("WIND CARDINAL: ", sensor_data.wind_cardinal) print("PRECIP CHECKED: ", sensor_data.precip_accum_local_day_final) +print("ABSOLUTE HUMIDITY: ", sensor_data.absolute_humidity) # data: WeatherFlowStationData = weatherflow.get_station() # print("STATION NAME: ", data.station_name)