aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2023-08-25 12:48:51 +0200
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2023-08-25 12:48:51 +0200
commit27b78272512cf229fa5dfa52a376a04877cc7dfd (patch)
tree589ba95d69548f7710f18aac251eddb396e045f3 /test
parent7a4b8a91ce5b9bbd2ce806d2463e95634ad8b1a1 (diff)
downloadmeteo_toolbox-27b78272512cf229fa5dfa52a376a04877cc7dfd.tar.gz
move stuff
Diffstat (limited to 'test')
-rwxr-xr-xtest/grib.py56
-rwxr-xr-xtest/grib_info.py7
2 files changed, 63 insertions, 0 deletions
diff --git a/test/grib.py b/test/grib.py
new file mode 100755
index 0000000..767f3d7
--- /dev/null
+++ b/test/grib.py
@@ -0,0 +1,56 @@
+#!/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')
+
+# GRIB-Objekt wichtige attribute:
+# analDate
+# validDate
+# units
+# level
+# typeOfLevel
+# name
+# shortName
+
+for grb in grib:
+ #print(grb)
+ vals = grb.values
+
+ lats, lons = grb.latlons()
+
+ for k in grb.keys():
+ print(k)
+
+ print(grb.analDate)
+ print(grb.validDate)
+ print(grb.units)
+ print(grb.typeOfLevel)
+ break
+
+ # TODO Data in xarray?
+
+ 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/test/grib_info.py b/test/grib_info.py
new file mode 100755
index 0000000..1f3b5c7
--- /dev/null
+++ b/test/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)