diff options
author | Jonas Gunz <himself@jonasgunz.de> | 2023-09-12 12:13:06 +0200 |
---|---|---|
committer | Jonas Gunz <himself@jonasgunz.de> | 2023-09-12 12:13:06 +0200 |
commit | 459b4665e436a23a55202ccdfdaf5b3bb9c83416 (patch) | |
tree | b2a6687dc07c07ff3d507b30a1e6f05cc6a74cf5 /horizontal.py | |
parent | 76a9a93d72ad3ff21854f532d64aca42c72c1ebf (diff) | |
download | meteo_toolbox-459b4665e436a23a55202ccdfdaf5b3bb9c83416.tar.gz |
output dir
Diffstat (limited to 'horizontal.py')
-rwxr-xr-x | horizontal.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/horizontal.py b/horizontal.py index 280599f..02e45b1 100755 --- a/horizontal.py +++ b/horizontal.py @@ -1,4 +1,6 @@ #!/usr/bin/env python3 +import os + import xarray as xr import numpy as np @@ -30,13 +32,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, name, layers, area = None): +def _plot(data, output, name, layers, area = None): for step in data.coords['step']: this_step = data.sel(step=step) @@ -68,7 +71,8 @@ def _plot(data, name, layers, area = None): pc.panels = [panel] pc.draw() #pc.show() - pc.save(f'{name}_{init_for_filename}+{hours_since_init_str}.png') + outname = f'{name}_{init_for_filename}+{hours_since_init_str}.png' + pc.save(os.path.join(output, outname)) def _layer(data, layertype, **kwargs): layertypes={ |