From f089fcbbfd01eab542e7d9d53f35912282f89afd Mon Sep 17 00:00:00 2001 From: "Daniel.Frisinghelli" <daniel.frisinghelli@eurac.edu> Date: Tue, 29 Jun 2021 10:14:03 +0200 Subject: [PATCH] Implemented download and preprocessing of ERA5 single level variables. --- climax/main/preprocess/download_ERA5.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/climax/main/preprocess/download_ERA5.py b/climax/main/preprocess/download_ERA5.py index 2dfd77b..cd78f2a 100644 --- a/climax/main/preprocess/download_ERA5.py +++ b/climax/main/preprocess/download_ERA5.py @@ -12,13 +12,9 @@ import cdsapi import numpy as np # locals -from climax.core.constants import ERA5_VARIABLES +from climax.core.constants import ERA5_P_VARIABLES, ERA5_VARIABLES from climax.main.config import ERA5_PATH -# ERA-5 product -product = 'reanalysis-era5-pressure-levels' -product_type = 'reanalysis' - # pressure levels pressure_levels = ['850', '500'] @@ -26,15 +22,14 @@ pressure_levels = ['850', '500'] years = [str(y) for y in np.arange(1981, 2011)] month = [str(m) for m in np.arange(1, 13)] days = [str(d) for d in np.arange(1, 32)] -time = ["{:02d}:00".format(t) for t in np.arange(0,24)] +time = ["{:02d}:00".format(t) for t in np.arange(0, 24)] # area of interest (Alps): North, West, South, East area = [52, 2, 40, 20] # ERA5 download configuration dictionary CONFIG = { - 'product_type': product_type, - 'pressure_level': pressure_levels, + 'product_type': 'reanalysis', 'month': month, 'day': days, 'time': time, @@ -59,6 +54,16 @@ if __name__ == '__main__': files = [output.joinpath('_'.join(['ERA5', var, year]) + '.nc') for year in years] + # check whether to download variable on pressure levels or single level + if var in ERA5_P_VARIABLES: + # download configuration: ERA5 variable on pressure levels + product = 'reanalysis-era5-pressure-levels' + CONFIG['pressure_level'] = pressure_levels # pressure levels + else: + # download configuration: ERA5 variable on single level + product = 'reanalysis-era5-single-levels' + CONFIG.pop('pressure_level') # remove pressure levels + # split the download to the different years: CDS API cannot handle # requests over the whole time period Parallel(n_jobs=min(len(years), os.cpu_count()), verbose=51)( -- GitLab