Versions Compared

Key

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

...

Info

Following the previous paragraph,  the natural way to group requests would be:
all parameters, all levels, all members, all time-steps for 1 hindcast date.

(warning) Note the following:

  1. 'all' means 'all' that the user wants. It doesn't have to be all parameters.
  2. If a user is interested only on z500,  he may request more hindcast dates in one go, since the overall request will not be so big.

What is the best approach to loop over several hindcastDates  for a CMA request?

Info
titleThe main idea in brief:

for hindcastDate in hindcastDate-list hindcastDateList (eg, 2010-03-01 to 2010-03-31)
     S2S-request(hindcastDate)

(lightbulb) You may wish to have a look on some CMA re-forecast examples or to visit the ECMWF Web API Home

...

Info
titleThe main idea in brief:

(lightbulb) The best approach is to iterate over the HindcastYearshindcastYears. For each HindcastYear hindcastYear iterate over all the available hindcastMonths and for each hindcastMonth iterate over all the available hindcastDays.

(warning) At this point you may wish to check CMA availability and to view a CMA request

Info
titleThe main idea in brief:
for HindcastYearhindcastYear in HindcastYearshindcastYears
for hindcastMonth in hindcastMonths
for hindcastDay in hindcastDays
hindcastDate = HindcastYear-hindcastMonth-hindcastDay
S2S-request(hindcastDate)

...

Code Block
languagepy
#!/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": ModelVersionDatemodelVersionDate,
    "expver": "prod",
    "hdate": hindcastDate, 
    "levtype": "sfc",
    "origin": "babj",
    "param": "165",
    "step": "0",
    "stream": "enfh",
    "target": "data.cf.sfc",
    "time": "00",
    "type": "cf",
})

...

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

Info
  • The objective of this example is to demonstrate how to make a MARS request efficient by iterating properly. 
  • It can be used as a starting point however you need to adapt it to your needseg : to set the keyword values (eg hindcastYear)  according to your needs. don't forget , to check CMA availability (warning)

(grey lightbulb) By setting (lightbulb) Please note: use the variable "target" accordingly you can have   to write each hindcastDate to be written on a separate file .

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)

...