diff options
author | Jonas Gunz <himself@jonasgunz.de> | 2023-11-07 00:22:43 +0100 |
---|---|---|
committer | Jonas Gunz <himself@jonasgunz.de> | 2023-11-07 00:22:43 +0100 |
commit | 637edcf7b9da61edebfe5c8d0c7bafea3543ebba (patch) | |
tree | 6c557cf8fb984b91d9905afe99fca9b9112c7ffd /aggregator/dwd_icon.py | |
parent | 6eb5ee144d5e730616f13d3d14129f0205282d90 (diff) | |
download | meteo_toolbox-637edcf7b9da61edebfe5c8d0c7bafea3543ebba.tar.gz |
description in aggregator
Diffstat (limited to 'aggregator/dwd_icon.py')
-rwxr-xr-x | aggregator/dwd_icon.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/aggregator/dwd_icon.py b/aggregator/dwd_icon.py index b8a4470..2bd3a61 100755 --- a/aggregator/dwd_icon.py +++ b/aggregator/dwd_icon.py @@ -45,7 +45,7 @@ def unpack_bz2(dest): def download_dwd_gribs( date, run, target, output, model, steps, model_long, pressure_level_parameters, parameter_caps_in_filename, - single_level_parameters + single_level_parameters, pressure_levels ): misc.create_output_dir(output) @@ -54,14 +54,14 @@ def download_dwd_gribs( for step in steps: step_str = f'{step:03d}' - for parameter in config['pressure_level_parameters']: - parameter2 = parameter.upper() if config['parameter_caps_in_filename'] else parameter + for parameter in pressure_level_parameters: + parameter2 = parameter.upper() if parameter_caps_in_filename else parameter - for level in config['pressure_levels']: + for level in pressure_levels: filename = f'{model_long}_regular-lat-lon_pressure-level_{date}{run}_{step_str}_{level}_{parameter2}.grib2.bz2' URL = f'{BASE}/{model}/grib/{run}/{parameter}/{filename}' - to_download.append((URL, os.path.join(config['output'], filename))) + to_download.append((URL, os.path.join(output, filename))) for parameter in single_level_parameters: parameter2 = parameter.upper() if parameter_caps_in_filename else parameter @@ -89,7 +89,7 @@ def download_dwd_gribs( if res.returncode != 0: print('rm failed with: ', res.stderr) -def load_data(name, output, **kwargs): +def load_data(name, output, description = None, **kwargs): run, date = get_current_run() target = os.path.join(output, f'{name}_{date}_{run}.grib2') @@ -98,7 +98,11 @@ def load_data(name, output, **kwargs): else: print(f'{target} alreasy exists. Using the cached version.') - return xr.load_dataset(target, engine='cfgrib') + ds = xr.load_dataset(target, engine='cfgrib') + if description is not None: + ds.attrs['_description'] = description + return ds + debug_config = { 'output':'dwd_icon-eu', |