...
The library provides a function that can be used to find out what the native type of a key value is.
In the C API, there Python interface there is a function called "codes_get_native_type" which 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
...
one of: "int", "float" or "str". E.g.
Code Block | ||
---|---|---|
| ||
gid = codes_grib_new_from_samples("GRIB2") codes_get_native_type(gid, "date") # returns int codes_get_native_type(gid, "referenceValue") # returns float codes_get_native_type |
...
(gid, "stepType") # returns str |
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.
Let's look at the types of various keys in a GRIB2 message:
...