aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xicon_download.sh8
-rw-r--r--misc.py9
-rwxr-xr-xvertical_from_grib.py22
3 files changed, 25 insertions, 14 deletions
diff --git a/icon_download.sh b/icon_download.sh
index aaa4be9..5c58b73 100755
--- a/icon_download.sh
+++ b/icon_download.sh
@@ -4,21 +4,23 @@
# <BASE>/<RUN>/<PARAMETER>/icon-d2_regular-lat-lon_pressure-level_<INIT>_<OFFSET>_<LEVEL>_<PARAMETER>
+# Detect latest with
+# curl https://opendata.dwd.de/weather/nwp/content.log.bz2 | bzip2 -d
+
NPROC=$(nproc)
OUTDIR=dwd_icon-d2
MODEL=icon-d2
MODEL_LONG=icon-d2_germany
-BASE="http://opendata.dwd.de/weather/nwp"
+BASE="https://opendata.dwd.de/weather/nwp"
-RUN="18"
+RUN="00"
PARAMETERS=( "t" "relhum" "u" "v" "fi" )
# tot_prec and cape_ml/cin_ml is in 15min intervals and screws with xygrib
PARAMETERS_SINGLE_LEVEL=( "w_ctmax" )
PRESSURE_LEVELS=( "1000" "975" "950" "850" "700" "600" "500" "400" "300" "250" "200" )
OFFSETS=( "000" "003" "006" "009" "012" "015" "018" "024" "027" "030" "033" "036" "039" "042" "045" "048" )
DATE=$(date +%Y%m%d)
-DATE=20230901
mkdir -p $OUTDIR
diff --git a/misc.py b/misc.py
new file mode 100644
index 0000000..90417f1
--- /dev/null
+++ b/misc.py
@@ -0,0 +1,9 @@
+import numpy as np
+import datetime
+
+def np_time_convert(dt64):
+ unix_epoch = np.datetime64(0, 's')
+ one_second = np.timedelta64(1, 's')
+ seconds_since_epoch = (dt64 - unix_epoch) / one_second
+
+ return datetime.datetime.utcfromtimestamp(seconds_since_epoch)
diff --git a/vertical_from_grib.py b/vertical_from_grib.py
index 759bca4..e5d6593 100755
--- a/vertical_from_grib.py
+++ b/vertical_from_grib.py
@@ -9,12 +9,7 @@ import numpy as np
import skewt
-def np_time_convert(dt64):
- unix_epoch = np.datetime64(0, 's')
- one_second = np.timedelta64(1, 's')
- seconds_since_epoch = (dt64 - unix_epoch) / one_second
-
- return datetime.datetime.utcfromtimestamp(seconds_since_epoch)
+import misc
config = {
'source':'dwd_icon-d2/combined.grib2',
@@ -22,7 +17,8 @@ config = {
{
'lat':47.9626,
'lon':11.9964,
- 'name':'Antersberg'
+ 'name':'Antersberg',
+ 'analysis':'lcl'
},
]
}
@@ -33,7 +29,7 @@ def run(config):
for plot in config['plots']:
_plot(data, **plot)
-def _plot(data, lat, lon, name):
+def _plot(data, lat, lon, name, analysis=None):
for_temp = data.sel(latitude=lat, longitude = lon, method='nearest')
for_temp = for_temp[['r', 't', 'u', 'v']]
@@ -47,8 +43,8 @@ def _plot(data, lat, lon, name):
u = this_step.u.values * (units.m / units.s)
v = this_step.v.values * (units.m / units.s)
- valid = np_time_convert(step.valid_time.values)
- init = np_time_convert(step.time.values)
+ valid = misc.np_time_convert(step.valid_time.values)
+ init = misc.np_time_convert(step.time.values)
valid_str = valid.strftime('%d %b %Y - %HUTC')
init_str = init.strftime('%d %b %Y - %HUTC')
@@ -60,7 +56,11 @@ def _plot(data, lat, lon, name):
skt.addInfo(f"VALID: {valid_str}")
skt.addInfo(f"INIT : {init_str}")
skt.addInfo(f"LAT {lat} LON {lon}")
- skt.addAnalysis(shade=True, analysis='lcl')
+
+ if analysis is not None:
+ skt.addAnalysis(shade=True, analysis=analysis)
+
+ # TODO get from source!
skt.addInfo("FORECAST DWD ICON-D2")
init_for_filename = init.strftime('%Y-%m-%d-%HUTC')