grib

Utilities for working with GRIB parameters.

See https://codes.ecmwf.int/grib/param-db/ for more information.

anemoi.utils.grib.shortname_to_paramid(shortname: str, **filters) int

Return the GRIB parameter id given its shortname.

Parameters:
  • shortname (str) – Parameter shortname.

  • filters (Any) – Additional filters to disambiguate parameters with the same shortname (e.g. origin, encoding, table, discipline, category).

Returns:

  • int – Parameter id.

  • >>> shortname_to_paramid(“2t”)

  • 167

anemoi.utils.grib.paramid_to_shortname(paramid: int, **filters) str

Return the shortname of a GRIB parameter given its id.

Parameters:
  • paramid (int) – Parameter id.

  • filters (Any) – Additional filters to disambiguate parameters with the same shortname (e.g. origin, encoding, table, discipline, category).

Returns:

  • str – Parameter shortname.

  • >>> paramid_to_shortname(167)

  • ’2t’

anemoi.utils.grib.units(param: int | str) str

Return the units of a GRIB parameter given its name or id.

Parameters:

param (int or str) – Parameter id or name.

Returns:

  • str – Parameter unit.

  • >>> unit(167)

  • ’K’

anemoi.utils.grib.must_be_positive(param: int | str) bool

Check if a parameter must be positive.

Parameters:

param (int or str) – Parameter id or shortname.

Returns:

  • bool – True if the parameter must be positive.

  • >>> must_be_positive(“tp”)

  • True