diff options
author | Jonas Gunz <himself@jonasgunz.de> | 2024-01-19 19:38:06 +0100 |
---|---|---|
committer | Jonas Gunz <himself@jonasgunz.de> | 2024-01-19 19:38:06 +0100 |
commit | 037e23d4109869559549d10d1e66c78dfd319008 (patch) | |
tree | 0ab475288831f622e3478be0997fb3bb263a73ba /aggregator/dwd_icon.py | |
parent | d58bd789e396b08bdd43d0b9642231d79bb62dfa (diff) | |
download | meteo_toolbox-037e23d4109869559549d10d1e66c78dfd319008.tar.gz |
aggregator dwd_icon add force_filename
Diffstat (limited to 'aggregator/dwd_icon.py')
-rwxr-xr-x | aggregator/dwd_icon.py | 27 |
1 files changed, 15 insertions, 12 deletions
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: |