Table of Contents
Calculating Heatindex
The heat index (HI) is an index that combines air temperature and relative humidity in an attempt to determine the human-perceived equivalent temperature—how hot it feels. The result is also known as the “felt air temperature” or “apparent temperature”.
This tells you how hot a day “feels”. See also Caclulating Wind Chill for cold days.
Example
Fahrenheit
Text: ({wt}<80 and {wt} or {wh}<40 and {wt} or math.floor(-42.379+(2.04901523*{wt})+(10.14333127*{wh})+(-0.22475541*{wt}*{wh})+(-.00683783*({wt}^2))+(-.05481717*({wh}^2))+(.00122874*{wh}*({wt}^2))+(.00085282*{wt}*({wh}^2))+(-.00000199*({wt}^2)*({wh}^2))+.5)) .. "ᵒF"
Explanation
Yeah right… you expect me to explain all that?!? Okay, okay, I'll try my best.
The example shows the text field of a text object displaying Heat Index in the following format: 129ᵒF
This is done by first calculating heat index using the current temperature ({wt}) and the current humidity ({wh}). Note that Heat Index is only calculated if the temperature is at or above 80ᵒF and the relative humitity is at or above 40%. Also note that there are several “alternate” formulas for certain conditions. This formula is simply the standard formula, which gets you pretty darn close.
Once we've done the calculation, we need to concatenate the “ᵒF” or “ᵒC” to the formula. To do this, we need to fool LUA into thinking that we're dealing exclusively with strings (for some stupid reason… LUA isn't the smartest of languages sometimes). We do this by encapsulating the entire formula within a single set of parentheses. So, yes, the first and last parentheses are required. Then, we simply add the concatenation symbol “..” followed by the desired display in quotes (“ᵒF” or even just “ᵒ”). Just be sure to include a single space on either side of the concatenation symbol.
I'm sure some of you are wondering why I didn't include a Celsius formula. The reason is simple. I couldn't find a formula for Celsius! I'm guessing that nobody wanted to duplicate that madness for another temperature scale, so they just do it in Fahrenheit, and convert the result to Celsius using the standard Fahrenheit to Celsius conversion formula of (F-32)*5/9.