Created
May 27, 2014 16:08
-
-
Save dotMorten/aef41f41efe05ae17ebd to your computer and use it in GitHub Desktop.
Heat Index
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Calculates the heat index | |
/// </summary> | |
/// <param name="t">Temperature in Fahrenheit</param> | |
/// <param name="rh">Relative humidity (0..1)</param> | |
/// <returns>Heat Index in Fahrenheit</returns> | |
public double GetHeatIndex(double t, double rh) | |
{ | |
if (rh < 0 || rh > 1) | |
throw new ArgumentOutOfRangeException("rh", "Relative Humidity must be between 0 and 1"); | |
if (t >= 80 && rh >= .40) | |
{ | |
//for temp>=80F and rh>=40%, this formula is +/- 1.3F accurate | |
return -42.379 + 2.04901523 * t + 10.14333127 * rh - 0.22475541 * t * rh - 6.83783E-3 * t * t - | |
5.481717E-2 * rh * rh - 1.22874E-3 * t * t * rh + 8.5282E-4 * t * rh * rh - 1.99E-6 * t * t * rh * rh; | |
} | |
else | |
{ | |
//An alternative set of constants for this equation that is within 3 degrees of the national weather service | |
//for all humidities from 0 to 80% and all temperatures between 70 and 115 °F and all heat indexes < 150 °F is | |
return -0.363445176 + .988622465 * t + 4.777114035 * rh - 0.114037667 * t * rh - 0.000850208 * t * t - | |
0.020716198 * rh * rh - 0.000687678 * t * t * rh + 0.000274954 * t * rh * rh; // - 0 * t * t * rh * rh; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment