HeatIndex for lower values of temperature and humidity
frankielc opened this issue · 1 comments
The current algorithm used for calculating heat index takes into account Rothfusz equation to achieve the values that Robert G. Steadman came up by experimentation. It then has some refinements done by the NWS but doesn't consider the other refinements that NWS did for lower values of temperature and humidity.
That's the reason why heat index for common house-hold values, like 74.84F and 68.5H give a heat index of 66.38F when in reality it should be somewhere in the range of 75.23F - which makes more sense.
NWS full algo is very well detailed in this paper:
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3801457/
I also submited a pull request:
#154
I changed used library DHT11 Asair using that diagram shown above:
And my code looks like this:
float DHT::computeHeatIndex(float temperature, float percentHumidity,
bool isFahrenheit) {
float hi;
if (!isFahrenheit)
temperature = convertCtoF(temperature);
if (temperature <= 40){
hi = temperature;
}
else{
float var_A = -10.3 + (1.1 * temperature) + (0.047 * percentHumidity);
if(var_A < 80){
hi = var_A;
}
else{
hi = -42.379 + 2.04901523 * temperature + 10.14333127 * percentHumidity +
-0.22475541 * temperature * percentHumidity +
-0.00683783 * pow(temperature, 2) +
-0.05481717 * pow(percentHumidity, 2) +
0.00122874 * pow(temperature, 2) * percentHumidity +
0.00085282 * temperature * pow(percentHumidity, 2) +
-0.00000199 * pow(temperature, 2) * pow(percentHumidity, 2);
if ((percentHumidity < 13) && (temperature >= 80.0) &&
(temperature <= 112.0)){
hi -= ((13.0 - percentHumidity) * 0.25) *
sqrt((17.0 - abs(temperature - 95.0)) * 0.05882353);
}
if ((percentHumidity > 85.0) && (temperature >= 80.0) &&
(temperature <= 87.0)){
hi += ((percentHumidity - 85.0) * 0.1) * ((87.0 - temperature) * 0.2);
}
}
}
return isFahrenheit ? hi : convertFtoC(hi);
}