You might find it easier to handle data in a CSV file instead of a GRIB file. This article demonstrates how to extract data from a GRIB file using ECMWF's ecCodes and save the output as a CSV file. You are expected to have ecCodes installed on a Linux machine before you continue. You are also recommended to add ecCodes' bin directory to your PATH. Work below was tested with ecCodes 2.5.0.
- Download 2m temperature from the Copernicus Climate Change Service (C3S)'s Climate Data Store (CDS) and save the data as file t2m_20000801.grib. In this example, selections are set as below:
- Dataset: ERA5 hourly data on single levels from 2000 to 2017 (you may see different years as new data is released)
- Parameter : 2m temperature
- Product type: Reanalysis
- Year : 2000
- Month : August
- Day : 01
- Time : 06:00, 12:00 and 18:00
- Format : GRIB
Check the GRIB file by issuing command grib_ls -P time t2m_20000801.grib, you should see three GRIB messages in the file at three different times: 600, 1200, 1800 as shown below. Remember three time values were selected in step 1. Option -P time shows key "time", typing grib_ls for help.
Say I want to extract lat, lon, 2t (2m temperature) at time = 12:00 from the GRIB file. Run command grib_get_data -w time=1200 t2m_20000801.grib > temp.csv and you will get a file containing data like below. Option -w time=1200 filters data for time = 12:00 only, typing grib_get_data for help.
Format the CSV file. You may use script below.
You have a CSV file t2m_20000801.csv, which is ready to be imported in Excel. Notice there are over 1 million records in the file! You may now want to extract data for time=600 and 1800.