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
Installing your API key
To access ECMWF you will need an API key that can be obtained at https://api.ecmwf.int/v1/key/. Copy the information in this page and paste it in the file $HOME/.ecmwfapirc
Content $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:
Python client
#!/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 | Name | Licence | Proposed licence | Licence link |
---|---|---|---|---|
demeter | DEMETER Project | demeter_mnth | demeter | http://apps.ecmwf.int/datasets/data/demeter_mnth/licence/ |
gems_nrealtime | GEMS Reanalysis and Near Real-time | gems_nrealtime | gems | http://apps.ecmwf.int/datasets/data/gems_nrealtime/licence/ |
macc_reanalysis | MACC Reanalysis | |||
tigge | TIGGE | |||
tigge_lam' | TIGGE LAM | |||
yotc | YOTC | |||
interim | ERA Interim (Jan 1979 - present) | |||
era40 | ERA-40 (Sep 1957 - Aug 2002) | |||
era15 | ERA-15 (Jan 1979 - Dec 1993) |
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