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.
In this example we work with the ERA5 datadataset, hourly surface pressure (sp) for the month 2010-08, in GRIB and NetCDF format, 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# ----- For GRIB version, specify target file name ------
"target": "e5-sp-201008xx.grib",
"levtype": "sfc",
"param": "134.128",
"stream": "oper",
"time": "00/to/23/by/1",
"type": "an",# ----- 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 a NetCDF file 'e5-sp-201008xx.nc'.
See also: How to download ERA5 data via the ECMWF Web API
Looking up data values in GRIB
...
| Code Block |
|---|
# lon lat date time value ... 7.36 43.89 2010-08-05 00:00:00 88360.6 ... |
Notes
The results from the GRIB and NetCDF versions are slightly different, because the GRIB data is in the original grid and resolution, whil eteh NetCDF data was regridded interpolated