Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Confirmed.

Page info
infoTypeModified date
prefixLast modified on
typeFlat

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

In this example we work with the  ERA5 dataset, Let's say you hav a data file containing ERA5 data, specifically hourly surface pressure (sp) for the month 20032010-08.In case you do not have a data file yet, download test data: first install the ECMWF WebAPI , run this Python , in GRIB or NetCDF format, as specified in this data retrieval CDS API script:

Code Block
languagepy
#!/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",
})
collapsetrue
import cdsapi

c = cdsapi.Client()

c.retrieve(
    'reanalysis-era5-single-levels',
    {
        'product_type':'reanalysis',
        'variable':'surface_pressure',
        'year':'2010',
        'month':'08',
        '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 format and file name ------ 

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

# ----- For NetCDF version, specify format and file name ------ 

        'format':'netcdf',
    },
    'e5-sp-201008xx.nc')

This script retrives This download gives you a GRIB file 'e5-sp-201008xx.grib' and or a NetCDF file 'e5-sp-200308xx201008xx.nc'.

See also: How to download ERA5

Looking up data values in GRIB

We want to look up the surface pressure (sp) data value for 2010-08-05 00:00, at the model point closest to our target location lon=7.36 lat=43.89.

Install ECMWF ecCodes, then look up the data value with the grib_ls command:

bash
Code Block
language
grib_ls -l 43.89,7.36,1 -w dataDate=20100805,dataTime=0000 -p shortName e5-sp-201008xx.grib

Output:

language
Code Block
bash
...
shortName    value 
sp          88510       
...
Input Point: latitude=43.89  longitude=7.36
Grid Point chosen #3 index=84109 latitude=43.98 longitude=7.50 distance=15.11 (Km)
...

Looking up data values in NetCDF

We want to look up the surface pressure (sp) data value for 2010-08-05 00:00, at the model point closest to our target location lon=7.36 lat=43.89.

Install CDO, then look up the data value:

bash
Code Block
language
cdo -outputtab,lon,lat,date,time,value -selyear,2010 -selmonth,08 -selday,05 -seltime,00:00 -remapnn,lon=7.36_lat=43.89 e5-sp-201008xx.nc

Output:

bash
Code Block
language
#   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, while the NetCDF data was regridded.

Info
iconfalse

This document has been produced in the context of the Copernicus Atmosphere Monitoring Service (CAMS) and Copernicus Climate Change Service (C3S).

The activities leading to these results have been contracted by the European Centre for Medium-Range Weather Forecasts, operator of CAMS and C3S on behalf of the European Union (Delegation Agreement signed on 11/11/2014 and Contribution Agreement signed on 22/07/2021). All information in this document is provided "as is" and no guarantee or warranty is given that the information is fit for any particular purpose.

The users thereof use the information at their sole risk and liability. For the avoidance of all doubt , the European Commission and the European Centre for Medium - Range Weather Forecasts have no liability in respect of this document, which is merely representing the author's view.

Content by Label
showLabelsfalse
max5
spacesCKB
showSpacefalse
sorttitle
typepage
cqllabel in ("data","netcdf","grib") and type = "page" and space = "CKB"
labelscams c3s data download