diff options
-rw-r--r-- | Readme.md | 5 | ||||
-rwxr-xr-x | grib.py | 37 | ||||
-rwxr-xr-x | grib_info.py | 7 | ||||
-rwxr-xr-x | icon_download.sh | 26 | ||||
-rw-r--r-- | requirements.txt | 2 |
5 files changed, 71 insertions, 6 deletions
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 @@ -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 + +# <BASE>/<RUN>/<PARAMETER>/icon-d2_regular-lat-lon_pressure-level_<INIT>_<OFFSET>_<LEVEL>_<PARAMETER> + +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 |