Skip to content

Commit

Permalink
Don't Calculate Heat Index when Temps are Cold
Browse files Browse the repository at this point in the history
  • Loading branch information
leoherzog committed Jan 1, 2025
1 parent 6c95e02 commit 2d963ff
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions code.gs
Original file line number Diff line number Diff line change
Expand Up @@ -1378,6 +1378,7 @@ Number.prototype.windChill = function(windSpeed, units='F') {
// https://www.weather.gov/media/epz/wxcalc/heatIndex.pdf
Number.prototype.heatIndex = function(humidity, units='F') {
let T = units === 'F' ? this : this.cToF();
if (T < 80) return units === 'F' ? T : this;
let H = humidity;
let heatIndexF = -42.379 + 2.04901523 * T + 10.14333127 * H - 0.22475541 * T * H - 6.83783 * Math.pow(10, -3) * Math.pow(T, 2) - 5.481717 * Math.pow(10, -2) * Math.pow(H, 2) + 1.22874 * Math.pow(10, -3) * Math.pow(T, 2) * H + 8.5282 * Math.pow(10, -4) * T * Math.pow(H, 2) - 1.99 * Math.pow(10, -6) * Math.pow(T, 2) * Math.pow(H, 2);
return units === 'F' ? heatIndexF : heatIndexF.fToC();
Expand Down

0 comments on commit 2d963ff

Please sign in to comment.