Versions Compared

Key

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

...

Retrieval of "mfb" files


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_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 = "/scratch/rd/sti/mfb_test/rom_saf_mfb_%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 - 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()