From 037e23d4109869559549d10d1e66c78dfd319008 Mon Sep 17 00:00:00 2001 From: Jonas Gunz Date: Fri, 19 Jan 2024 19:38:06 +0100 Subject: aggregator dwd_icon add force_filename --- aggregator/dwd_icon.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'aggregator') diff --git a/aggregator/dwd_icon.py b/aggregator/dwd_icon.py index 88288f3..0827469 100755 --- a/aggregator/dwd_icon.py +++ b/aggregator/dwd_icon.py @@ -97,18 +97,21 @@ def clean_output_dir(directory, target): for f in to_delete: os.unlink(os.path.join(directory, f)) -def load_data(name, output, description = None, clean = False, **kwargs): - run, date = get_current_run() - filename = f'{name}_{date}_{run}.grib2' - target = os.path.join(output, filename) - - if not os.path.exists(target): - download_dwd_gribs(date, run, target, output, **kwargs) - else: - print(f'{target} alreasy exists. Using the cached version.') - - if clean: - clean_output_dir(output, filename) +def load_data(name, output, description = None, clean = False, force_filename = None, **kwargs): + target = force_filename + + if target is None: + run, date = get_current_run() + filename = f'{name}_{date}_{run}.grib2' + target = os.path.join(output, filename) + + if not os.path.exists(target): + download_dwd_gribs(date, run, target, output, **kwargs) + else: + print(f'{target} already exists. Using the cached version.') + + if clean: + clean_output_dir(output, filename) ds = xr.load_dataset(target, engine='cfgrib') if description is not None: -- cgit v1.2.3