GRIB

GRIB is the WMO’s format for binary gridded data consisting of GRIB messages, which in the earthkit terminology are called fields. The earthkit-data GRIB interface is based on ecCodes and can handle both GRIB edition 1 and edition 2.

Fieldlists

We can read/retrieve GRIB data with from_source(). The resulting object will be a GribFieldList representing a list of GribFields, which we can iterate through:

>>> import earthkit.data
>>> ds = earthkit.data.from_source("file", "docs/examples/test.grib")

>>> len(ds)
2

>>> for f in ds:
...     print(f)
...
GribField(2t,1000,20200513,1200,0,0)
GribField(msl,1000,20200513,1200,0,0)

The following table gives us an overview of the GRIB FieldList API:

Highlights of the GRIB FieldList API

Methods/Operators

API

Conversion to scientific Python objects

to_xarray()

Concatenation

Iteration

Selection with [...]

Selection with .sel()

sel()

Ordering with .order_by()

order_by()

Accessing data values

to_numpy()

Accessing metadata

metadata()

Inspecting contents

ls(), head() and tail()

Fields

A GribField represent a single GRIB field. It primarily offers methods to:

Examples: