diff options
author | Erich Eckner <git@eckner.net> | 2019-09-23 12:00:02 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2019-09-23 12:00:02 +0200 |
commit | 4612a4c87c4ea19f09042928dff338aab68c98a1 (patch) | |
tree | b79c6d77af927a6e337edd7c8d878d7a48a2cad6 | |
parent | e245b5fbcde364456b0cfda4bf85709dfe4d5bbc (diff) | |
download | interpoliere-master.tar.xz |
-rwxr-xr-x | interpoliere | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/interpoliere b/interpoliere new file mode 100755 index 0000000..d731a95 --- /dev/null +++ b/interpoliere @@ -0,0 +1,120 @@ +#!/bin/bash + +finde_interpolierten_wert() { + local t="$1" + local lv='0' + local lt='-273.15' + sed ' + /^\s*#/d + s/ -$// + t + s/ \S\+ / / + ' "${0%/*}/werte" \ + | if [ "x$2" = 'xinvers' ]; then + sed ' + s/^\(\S\+\) \(\S\+\)$/\2 \1/ + ' + else + cat + fi \ + | while read -r ct cv; do + if printf '(%s)-(%s)\n' "${ct}" "${t}" \ + | bc -l \ + | grep -q '^[^-]'; then + printf '((%s)-(%s))/((%s)-(%s))*((%s)-(%s))+(%s)\n' \ + "${t}" "${lt}" \ + "${ct}" "${lt}" \ + "${cv}" "${lv}" \ + "${lv}" \ + | bc -l + break + fi + lt="${ct}" + lv="${cv}" + done +} + +gib_absolute_luftfeuchte() { + printf '(%s)*(%s)/100\n' \ + "$(finde_interpolierten_wert "$1")" \ + "$2" \ + | bc -l +} + +fh=$( + curl -Ss 'http://wetter.mb.fh-jena.de/station/datenbank/php_giese/online.php' +) +fh_t=$( + printf '%s\n' "${fh}" \ + | sed ' + \@>Temperatur</td>@ { + N + s@^.*<strong>\(\S\+ \)@\1@ + t + } + d + ' \ + | awk '{print $1}' +) +fh_rh=$( + printf '%s\n' "${fh}" \ + | sed ' + \@>Luftfeuchtigkeit</td>@ { + N + s@^.*<strong>\(\S\+\) %</strong></td>\s*$@\1@ + t + } + d + ' +) + +fh_ah=$( + gib_absolute_luftfeuchte "${fh_t}" "${fh_rh}" +) +fh_tp=$( + finde_interpolierten_wert "${fh_ah}" invers +) + +kpi=$( + curl -Ss 'https://kpi.ddns.eckner.net/tmp/sensor' +) +kpi_rh=$( + printf '%s\n' "${kpi}" \ + | sed ' + s/^RH: \(\S\+\) %$/\1/ + t + d + ' +) +kpi_t=$( + printf '%s\n' "${kpi}" \ + | sed ' + s/^T: \(\S\+\) °C$/\1/ + t + d + ' +) + +kpi_ah=$( + gib_absolute_luftfeuchte "${kpi_t}" "${kpi_rh}" +) +kpi_tp=$( + finde_interpolierten_wert "${kpi_ah}" invers +) + +ah_anteil=$( + printf '(%s)/(%s)*100\n' "${kpi_ah}" "${fh_ah}" \ + | bc -l +) +kpi_tp_diff=$( + printf '(%s)-(%s)\n' "${kpi_t}" "${kpi_tp}" \ + | bc -l +) +fh_tp_diff=$( + printf '(%s)-(%s)\n' "${kpi_t}" "${fh_tp}" \ + | bc -l +) + +printf '%s %% so viel Wasser innen wie außen\n' "${ah_anteil}" +printf '%s K über innerem Taupunkt\n' "${kpi_tp_diff}" +printf '%s K über äußerem Taupunkt\n' "${fh_tp_diff}" |