From ae709fdf1eb0df384835509a6c9500b69301d14c Mon Sep 17 00:00:00 2001 From: Jonas Gunz Date: Sun, 13 Aug 2023 21:02:42 +0200 Subject: asdf --- Readme.md | 5 +++++ grib.py | 37 +++++++++++++++++++++++++++++++++++++ grib_info.py | 7 +++++++ icon_download.sh | 26 ++++++++++++++++++++------ requirements.txt | 2 ++ 5 files changed, 71 insertions(+), 6 deletions(-) create mode 100644 Readme.md create mode 100755 grib.py create mode 100755 grib_info.py create mode 100644 requirements.txt diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..32de887 --- /dev/null +++ b/Readme.md @@ -0,0 +1,5 @@ +# meteo toolbox + +DTKE_CON for convection forecast? + +w_ctmax updraft velocity diff --git a/grib.py b/grib.py new file mode 100755 index 0000000..c298450 --- /dev/null +++ b/grib.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python3 +import pygrib + +# http://opendata.dwd.de/weather/nwp/icon-d2/grib/00/t/icon-d2_germany_regular-lat-lon_pressure-level_2023080200_000_1000_t.grib2.bz2 + +# ///icon-d2_regular-lat-lon_pressure-level____ + +GRIBDIR='dwd_icon-d2' + +# Flugplatz Saal a. d. Saale +target_lat='50.3108796' +target_lon='10.0646952' + +# Find nearest coords in model +# TODO + +grib = pygrib.open('dwd_icon-d2/combined.grib2') + + +for grb in grib: + print(grb) + vals = grb.values + + lats, lons = grb.latlons() + + print(grb.name) + #print(grb.level) + + #print('lats min/max: ', lats.shape, lats.max(), lats.min()) + #print('lons min/max: ', lons.shape, lons.max(), lons.min()) + + #print(vals.shape) + + #print(vals[100][::100]) + + #print(grb.latlons()) + diff --git a/grib_info.py b/grib_info.py new file mode 100755 index 0000000..1f3b5c7 --- /dev/null +++ b/grib_info.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python3 +import pygrib +import sys + +grib = pygrib.open(sys.argv[1]) +for grb in grib: + print(sys.argv[1], grb) diff --git a/icon_download.sh b/icon_download.sh index d461b48..cf00cca 100755 --- a/icon_download.sh +++ b/icon_download.sh @@ -9,27 +9,36 @@ MODEL=icon-d2 MODEL_LONG=icon-d2_germany BASE="http://opendata.dwd.de/weather/nwp" -RUN="00" -PARAMETERS=( "t" ) +RUN="15" +PARAMETERS=( "t" "relhum" "u" "v" "fi" ) +PARAMETERS_SINGLE_LEVEL=( "cape_ml" "cin_ml" "tot_prec" "w_ctmax" ) PRESSURE_LEVELS=( "1000" "975" "950" "850" "700" "600" "500" "400" "300" "250" "200" ) -OFFSETS=( "000" ) +OFFSETS=( "000" "003" "006" "009" "012" "015" "018" "024" ) DATE=$(date +%Y%m%d) mkdir -p $OUTDIR echo -n > "$OUTDIR/index.txt" -for PARAMETER in ${PARAMETERS[@]}; do - for OFFSET in ${OFFSETS[@]}; do +for OFFSET in ${OFFSETS[@]}; do + for PARAMETER in ${PARAMETERS[@]}; do for LEVEL in ${PRESSURE_LEVELS[@]}; do URL="$BASE/$MODEL/grib/$RUN/$PARAMETER/${MODEL_LONG}_regular-lat-lon_pressure-level_${DATE}${RUN}_${OFFSET}_${LEVEL}_${PARAMETER}.grib2.bz2" BNAME=$(basename "$URL") echo Getting "$URL" - echo "$BNAME" >> $OUTDIR/index.txt + echo "${BNAME%.bz2}" >> $OUTDIR/index.txt wget -q --directory-prefix=$OUTDIR "$URL" done done + + for PARAMETER in ${PARAMETERS_SINGLE_LEVEL[@]}; do + URL="$BASE/$MODEL/grib/$RUN/$PARAMETER/${MODEL_LONG}_regular-lat-lon_single-level_${DATE}${RUN}_${OFFSET}_2d_${PARAMETER}.grib2.bz2" + BNAME=$(basename "$URL") + echo Getting "$URL" + echo "${BNAME%.bz2}" >> $OUTDIR/index.txt + wget -q --directory-prefix=$OUTDIR "$URL" + done done echo Done downloading. Decompressing... @@ -38,4 +47,9 @@ for F in $OUTDIR/*.grib2.bz2; do bzip2 -df "$F" done +rm -f $OUTDIR/combined.grib2 + +grib_copy $OUTDIR/*.grib2 $OUTDIR/combined.grib2 || exit 1 +rm -f $OUTDIR/icon*.grib2 + echo Done. diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..7ce482f --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +metpy +pygrib -- cgit v1.2.3