Skip to content

Instantly share code, notes, and snippets.

@dewomser
Last active June 29, 2025 15:11
Show Gist options
  • Save dewomser/2d4cb21cc4647a6179636931de8b65ea to your computer and use it in GitHub Desktop.
Save dewomser/2d4cb21cc4647a6179636931de8b65ea to your computer and use it in GitHub Desktop.
Grafisch Luftqualität Vorhersage 96h Datenquelle DWD BETA
#!/bin/bash
# Dieses Skript ist Shellcheck-geprüft
#
most_recent_file="$(curl -s https://opendata.dwd.de/climate_environment/health/forecasts/air_quality/ | tail -n 3 | head -n 1)"
#echo "${most_recent_file:9:26}"
curl -o lq_forecast.csv https://opendata.dwd.de/climate_environment/health/forecasts/air_quality/"${most_recent_file:9:26}"
# Daten für die Station 'DERP023' extrahieren
echo "$(<lq_forecast.csv)" | grep -E ^\'DERP023\|^Station>derp023_data.csv
cut -f7- -d';' derp023_data.csv |tr -d h| tr -d + > data.csv
# Gnuplot-Skript
gnuplot << EOF
set datafile separator ";"
set terminal png size 800,600
set output 'plot.png'
set title "Vorhersage Luftqualität in Worms Quelle DWD"
set xlabel "Stunden Vorhersage"
set ylabel "Wert in PPM"
set xrange [1:96] # Angenommen, dass die Zeit in Stunden von 1 bis 96 reicht
set style data lines
set key autotitle columnhead left
ozon = 2 # counting starts from 0
no2 = 1
pm10 = 3
pm2_5= 4
# set key left
plot 'data.csv' matrix u 1:3 every :::no2::no2 w lp pt 7 lc "green" ti sprintf("Stickstoffdioxid / Reihe %d",no2), \
'' matrix u 1:3 every :::ozon::ozon w lp pt 7 lc "red" ti sprintf("Ozon / Reihe %d",ozon), \
'' matrix u 1:3 every :::pm10::pm10 w lp pt 7 lc "grey" ti sprintf("PM10 / Reihe %d",pm10), \
'' matrix u 1:3 every :::pm2_5::pm2_5 w lp pt 7 lc "brown" ti sprintf("PM2.5 / Reihe %d",pm2_5)
### end of code
EOF
@dewomser
Copy link
Author

plot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment