The ERA-5 reanalysis: IRData.era5

This package retrieves and loads data from the ERA5 reanalysis.

To retrieve the data, it uses the ECMWF Public data API. You will need to install a key as described in the API documentation. Note that this is the same system used by IRData.cera20c - the same key will let you use that as well.

Only hourly data is supported (no daily or monthly averages) for 7 surface variables:

  • Mean-sea-level pressure: ‘mslp’
  • 2m air temperature: ‘air.2m’
  • Precipitation rate: ‘prate’
  • 10m meridional wind: ‘uwnd.10m’
  • 10m zonal wind: ‘vwnd.10m’
  • Sea-surface temperature: ‘sst’
  • Sea-ice coverage: ‘icec’

Data retrieved is stored in directory $SCRATCH/ERA5 - the ‘SCRATCH’ environment variable must be set. ERA 5 comes in two streams: the ‘oper’ stream is a single member analysis at highest resolution, and the ‘enda’ stream is a 10-member ensemble at lower resolution - both are supported.

For example:

import datetime
import IRData.era5 as era5
era5.fetch('prate',
           datetime.datetime(2015,3,12),
           stream='enda')

will retrieve precipitation rate data for the selected date. ERA5 data is fetched in one-calendar-month blocks, so this will retrieve data for the whole of March 2015. The retrieval is slow, as the data has to be fetched from MARS at ECMWF, but the retrieval is only run if necessary - if that month’s data has been previously fetched and is already on local disc, the fetch command will detect this and return instantly.

Once the data has been fetched,

pr=era5.load('prate',
             datetime.datetime(2015,3,12,15,15),
             stream='enda')

will then load the precipitation rates at quarter past 3pm on March 12 2015 from the retrieved dataset as a iris.cube.Cube. Note that as ERA5 only provides data at hourly or 3-hourly intervals, the value for 3:15pm will be interpolated between the outputs. Also, as ERA5 stream ‘enda’ is an ensemble dataset, the result will include all 10 ensemble members.


IRData.era5.fetch(variable, dtime, stream='enda')[source]

Get all data for one variable, for one month, from ECMWF’s archive.

Data wil be stored locally in directory $SCRATCH/ERA5, to be retrieved by load(). If the local file that would be produced already exists, this function does nothing.

Parameters:
  • variable (str) – Variable to fetch (e.g. ‘prmsl’).
  • dtime (datetime.datetime) – Date and time to get data for.
  • month (int) – Month to get data for (1-12).
  • stream (str) – Analysis stream to use, can be ‘enda’ - ensemble DA, or ‘oper’ - high res single member.

Will retrieve the data for the year and month of the given date-time. If the selected time is very close to the end of the calendar month, loading data for that time will also need data from the next calendar month (for interpolation). In this case, also fetch the data for the next calendar month.

Raises:StandardError – If variable is not a supported value.

IRData.era5.load(variable, dtime, stream='enda', fc_init=None)[source]

Load requested data from disc, interpolating if necessary.

Data must be available in directory $SCRATCH/ERA5, previously retrieved by fetch().

Parameters:
  • variable (str) – Variable to fetch (e.g. ‘prmsl’)
  • dtime (datetime.datetime) – Date and time to load data for.
  • fc_init (int) – If not None; 6 or 18. See below.
Returns:

Global field of variable at time.

Return type:

iris.cube.Cube

Note that ERA5 data is only output every 3 hours (enda) or hour (oper), so if hour%3!=0, the result may be linearly interpolated in time.

Precipitation data in ERA5 is a forecast field: twice a day (at 06:00 and 18:00) forecast data is calculated for the next 18 hours. So at 21:00, for example, there are 2 sets of precipitation available: a 3-hour forecast starting at 18 that day, and a 15-hour forecast starting at 06:00, and there is a discontinuity between the two fields. This function will always load the shortest lead-time forecast available unless fc_init is set (to 6 or 18) in which case it will load the forecast starting at the hour specified. You will only need this if you are making videos, or otherwise need time-continuous forecast fields, in which case you will need to be clever in smoothing over the discontinuity. For analysis fields (everything except prate), this issue does not arise and fc_init is ignored.

Raises:StandardError – Data not on disc - see fetch()