You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 18 Next »

Background

We need to retrieve three types of files efficiently for the two reanalyses with experiment id = 21 and experiment id = 22. These are all class=ea. The three "streams" are oper, moda and mfb:

  • Stream: Atmospheric daily analyses (oper)
  • Stream: Monthly means of Daily Means (moda)
  • Stream: Observation departures for the data used in the reanalyses (mfb)

Retrieval of daily "oper" files

The availability of the oper files for experiment  = 21 is given here, and the availability of experiment = 22 is here. These pages also enable users to check data availability and estimate the download costs for the retrievals.

The example below retrieves geopotential and temperature on a set of pressure levels for "rom_saf_21" (experiment id = 21).  Its can be modified easily for rom_saf_22 (experiment id = 22). The request is for data from 20140101 to 20151231. For efficiency reasons, the retrieval is done one calendar month at a time.  These monthly files can be combined with the "cat" command if required. E.g., cat month1 month2 > both_months.   


#!/usr/bin/env python

import calendar
from ecmwfapi import ECMWFDataServer

server = ECMWFDataServer()
 
def retrieve_rom_saf():
    """      
       A function to demonstrate how to iterate efficiently over several years and months etc    
       for a particular rom_saf 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_21_daily_201510.nc")
    """
    yearStart = 2014
    yearEnd = 2015
    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_21_daily_%04d%02d.nc" % (year, month)  # or name rom_saf_22_ ...
            requestDates = (startDate + "/TO/" + lastDate)
            rom_saf_request(requestDates, target)
 
def rom_saf_request(requestDates, target):
    """      
        An ROM SAF request for analysis pressure level data.
        Change the keywords below to adapt it to your needs.
        (eg to add or to remove  levels, parameters, times etc)
        Request cost per month is 3472 fields, ~200 Mbytes
    """
    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": "an",                                      # analysis (versus forecast, fc)
        "date": requestDates,                              # dates, set automatically from above
        "levtype": "pl",                                   # pressure level data (versus surface, sfc, and model level, ml)
        "levelist": "100/500/700/750/850/925/1000",        # levels, required only with levtype:pl and levtype:ml
        "param": "129.128/130.128",                        # Geopotential height, Temperature (T), see http://apps.ecmwf.int/codes/grib/param-db
        "target": target,                                  # output file name, set automatically from above
        "time": "00/03/06/09/12/15/18/21",                 # times of analysis (with type:an), or initialization time of forecast (with type:fc)
        "grid": "1.5/1.5",                                 # Optional for GRIB, required for NetCDF. The horizontal resolution in decimal degrees. If not set, the archived grid as specified in the data documentation is used.
        "format": "netcdf",                                # Optional. Output in NetCDF format. Requires that you also specify 'grid'. If not set, data is delivered in GRIB format, as archived.
    })
if __name__ == '__main__':
    retrieve_rom_saf()












  • No labels