grib

Utilities for working with GRIB parameters.

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

anemoi.utils.grib.SETTINGS = AnemoiSettings(object_storage=ObjectStorageConfig(endpoint_url=None, skip_signature=False, access_key_id=None, secret_access_key=None, region=None, account_name=None, account_key=None, sas_token=None, type=None), datasets=DatasetsConfig(path=[], use_search_path_not_found=False, ignore_naming_conventions=False, named=DatasetsNamedConfig()), paramdb=ParamDBConfig(default_origin='ecmf', cache_length=30, local_cache=None), registry=RegistryConfig(api_url=None, api_token=None, allow_delete=False, plots_uri_pattern=None, datasets_uri_pattern=None, weights_uri_pattern=None, weights_platform=None), nexus=NexusConfig(api_url=None, api_token=None), utils=UtilsConfig(grids_path=None, cache_directory=PosixPath('/home/docs/.cache/anemoi'), debug_imports_in_cli=False))

Anemoi settings, loaded on module import.

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