You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »


Documentation

The ecCodes Python API is documented at:

There are examples of how to use it at:

Other useful resources:

Preliminaries

Login to ecs-login and work in your $SCRATCH

$> cd $SCRATCH

Make a copy of the practicals directory in your $SCRATCH to Atos:

$> tar –xvf /home/trx/grib_practicals.tar

This will create a directory in your $SCRATCH called grib_practicals containing the GRIB data files for this tutorial.

There are sub-directories for each practical:

$> ls $SCRATCH/grib_practicals

inspect  modify  python

For this tutorial cd to the python directory:

$> cd $SCRATCH/grib_practicals/python


Remember to load the ecmwf-toolbox !

$> module load ecmwf-toolbox

This tutorial covers the following topics:


Using the Python API to decode messages in a GRIB file

The directory contains an example Python script called eccodes_demo.py which decodes data via a call to a function called grib_dump and some GRIB messages to be decoded in a file called grib_file.grib

Run the Python script unchanged and redirect the output to a file using:

$> ./eccodes_demo.py > output

Look at the text information written to the file called output.  Compare with the output obtained with the grib_ls and grib_dump commands:

$> grib_ls grib_file.grib
...

$> grib_dump grib_file.grib

Your challenge is to change the Python script eccodes_demo.py to replace the call to the function codes_dump with several calls to codes_get or codes_get_array to decode the values for the edition, date, time, paramId (or shortName) and level keys.  Add your own print statements to output this information.


  • No labels