Installing ecmwf package in conda 2.7

in #ecmwf7 years ago

When dealing with weather and climate data, ECMWF reanalysis are a great data set to work with.

In this post my task was download a huge amount of reanalysis from ECMWF website. They have an impressive interface for download and search. Anyway, for my needs I had to do it in a programmatic way. For this I followed the steps described in here.

Basically we can just type in terminal inside conda environment (attention: no sudo is necessary!)


pip install https://software.ecmwf.int/wiki/download/attachments/56664858/ecmwf-api-client-python.tgz

Before try any code, it is necessary remember that, according with the same page of ecmwf, we have the following code. Three points are needed here:

  • The original code available in the site does not explicitly choose the output data format. Here I set up for download directly to netcdf format in the format key.
    param key is very specific and I really did not find a comprehensive and clear reference for all variables

  • You must to create a $HOME/.ecmwfapirc and paste your private key or it won't connect (dear windows user, I have no idea about how you can do it). At this point you already have a login in the ecmwf site, so you can just follow this address in order to get your own key https://api.ecmwf.int/v1/key/

All said, you can use the following script to download your reanalysis. All you need is to choose the date range in date and the variables you needs (here, 165.128 means temperature and 228.168 is for precipitation).

#!/usr/bin/env python
from ecmwfapi import ECMWFDataServer

server = ECMWFDataServer()

server.retrieve({
'stream' : "oper",
'levtype' : "sfc",
'param' : "165.128/228.168",
'dataset' : "interim",
'step' : "12",
'grid' : "0.75/0.75",
'time' : "00/12",
'date' : "2014-07-01/to/2014-07-31",
'type' : "an",
'class' : "ei",
'format' : "netcdf",
'target' : "interim_2014-07-01to2014-07-31_00061218.nc"
})

OBS: You can download a more sophisticated version of this code in my github.

Coin Marketplace

STEEM 0.16
TRX 0.13
JST 0.027
BTC 60629.29
ETH 2636.33
USDT 1.00
SBD 2.51