Created
February 21, 2018 16:47
-
-
Save hydrogo/7130e1cc251b4113ef2768372cb6815c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import numpy as np | |
import datetime | |
import ecmwfapi | |
import xarray as xr | |
from collections import OrderedDict | |
dates = pd.Series([d.strftime("%Y-%m-%d") for d in pd.date_range("1979-01-01", "2016-12-31", freq="1D")], | |
index=pd.date_range("1979-01-01", "2016-12-31", freq="1D")) | |
periods = [dates[str(year)+"-"+str(month)][0] + "/to/" + dates[str(year)+"-"+str(month)][-1] | |
for year in range(1979, 2017) for month in range(1, 13)] | |
server = ecmwfapi.ECMWFDataServer() | |
for period in periods[:1]: | |
filename = period[:4]+period[5:7]+"_tmin.nc" | |
data_dict = {"class": "ei", | |
"dataset": "interim", | |
"stream": "oper", | |
"expver": "1", | |
"date": period, # month i need | |
"type": "fc", | |
"levtype": "sfc", | |
"param": "201.128", # 'Maximum temperature at 2 metres since previous post-processing' and 'Minimum temperature at 2 metres since previous post-processing' | |
"step": "3/6/9/12", # 4 steps per forecast | |
"time": "00:00:00/12:00:00", # 2 forecasts per day | |
"grid": "0.125/0.125", | |
"format": "netcdf", | |
"target": filename, # change this to your output file name | |
} | |
server.retrieve(data_dict) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment