Skip to end of metadata
Go to start of metadata

How is the CAMS Reanalysis monthly means of daily means (stream=moda) data organised in MARS?

In general it is organised, as a huge tree, with the indentation below, showing different levels down that tree:

What would be the natural way to group requests?

The idea is to request as much data as possible from the same tape file (star) . The natural way to group requests would be:
all parameters, all levels, all time-steps for all months of a decade.

(warning) Note: 'all' means 'all' that the user wants. It doesn't have to be all available parameters.

Web-API examples:

Example 1: A request for CAMS Reanalysis monthly means of daily means (stream=moda) data, pressure levels

  • The objective of this example is to demonstrate how to iterate efficiently over some years, for a particular CAMS Reanalysis, monthly, pressure level request.
  • At this point you may wish to have a look on the CAMS Reanalysis data availability
  • The request below can be used as a starting point, however you need to keep in mind that you have to adapt it to your needs e.g. to set the keyword, values according to your requirements (e.g. add or remove 'param', 'levtype', etc).
  • In this way you can extend this example to download a longer period or even the whole CAMS Reanalysis dataset.

#!/usr/bin/env python
import calendar
from ecmwfapi import ECMWFDataServer
server = ECMWFDataServer()
def retrieve_cams-reanalysis():
       A function to demonstrate how to retrieve CAMS Reanalysis monthly means data.     
       Change the variables below to adapt to your needs.

       CAMS Reanalysis monthly data is timestamped to the first of the month, hence dates 
       have to be specified as a list in this format:

       Data is stored on one tape per decade, so for efficiency we split the date range into 
       decades, hence we get multiple date lists by decade: 

       In the example below the output data are organised as one file per decade:
    yearStart = 2003                        # adjust to your requirements - as of 2017-11 only year 2003 is available 
    yearEnd = 2016                          # adjust to your requirements
    months = [1,2,3,4,5,6,7,8,9,10,11,12]   # adjust to your requirements

    years = range(yearStart, yearEnd+1)
    print 'Years: ',years
    decades = list(set([divmod(i, 10)[0] for i in years]))
    decades = [x * 10 for x in decades]
    print 'Decades:', decades

# loop through decades and create a month list
    for d in decades:
        for y in years:
            if ((divmod(y,10)[0])*10) == d:
                for m in months:
                    requestDates = requestDates+str(y)+(str(m)).zfill(2)+'01/'
        requestDates = requestDates[:-1]
        print 'Requesting dates: ', requestDates
        target = ''% (d)    # specifies the output file name
        print 'Output file: ', target
        cams-reanalysis_request(requestDates, d, target)

# the actual data request
def cams-reanalysis_request(requestDates, decade, target):
        Change the keywords below to adapt to your needs.
        The easiest way to do this is: 
        1. go to
        2. click through to the parameters you want, for any date
        3. click 'View the MARS request'
        'class': 'mc',                # do not change
        'dataset': 'cams_reanalysis', # do not change
        'expver': 'eac4',             # do not change
        'stream': 'moda',             # monthly means of daily means
        'type': 'an',                 # analysis (versus forecast, fc)
        'levtype': 'pl',              # surface data (versus pressure level, pl, and model level, ml)
        'levelist': '500/850/1000',   # selected pressure levels 
        'param': '4.210/130.128',     # Parameters. Here: Dust Aerosol mixing ratio (Bin 1) and Temperature
        'grid': '0.7/0.7',	          # Optional. The horizontal resolution in decimal degrees. If not set, the archived grid as specified in the data documentation is used.
        'area': '75/-20/10/60',	      # Optional. Subset (clip) to an area. Specify as N/W/S/E in Geographic lat/long degrees. Southern latitudes and western longitudes must be
                                      # given as negative numbers. Requires "grid" to be set to a regular grid, e.g. "0.7/0.7".
        'format': 'netcdf',           # Optional. Output in NetCDF format. Requires that you also specify 'grid'. If not set, data is delivered in GRIB format, as archived. 
        'date': requestDates,         # dates, set automatically from above
        'decade': decade,             # decade set automatically from above
        'target': target              # output file name, set automatically from above
if __name__ == '__main__':

Merging files

The example script above creates one output file per month of data. If you want a single output file:

For GRIB files, you can simply concatenate the files in Linux: cat file1 file2 file3 > file4

For NetCDF files (unsupported) see

Useful links



  • No labels