Versions Compared

Key

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

...

In this example we work with the  ERA5 dataset, hourly surface pressure (sp) for the month 2010-08, in GRIB and or NetCDF format, as specified in this data retrieval CDS API script:

Code Block
languagepy
collapsetrue
#!/usr/bin/env python
from ecmwfapi import ECMWFDataServer
serverimport cdsapi

c = ECMWFDataServercdsapi.Client()

serverc.retrieve(
    'reanalysis-era5-single-levels',
    {
     "class": "ea",
   'product_type':'reanalysis',
        'variable':'surface_pressure',
       "dataset": "era5",
 'year':'2010',
        'month':'08',
      "date": "2010-08-01/to/2010-08-31",
    "expver": "1",
    "levtype": "sfc",
    "param": "134.128",
    "stream": "oper",
    "time": "00/to/23/by/1",
    "type": "an",
      'day':[
            '01','02','03',
            '04','05','06',
            '07','08','09',
            '10','11','12',
            '13','14','15',
            '16','17','18',
            '19','20','21',
            '22','23','24',
            '25','26','27',
            '28','29','30',
            '31'
        ],
        'time':[
            '00:00','01:00','02:00',
            '03:00','04:00','05:00',
            '06:00','07:00','08:00',
            '09:00','10:00','11:00',
            '12:00','13:00','14:00',
            '15:00','16:00','17:00',
            '18:00','19:00','20:00',
            '21:00','22:00','23:00'
        ]
 # ----- For GRIB version, specify targetformat and file name ------ 

    "target": "     'format':'grib',
    },
    'e5-sp-201008xx.grib",
    ')

# ----- For NetCDF version, specify grid, format and target file name ------ 
 
   "grid": "0.5/0.5",
    "'format"': "'netcdf"',
    },
   "target": "'e5-sp-201008xx.nc",
 })')

This script retrives a GRIB file 'e5-sp-201008xx.grib' and or a NetCDF file 'e5-sp-201008xx.nc'.

...