ERA5 is the new dataset replacing the ERA-Interim data provided by our lovely hero: ECMWF. I usually used the ERA-Interim dataset to get the wave data, and now I am trying to use the ERA5. Thus, let’s take some notes on how to access it. (Disclaimer: I know NOTHING about python, so if you know better, please advise me 🙂 )
This is an easy explanation on how to setup the CDSAPI on your machine by using the Anaconda, and testing it to download a sample data. Information on this post is based on: Link.
First, we need to install the Anaconda (I am using the version 3.7) and install the CDSAPI
Once it installed, add the “program” and “Scripts” PATH to the environment variable. Note: I am using Windows 7 pro.
I used Anaconda Prompt as administrator, and then type: conda install cdsapi
Get your API Key
In order to access the ECMWF ERA5 database, we need a user and API key. To do this:
- create an account at CDS page, and log in.
- click on your account, and find your API Key (scroll down to the bottom of the page)
Configure the API Key using \.cdsapirc file
open a blank notepad and type:
url: https://cds.climate.copernicus.eu/api/v2
key: <UID>:<API key>
- save that notepad file to “C:\Users\Username\test.cdsapirc.txt” (I installed the Anaconda in C:\Users\Username\Anaconda3)
- close, and go to C:\Users\Username\ and rename the file:
- rename the ” test.cdsapirc.txt” to “.cdsapirc.” (source)
- done
Test your configuration by downloading a sample file (source).
Prepare a python code as follow and run it.
import cdsapi
c = cdsapi.Client()
c.retrieve('reanalysis-era5-pressure-levels', {
'variable' : 'temperature',
'pressure_level': '1000',
'product_type' : 'reanalysis',
'year' : '2008',
'month' : '01',
'day' : '01',
'time' : '12:00',
'format' : 'netcdf' # Supported format: grib and netcdf. Default: grib
}, 'test.nc')
In this exercise, I used Spider to run it. But if you got the cdsapi installation correct, you can also run it through command prompt, or just double click the file.
Enjoy!