Accessing the batch service with Python
Installing the Python library
You can install the ecmwfapi
python library by running:
sudo pip install https://software.ecmwf.int/wiki/download/attachments/23694554/ecmwf-api-python-client.tgz
If you cannot run the sudo
command, just download the ecmwf-api-python-client.tgz, extract its content and copy the module ecmwfapi
to a directory pointed by the environment variable PYTHONPATH
.
Installing your API key
To access ECMWF you will need an API key. For that you first need to login at https://apps.ecmwf.int/auth/login/ and then retrieve you key at https://api.ecmwf.int/v1/key/. For this, you will need to have an account on ECMWF web site. Copy the information in this page and paste it in the file $HOME/.ecmwfapirc.
{ "url" : "https://api.ecmwf.int/v1", "key" : "XXXXXXXXXXXXXXXXXXXXXX", "email" : "john.smith@example.com" }
Sample Python script
Below is a simple Python script making use of the ecmwfapi
library:
#!/usr/bin/env python from ecmwfapi import ECMWFDataServer server = ECMWFDataServer() server.retrieve({ 'dataset' : "tigge", 'step' : "24/to/120/by/24", 'number' : "all", 'levtype' : "sl", 'date' : "20071001/to/20071003", 'time' : "00/12", 'origin' : "all", 'type' : "pf", 'param' : "tp", 'area' : "70/-130/30/-60", 'grid' : "2/2", 'target' : "data.grib" })
The "dataset
" parameter is one of:
dataset | alternative | Name | Licence | Proposed licence | Licence link |
---|---|---|---|---|---|
api...v1/datasets/demeter/requests | demeter | DEMETER Project | demeter_mnth | research | http://apps.ecmwf.int/datasets/data/demeter_mnth/licence/ |
gems_nrealtime | gems | GEMS Reanalysis and Near Real-time | gems_nrealtime | gems | http://apps.ecmwf.int/datasets/data/gems_nrealtime/licence/ |
macc_reanalysis | macc | MACC Reanalysis | macc_reanalysis | macc_reanalysis | http://apps.ecmwf.int/datasets/data/macc_reanalysis/ |
tigge | tigge/global | TIGGE | tigge | tigge | http://apps.ecmwf.int/datasets/data/tigge/licence/ |
tigge_lam | tigge/lam | TIGGE LAM | tigge_lam | tigge_lam | http://apps.ecmwf.int/datasets/data/tigge_lam/licence/ |
yotc | yotc | YOTC | yotc_od | general | http://apps.ecmwf.int/datasets/data/yotc_od/licence/ |
interim | era/interim | ERA Interim (Jan 1979 - present) | interim_full_daily | general | http://apps.ecmwf.int/datasets/data/interim_full_daily/licence/ |
interim_land | era/interim/sfc | ERA Interim/LAND (Jan 1979 - Dec 2010) | interim_land | general | http://apps.ecmwf.int/datasets/data/interim_land/ |
era40 | era/era40 | ERA-40 (Sep 1957 - Aug 2002) | era40_daily | general | http://apps.ecmwf.int/datasets/data/era40_daily/licence/ |
era15 | era/era15 | ERA-15 (Jan 1979 - Dec 1993) | era15 | general | http://apps.ecmwf.int/datasets/data/era40_daily/licence/ |
era_clim_ispd | era/clim/ispd | ISPD v2.2 | ispd | research | http://apps.ecmwf.int/datasets/data/ispd/licence/ |
era_clim_icoads | era/clim/icoads | ICOADS v2.5.1 with interpolated 20CR feedback | icoads | research | http://apps.ecmwf.int/datasets/data/icoads/ |
20cr | ? | NOAA/CIRES 20th Century Reanalysis version II | ? | ? | |
JMA 55 year Reanalysis | ? |
To access these dataset, you need to agree on the the corresponding terms and conditions that can be found at http://apps.ecmwf.int/datasets/
The other parameters are described at: http://www.ecmwf.int/publications/manuals/mars/guide/index.html