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

Download ERA5 reanalyis data.

parent ba528dd0
No related branches found
No related tags found
No related merge requests found
"""Download ERA-5 data from the Copernicus Climate Data Store."""
# !/usr/bin/env python
# -*- coding: utf-8 -*-
# builtins
import os
import pathlib
from joblib import Parallel, delayed
# externals
import cdsapi
import numpy as np
# ERA-5 product
product = 'reanalysis-era5-pressure-levels'
product_type = 'reanalysis'
# pressure levels
pressure_levels = ['850', '500']
# variables
variables = ['geopotential', 'temperature', 'u_component_of_wind',
'v_component_of_wind', 'specific_humidity']
# time period
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, 31)]
# area of interest (Europe): North, West, South, East
area = [52, 2, 40, 20]
# ERA5 download configuration dictionary
CONFIG = {
'product_type': product_type,
'variable': variables,
'pressure_level': pressure_levels,
'year': years,
'month': month,
'day': days,
'format': 'netcdf',
'area': area
}
# output path
target = pathlib.Path('/mnt/CEPH_PROJECTS/FACT_CLIMAX/REANALYSIS/ERA5/')
if __name__ == '__main__':
# initialize client
c = cdsapi.Client()
# download data for the different variables
Parallel(n_jobs=min(len(variables), os.cpu_count()), verbose=51)(
delayed(c.retrieve)(product, CONFIG.update({'variable': var}), str(
target.joinpath('_'.join(['ERA5', var, years[0], years[-1]])
+ '.nc'))) for var in variables)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment