Versions Compared

Key

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

...

The best approach is to iterate over the Hyears you wishHindcastYears. For each Hyear HindcastYear iterate over all Hmonths HindcastMonths and for each Hmonth HindcastMonth iterate over all its HdaysHindcastDays.

Info
titleThe main idea in brief:
for HindcastYear in HindcastYears
for HindcastMonth in HindcastMonths
for HindcastDay in HindcastDays
HindcastDate = HindcastYear-HindcastMonth-HindcastDay
S2S-request(HindcastDate)

An example to request Control forecast, sfc, for HindcastYears 2010 to 2014 for 2 HindcastMonths  (eg April and June)

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 the web API request example below)

A  simple web API example, requesting Control forecast, sfc for one

...

hindcast date for model version 2014-05-01 

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": ModelVersionDate,
    "expver": "prod",
    "hdate": HindcastDate, 
    "levtype": "sfc",
    "origin": "babj",
    "param": "165",
    "step": "0",
    "stream": "enfh",
    "target": "CHANGEMEdata.cf.sfc",
    "time": "00",
    "type": "cf",
})

...

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

  • So far so good!
  • Now, let's see how we can change the script above to iterate over several hindcastYears, hindcastMonths and hindcastDays efficiently
  • Please note that the The objective of this example is only to 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 keywords keyword values (eg hindcastYear)  according to your needs. 
    • Don't forget to check the availability (warning)
    • to make it more "pythonic" (wink)etc

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

...