How to export data (e.g. ERA-20C wave data) from ECMWF in GRIB format and easily convert it to CSV (Excel format) using Python (applied to Windows systems only)
1. Author: Nadezda Avanessova
Date: 08/10/2020
How to export data (e.g. ERA-20C wave data) from ECMWF in GRIB format and easily
convert it to CSV (Excel format) using Python (applied to Windows systems only):
1. Register at ecmwf and generate a key for your username:
https://confluence.ecmwf.int/display/WEBAPI/Install+ECMWF+API+Key
2. I saved that key (.ecmwfapi file) in the directory where I was working in (I used Anaconda
Prompt to do all steps) but you may use a different location.
3. Now install esmwf-api, it will require a key:
https://confluence.ecmwf.int/pages/viewpage.action?pageId=140378943
4. Alternatively you can simply download data from a dataset without using esmwf-api, e.g. :
https://apps.ecmwf.int/datasets/data/era20c-wave-daily/type=an/
5. When ecmwf-api is installed you have a great flexibility over what data and what time span
you can export, this source will give some idea how:
https://confluence.ecmwf.int/display/WEBAPI/Python+ERA-20c+examples
6. Using one of the two steps above you will get a .grib file, to visualise data in cmd and
convert it to a csv format you need to install eccodes package together with the library, use
the following two steps (I am using Anaconda, not sure how to do “forge” part without it).
7. $ pip install eccodes
8. $ conda install -c conda-forge eccodes
9. At step 8 it may get stuck at “Solving environment”, if it does, cancel “Solving environment”
by doing Ctrl+C and use this trick:
10. $ conda update -c conda-canary conda
11. Now try step 8 again.
12. Check if eccodes installed correctly:
13. python -m eccodes selfcheck
14. If selfcheck is successful, use the following instructions to convert your grib files to csv:
https://confluence.ecmwf.int/display/CKB/How+to+convert+GRIB+to+CSV