Skip to content
Snippets Groups Projects
Commit f089fcbb authored by Frisinghelli Daniel's avatar Frisinghelli Daniel
Browse files

Implemented download and preprocessing of ERA5 single level variables.

parent 05f9824c
No related branches found
No related tags found
No related merge requests found
...@@ -12,13 +12,9 @@ import cdsapi ...@@ -12,13 +12,9 @@ import cdsapi
import numpy as np import numpy as np
# locals # 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 from climax.main.config import ERA5_PATH
# ERA-5 product
product = 'reanalysis-era5-pressure-levels'
product_type = 'reanalysis'
# pressure levels # pressure levels
pressure_levels = ['850', '500'] pressure_levels = ['850', '500']
...@@ -26,15 +22,14 @@ pressure_levels = ['850', '500'] ...@@ -26,15 +22,14 @@ pressure_levels = ['850', '500']
years = [str(y) for y in np.arange(1981, 2011)] years = [str(y) for y in np.arange(1981, 2011)]
month = [str(m) for m in np.arange(1, 13)] month = [str(m) for m in np.arange(1, 13)]
days = [str(d) for d in np.arange(1, 32)] 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 of interest (Alps): North, West, South, East
area = [52, 2, 40, 20] area = [52, 2, 40, 20]
# ERA5 download configuration dictionary # ERA5 download configuration dictionary
CONFIG = { CONFIG = {
'product_type': product_type, 'product_type': 'reanalysis',
'pressure_level': pressure_levels,
'month': month, 'month': month,
'day': days, 'day': days,
'time': time, 'time': time,
...@@ -59,6 +54,16 @@ if __name__ == '__main__': ...@@ -59,6 +54,16 @@ if __name__ == '__main__':
files = [output.joinpath('_'.join(['ERA5', var, year]) + '.nc') for files = [output.joinpath('_'.join(['ERA5', var, year]) + '.nc') for
year in years] 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 # split the download to the different years: CDS API cannot handle
# requests over the whole time period # requests over the whole time period
Parallel(n_jobs=min(len(years), os.cpu_count()), verbose=51)( Parallel(n_jobs=min(len(years), os.cpu_count()), verbose=51)(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment