aboutsummaryrefslogtreecommitdiff
path: root/vertical_from_grib.py
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2023-09-12 12:13:06 +0200
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2023-09-12 12:13:06 +0200
commit459b4665e436a23a55202ccdfdaf5b3bb9c83416 (patch)
treeb2a6687dc07c07ff3d507b30a1e6f05cc6a74cf5 /vertical_from_grib.py
parent76a9a93d72ad3ff21854f532d64aca42c72c1ebf (diff)
downloadmeteo_toolbox-459b4665e436a23a55202ccdfdaf5b3bb9c83416.tar.gz
output dir
Diffstat (limited to 'vertical_from_grib.py')
-rwxr-xr-xvertical_from_grib.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/vertical_from_grib.py b/vertical_from_grib.py
index 9251410..934b248 100755
--- a/vertical_from_grib.py
+++ b/vertical_from_grib.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
+import os
import datetime
@@ -23,13 +24,14 @@ config = {
]
}
-def run(source, plots):
+def run(source, plots, output='.'):
+ misc.create_output_dir(output)
data = xr.load_dataset(source, engine='cfgrib')
for plot in plots:
- _plot(data, **plot)
+ _plot(data, output, **plot)
-def _plot(data, lat, lon, name, analysis=None):
+def _plot(data, output, lat, lon, name, analysis=None):
for_temp = data.sel(latitude=lat, longitude = lon, method='nearest')
for_temp = for_temp[['r', 't', 'u', 'v']]
@@ -65,7 +67,8 @@ def _plot(data, lat, lon, name, analysis=None):
init_for_filename = init.strftime('%Y-%m-%d-%HUTC')
- skt.plot(filename=f'skewt_{name}_{init_for_filename}+{hours_since_init_str}.png')
+ outname = f'skewt_{name}_{init_for_filename}+{hours_since_init_str}.png'
+ skt.plot(filename=os.path.join(output, outname))
if __name__ == '__main__':
run(**config)