From 459b4665e436a23a55202ccdfdaf5b3bb9c83416 Mon Sep 17 00:00:00 2001 From: Jonas Gunz Date: Tue, 12 Sep 2023 12:13:06 +0200 Subject: output dir --- horizontal.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'horizontal.py') 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={ -- cgit v1.2.3