Author: Mattia C. Mancini -- (m.c.mancini@exeter.ac.uk)
Date: July 30th, 2024
This document goes through the steps required to download and process ERA5 reanalysis land hourly historic data for the purposes of driving the UK implementation of the WOFOST crop yield model.
Downloading and processing of the ERA5 reanalysis data is done using the download_and_process_era5.py
script, which allows to:
conda env create -f "full\path\of\environment.yml"
The full\path\of\environment.yml
is the full path of the environment.yml
file in the main project directory of the newly cloned repository.To use the ERA5 weather data downloader and processer, a series of steps are required.
Step 1: User registration with Copernicus ECMWF. To access the Copernicus Climate Data Store an account is required. As of the writing of this notebook, old accounts (registered before July 18th, 2024) are no longer working so users who registered in the past will need to register again given the CDS migration to the new infrastructure and new CDS engine. Equally, old API keys and endpoints will no longer work.
Step 2: set up the API access token and endpoint.
Downloads will be available through the use of the cdsapi python package which is installed through pip. If you install the Conda environmment defined in environment.yml
in the main project folder, this will be installed automatically.
An API access token is required for the API to work. This is available here (after log-in).
Once the access token has been generated, it must be stored in your $HOME
directory. For Windows machines, this is usually C:\Users\username\
(change 'username' to your own). To store the access token:
.cdsapirc
. Make sure that the file does not have a .txt extension to work properly..cdsapirc
file with a text editor and paste your access token retrieved from the CDS website. This will look something like:
url: https://cds-beta.climate.copernicus.eu/api
key: your_api_key
.cdsapirc
file.Step 3: accept the license to download the dataset of interest.
Each data type comes with a license that needs to be accepted before download. Clicking on the Download
tab for each dataset brings you to a page at the bottom of which there is a Terms of use
section which allows to read the terms of the license and accept them. Failing to accept the license will return a self explanatory error when trying to download the dataset using the API.
More information on the CDS system and the API set up is available here and here.
download_and_process_era5.py
contained in the main project directory.config.ini
file in the main project folder and edit the paths to point to locations on your disk where the data will need to be stored/read from. In particular:python download_and_process_era5.py --start XXXX --end YYYY --options download
where XXXX
and YYYY
are the start year and the end year for which data needs to be downloaded. The argument --options
is optional, and indicates whether the data needs to be dowloaded, processed or both. As such, it can take values of download
, for only donwloading the hourly data, process
, to only rechunk and assign already downloaded raw weather data to BNG. If left empty (i.e., python download_and_process_era5.py --start XXXX --end YYYY
), then the script will both download and process the data for the required time frame. The notebook era5_downloader.ipynb contains detailed instructions on how to set up and run the weatehr data downloader and processor.