From 89693ad01d4375e04d6f28603269aa60f409bac1 Mon Sep 17 00:00:00 2001 From: Ally Bowles Date: Mon, 14 Oct 2019 18:17:44 -0500 Subject: [PATCH] Calculate heat index --- .bin/wx | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/.bin/wx b/.bin/wx index 17defb8..01752ad 100755 --- a/.bin/wx +++ b/.bin/wx @@ -10,6 +10,7 @@ # http://www.met.tamu.edu/class/metar/quick-metar.html # http://www.dixwx.com/wxdecoding.htm # https://en.wikipedia.org/wiki/Wind_chill#North_American_and_United_Kingdom_wind_chill_index +# https://en.wikipedia.org/wiki/Heat_index#Formula ## Dependencies: # bc @@ -236,9 +237,13 @@ _temperature_conversion() { esac } +_calculate_humidity() { + humidity=$(bc -l <<< "100 * (e((17.625 * $dp)/(243.04 + $dp))/e((17.625 * $temp)/(243.04 + $temp)))") +} + humidity() { _temperature_dewpoint - humidity=$(bc -l <<< "100 * (e((17.625 * $dp)/(243.04 + $dp))/e((17.625 * $temp)/(243.04 + $temp)))") + _calculate_humidity printf "%.0f%%" $humidity } @@ -256,4 +261,20 @@ wind_chill() { _temperature_conversion $wind_chill $1 } +heat_index() { + _temperature_dewpoint + _calculate_humidity + c1="-8.78469475556" + c2="1.61139411" + c3="2.33854883889" + c4="-0.14611605" + c5="-0.012308094" + c6="-0.0164248277778" + c7="0.002211732" + c8="0.00072546" + c9="-0.000003582" + heat_index=$(bc <<< "$c1 + $c2 * $temp + $c3 * $humidity + $c4 * $temp * $humidity + $c5 * $temp ^ 2 + $c6 * $humidity ^ 2 + $c7 * ($temp ^ 2) * $humidity + $c8 * $temp * ($humidity ^ 2) + $c9 * ($temp ^ 2) * ($humidity ^ 2)") + _temperature_conversion $heat_index $1 +} + $@ && _check_last_modified || refresh