...
What is the best approach to get all hindcastDays for several HindcastYears ?
Info | ||
---|---|---|
| ||
The best approach is to iterate over the HindcastYears. For each HindcastYear iterate over all the available hindcastMonths and for each hindcastMonth iterate over all |
...
the available hindcastDays. At this point you may wish to check CMA availability and to view a CMA request |
Info | ||
---|---|---|
| ||
for HindcastYear in HindcastYears |
...
Code Block | ||
---|---|---|
| ||
#!/usr/bin/env python from ecmwfapi import ECMWFDataServer modelVersionDate = "2014-05-01" hindcastDate = "2014-04-01" # The selected hindcast date server = ECMWFDataServer() server.retrieve({ "class": "s2", "dataset": "s2s", "date": ModelVersionDate, "expver": "prod", "hdate": hindcastDate, "levtype": "sfc", "origin": "babj", "param": "165", "step": "0", "stream": "enfh", "target": "data.cf.sfc", "time": "00", "type": "cf", }) |
Info |
---|
If the request is "small" you may request more hindcastDates in one go. |
...
See the example below. |
A web API example requesting data for several hindcastDates (iterating over several hindcastYears, hindcastMonths and hindcastDays)
Info |
---|
|
...
|
...
By setting the variable "target" accordingly you can have each hindcastDate to be written on a separate file . |
Code Block | ||
---|---|---|
| ||
#!/usr/bin/env python from ecmwfapi import ECMWFDataServer server = ECMWFDataServer() def retrieve_data(hindcastDate): target = "target_s2s_%s.grb" % hindcastDate server.retrieve({ "class": "s2", "dataset": "s2s", "date": "2014-05-01", "expver": "prod", "hdate": hindcastDate, "levtype": "sfc", "origin": "babj", "param": "165", "step": "0", "stream": "enfh", "target": target, "time": "00", "type": "cf", }) for hindcastYear in ["2012", "2013"]: for hindcastMonth in ["08", "09"]: for hindcastDay in ["01", "02"]: hindcastDate = hindcastYear+hindcastMonth+hindcastDay retrieve_data(hindcastDate) |
...