From f681b8e861052766f9ea5882cbf48dda9d4f72ac Mon Sep 17 00:00:00 2001 From: Frankie Date: Thu, 2 Apr 2020 11:28:58 +0100 Subject: [PATCH] heat index with refinements from NWS for lower values --- DHT.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/DHT.cpp b/DHT.cpp index 14e1d85..96bc17e 100644 --- a/DHT.cpp +++ b/DHT.cpp @@ -175,9 +175,12 @@ float DHT::computeHeatIndex(bool isFahrenheit) { } /*! - * @brief Compute Heat Index - * Using both Rothfusz and Steadman's equations + * @brief Compute Heat Index (based on Robert G. Steadman tables) + * Using Rothfusz equations with refinements by the NWS * (http://www.wpc.ncep.noaa.gov/html/heatindex_equation.shtml) + * and NWS algorithm that respects lower values of temperature + * and humidity + * (https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3801457/) * @param temperature * temperature in selected scale * @param percentHumidity @@ -193,6 +196,15 @@ float DHT::computeHeatIndex(float temperature, float percentHumidity, if (!isFahrenheit) temperature = convertCtoF(temperature); + if(temperature <= 40) { + return isFahrenheit ? temperature : convertFtoC(temperature); + } + + float varA = -10.3 + 1.1 * temperature + 0.047 * percentHumidity; + if (varA < 79) { + return isFahrenheit ? varA : convertFtoC(varA); + } + hi = 0.5 * (temperature + 61.0 + ((temperature - 68.0) * 1.2) + (percentHumidity * 0.094));