Much of the data provided by the Copernicus Atmosphere Monitoring Service (CAMS), the Copernicus Climate Change Service (C3S), and by meteorological centres like ECMWF comes in GRIB or NetCDF format. This article gives examples how to extract data for a specific location and/or time from a GRIB or NetCDF file.
Download data
Let's say you have a data file containing In this example we work with ERA5 data, specifically hourly surface pressure (sp) for the month 2010-08.In case you do not have a data file yet, download test data: first install the ECMWF WebAPI , then run this Python , as specified in this data retrieval script:
Code Block | ||||
---|---|---|---|---|
| ||||
#!/usr/bin/env python from ecmwfapi import ECMWFDataServer server = ECMWFDataServer() server.retrieve({ "class": "ea", "dataset": "era5", "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", "target": "e5-sp-201008xx.grib", }) server.retrieve({ "class": "ea", "dataset": "era5", "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", "grid": "0.5/0.5", "format": "netcdf", "target": "e5-sp-201008xx.nc", }) |
This download gives you script retrives a GRIB file 'e5-sp-201008xx.grib' and a NetCDF file 'e5-sp-201008xx.nc', containing surface pressure for the month 2010-08, hourly, with global coverage.
Looking up data values in GRIB
...