aboutsummaryrefslogtreecommitdiff
path: root/xar.py
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2023-08-24 17:22:32 +0200
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2023-08-24 17:22:32 +0200
commitb85a2929e76ddc39f83ac0403f8356e05b71d129 (patch)
tree17a8e630d55d1d95bd6f071b07851665349e8586 /xar.py
parent60ab2d134df00f8099add774e698b2d7d2395bdc (diff)
downloadmeteo_toolbox-b85a2929e76ddc39f83ac0403f8356e05b71d129.tar.gz
stuff
Diffstat (limited to 'xar.py')
-rwxr-xr-xxar.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/xar.py b/xar.py
new file mode 100755
index 0000000..fca3887
--- /dev/null
+++ b/xar.py
@@ -0,0 +1,34 @@
+#!/usr/bin/env python3
+
+import xarray as xr
+from metpy.units import units
+import metpy.calc as mpcalc
+
+import skewt
+
+#grib = pygrib.open('dwd_icon-d2/combined.grib2')
+data = xr.load_dataset('dwd_icon-d2/combined.grib2', engine='cfgrib')
+
+lat = 47.9626
+lon = 11.9964
+
+for_temp = data.sel(latitude=lat, longitude = lon, method='nearest')
+
+for_temp = for_temp[['r', 't', 'u', 'v']]
+
+for step in for_temp.coords['step']:
+ this_step = for_temp.sel(step=step)
+
+ p = this_step.coords['isobaricInhPa'].values * units.hPa
+ T = this_step.t.values * units.K
+ relHum = this_step.r.values * units.percent
+ Td = mpcalc.dewpoint_from_relative_humidity(T, relHum)
+ u = this_step.u.values * (units.m / units.s)
+ v = this_step.v.values * (units.m / units.s)
+
+ skt = skewt.Skewt(p=p, T=T, Td=Td)
+ skt.addWindUV(u, v)
+ skt.addInfo("TEST")
+ skt.plot(filename=f'skewt.png')
+
+ break