Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Info
titleThe main idea in brief:
for HindcastYear from 2010 to 2014    
for HindcastMonth in 04, 06
for HindcastDay in HindcastDays
HindcastDate = HindcastYear-HindcastMonth-HindcastDay
S2S-request(HindcastDate) (see below anthe web API request example below)

...

A  simple web API example, requesting Control forecast, sfc

...

for one hdate

Code Block
languagepy
#!/usr/bin/env python
from ecmwfapi import ECMWFDataServer
server = ECMWFDataServer()
server.retrieve({
    "class": "s2",
    "dataset": "s2s",
    "date": ModelVersionDate, (ie "2014-05-01"),
    "expver": "prod",
    "hdate": HindcastDate, (ie the selected HindcastDate eg "2014-04-01"),
    "levtype": "sfc",
    "origin": "babj",
    "param": "165",
    "step": "0",
    "stream": "enfh",
    "target": "CHANGEME",
    "time": "00",
    "type": "cf",
})

...

 (info) Do you need more CMA re-forecast examples?

A

...

web API example requesting data for several hindcastDates (iterating over several hindcastYears, hindcastMonths and hindcastDays)

(lightbulb) Let's see how we can change the script above to iterate over several hindcastYears, hindcastMonths and hindcastDays efficiently

(grey lightbulb) Note that each hindcastDate is written into a separate file

(warning) Please note that the objective of the this python script below is  is only to demonstrate how to make a MARS request efficient via hindcastYears, hindcastMonths and hindcastDays iterations. You need to adapt it to your needs.

Code Block
languagepy
#!/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)

...