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

Compare with Current View Page History

« Previous Version 8 Next »

Step-by-step guide

For the moment there is no simple way of knowing what the type of a key value is. However, the library provides a function that can be used to find out what the native type of a key value is.
The function, available only in the C API, is called 'grib_get_native_type'. It returns an integer which can be checked against the following macros:

CODES_TYPE_UNDEFINED
CODES_TYPE_LONG
CODES_TYPE_DOUBLE
CODES_TYPE_STRING
CODES_TYPE_BYTES
CODES_TYPE_SECTION
CODES_TYPE_LABEL
CODES_TYPE_MISSING


As of version 2.14.0, one can use the grib_dump tool with the "-p" option to dump a given key and query its type with the "-t" option.
E.g.

% grib_dump -t -p identifier my.grib
  # type ascii (str)
  #-READ ONLY- identifier = GRIB;

% grib_dump -t -p referenceValue my.grib
  # type ieeefloat (double)
  #-READ ONLY- referenceValue = 45.67;

Here you can see that the key "identifier" is of type string and "referenceValue" is a double.


  • No labels