Versions Compared

Key

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

...

The mfb files contain information about the observations used in the reanalyses, for example the forecast and analysis departure statistics, assumed observation error statistics, etc. This data is available at 00/12 each day. The example below is for rom_saf_21, and we retrieve all the GPS-RO data for the year 2014. This retrieval produces one file per month. The As above the user could then combine these 12 files if required,e.g.  cat month1 month2 > both_months.   

Code Block
languagepy
#!/usr/bin/env python
import calendar
from ecmwfapi import ECMWFDataServer
server = ECMWFDataServer()
 
def retrieve_rom_saf_mfb():
    """      
       A function to demonstrate how to iterate efficiently over several years and months etc    
       for a particular rom_saf mfb request.     
       Change the variables below to adapt the iteration to your needs.
       You can use the variable 'target' to organise the requested data in files as you wish.
       In the example below the data are organised in files per month. (eg "rom_saf_mfb_21_201410.odb")
       Each monthly file is ~1.2 Gb for GPSRO data used exp id = 21. 
    """
    yearStart = 2014
    yearEnd = 2014
    monthStart = 1
    monthEnd = 12
    for year in list(range(yearStart, yearEnd + 1)):
        for month in list(range(monthStart, monthEnd + 1)):
            startDate = '%04d%02d%02d' % (year, month, 1)
            numberOfDays = calendar.monthrange(year, month)[1]
            lastDate = '%04d%02d%02d' % (year, month, numberOfDays)
            target = "rom_saf_mfb_21_%04d%02d.odb" % (year, month)
            requestDates = (startDate + "/TO/" + lastDate)
            rom_saf_request(requestDates, target)
 
def rom_saf_request(requestDates, target):
    """      
        An ROM SAF request for a month of MFB observation data.
        Change the keywords below to adapt it to your needs.
        (eg to add or to remove  levels, parameters, times etc)
        
    """
    server.retrieve({
        "class"     : "ea",                                  # do not change
        "dataset"   : "rom_saf_21",                          # or "rom_saf_22"
        "expver"    : "21",                                  # or "22"
        "stream"    : "oper",                                # do not change
        "type"      : "mfb",                                 # do not change - only mfb's available for 21 and 22
        "date"      : requestDates,                          # dates, set automatically from above
        'obsgroup'  : '8',                                   # GPSRO - for other groups see https://apps.ecmwf.int/odbgov/group/
        "target"    : target,                                # output file name, set automatically from above
        "time"      : "00/12",                               # times of analysis (00 or 12 or both)
        "format"    : "odb",                                 # or ascii format
    })
if __name__ == '__main__':
    retrieve_rom_saf_mfb()

...