From 60e48f801f9411e2cb368ca89fcbf2573b60092d Mon Sep 17 00:00:00 2001 From: fenix-soft Date: Sun, 16 Sep 2018 20:43:17 +0200 Subject: [PATCH] add rf5 tools --- tools/rf5 | 101 ++++++++++++++++++++++++++++++++++++++++++ tools/rf5_README.md | 10 +++++ tools/rf5_cangelog.md | 3 ++ tools/rf5_version.md | 1 + 4 files changed, 115 insertions(+) create mode 100644 tools/rf5 create mode 100644 tools/rf5_README.md create mode 100644 tools/rf5_cangelog.md create mode 100644 tools/rf5_version.md diff --git a/tools/rf5 b/tools/rf5 new file mode 100644 index 0000000..e65a262 --- /dev/null +++ b/tools/rf5 @@ -0,0 +1,101 @@ +#!/bin/bash +# read and print video forecast 5 data +# V.1.0 + + +forecast5() { + +for ((i=0; i<6; i++)); do + +# exstract forecast 5 data to jason file + +city_name=`cat meteonow.txt | jq -r '.list[0]|.name'` +L=`cat meteonow.txt | jq -r '.list[0]|.sys[]'` +Lat=`cat meteonow.txt | jq -r '.list[0]|.coord.lat'` +Lon=`cat meteonow.txt | jq -r '.list[0]|.coord.lon'` +data_X=`cat meteo5.txt | jq -r '.list['$i']|.dt'` +data_U=`date -d @$data_X` +Wcond_n=`cat meteo5.txt | jq -r '.list['$i']|.weather[].main'` +Wcond_nd=`cat meteo5.txt | jq -r '.list['$i']|.weather[].description'` +Tmax=`cat meteo5.txt | jq -r '.list['$i']|.temp.max'` +Tmin=`cat meteo5.txt | jq -r '.list['$i']|.temp.min'` +TM=`cat meteo5.txt | jq -r '.list['$i']|.temp.morn'` +TE=`cat meteo5.txt | jq -r '.list['$i']|.temp.eve'` +TN=`cat meteo5.txt | jq -r '.list['$i']|.temp.night'` +TD=`cat meteo5.txt | jq -r '.list['$i']|.temp.day'` +Hm=`cat meteo5.txt | jq -r '.list['$i']|.humidity'` +PrS=`cat meteo5.txt | jq -r '.list['$i']|.pressure'` +#ClD=`cat meteo5.txt | jq -r '.list['$i']|.clouds'` +R=`cat meteo5.txt | jq -r '.list['$i']|.rain'` +S=`cat meteo5.txt | jq -r '.list['$i']|.snow'` +Ws=`cat meteo5.txt | jq -r '.list['$i']|.speed'` +Wsd=`cat meteo5.txt | jq -r '.list['$i']|.deg'` + +# convert m/s to Km/s +WsKM=$(echo "3.6"*$Ws | bc) + + +# convert degreese to cardinal name + +if (($(echo "$Wsd>= 0" | bc))); then W_nc="N"; fi; + +if (($(echo "$Wsd>= 11.25" | bc))); then W_nc="N-NE"; fi; + +if (($(echo "$Wsd>= 33.25" | bc))); then W_nc="NE"; fi; + +if (($(echo "$Wsd>= 56.25" | bc))); then W_nc="E-NE"; fi; + +if (($(echo "$Wsd>= 78.75" | bc))); then W_nc="E"; fi; + +if (($(echo "$Wsd>= 101.25" | bc))); then W_nc="E-SE"; fi; + +if (($(echo "$Wsd>= 123.75" | bc))); then W_nc="SE"; fi; + +if (($(echo "$Wsd>= 146.25" | bc))); then W_nc="S-SE"; fi; + +if (($(echo "$Wsd>= 168.75" | bc))); then W_nc="S"; fi; + +if (($(echo "$Wsd>= 191.25" | bc))); then W_nc="S-SW"; fi; + +if (($(echo "$Wsd>= 213.75" | bc))); then W_nc="SW"; fi; + +if (($(echo "$Wsd>= 236.25" | bc))); then W_nc="W-SW"; fi; + +if (($(echo "$Wsd>= 258.75" | bc))); then W_nc="W"; fi; + +if (($(echo "$Wsd>= 281.25" | bc))); then W_nc="W-NW"; fi; + +if (($(echo "$Wsd>= 303.75" | bc))); then W_nc="NW"; fi; + +if (($(echo "$Wsd>= 326.25" | bc))); then W_nc="N-NW"; fi; + +if (($(echo "$Wsd>= 348.75" | bc))); then W_nc="N"; fi; + +if (($(echo "$Wsd> 360" | bc))); then W_nc="-?-"; fi; + +if (($(echo "$Wsd< 0" | bc))); then W_nc="-?-"; fi + +if [ "$Wsd" = "null" ]; then W_nc="-?-"; fi; + + +# print to video all data.. +echo " " +echo " " +echo " " $city_name","$L " " "Lat: "$Lat " " "Lon: "$Lon " " +echo " " "Forecast: "$data_U +echo " " +echo " " "Weather: "$Wcond_n"," $Wcond_nd +echo " " +echo " " "T.morn. (C°): "$TM " " "T.day (C°): "$TD " " "T.even. (C°): "$TE " " "T.night (C°): "$TN +echo " " +echo " " "Tmax (C°): "$Tmax" " "Tmin (C°): "$Tmin " " "Humidity (%): "$Hm +echo " " +echo " " "Pressure (hPa): "$PrS " " "Rain (mm): "$R " " "Snow (mm): "$S +echo " " +echo " " "Wind speed (km/h): "$WsKM " " "Wind deg (°): "$Wsd " " "Wind dir: "$W_nc +echo " " +echo " " + + done +} +forecast5 \ No newline at end of file diff --git a/tools/rf5_README.md b/tools/rf5_README.md new file mode 100644 index 0000000..32d4a2d --- /dev/null +++ b/tools/rf5_README.md @@ -0,0 +1,10 @@ +# rf5: + +**rf5**: read and print on video the forecast 5 **jason data** (meteo5.txt) generated to fmeteo. + +The script is a utility to test a future implementation on fmeteo, or read the **old** forecast 5 data, offline. + + +# use: + +For use this, put or copy the script, in the same directory of fmeteo and run it. \ No newline at end of file diff --git a/tools/rf5_cangelog.md b/tools/rf5_cangelog.md new file mode 100644 index 0000000..6b288a4 --- /dev/null +++ b/tools/rf5_cangelog.md @@ -0,0 +1,3 @@ +# V.1.0 + +- initial relase \ No newline at end of file diff --git a/tools/rf5_version.md b/tools/rf5_version.md new file mode 100644 index 0000000..6af9b14 --- /dev/null +++ b/tools/rf5_version.md @@ -0,0 +1 @@ +V.1.0 \ No newline at end of file