Skip to content

CodeTable 4.5 #449

Description

@manfredsc

I had some unrelated (local entries with index>=192) issues with level descriptions and looked into the relevant code.

Related links:
https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_table4-5.shtml
https://github.com/wmo-im/GRIB2/blob/master/GRIB2_CodeFlag_4_5_CodeTable_en.csv

WMO table 4.5 entries in Level.c (array level_table) are a bit outdated. One could of course generate the entries from github sources,
but the thing is, the existing entries are heavily modified (shortened, more concise, sometimes also more unclear)
and have printf format specifiers interlaced. For some entries, the specifiers are missing, though (as there exists a unit indication).
On the other hand, taking the official WMO strings would be obviously correct and less error-prone.

One could generate the format specifiers at a fixed place in the string (e.g., beginning) for entries with existing unit indication:

      if (unit !="" && unit !~ "-") {
        printf "/* %3d */ \"%%g %s %s\",\n",num,unit,name
      } else {
        printf "/* %3d */ \"%s\",\n",num,name
      }

But readability would be hampered a bit, as the automatic placement would not always make sense.

Perhaps it would be better to just update the entries by hand and try to remember to periodically update them.

Three remarks:

  • it is unclear which entries have to take an argument. I assume entries with unit indication to take a format specifier.
  • entries 31 and 32 are shifted by one index
  • in Level.c:542 and Level.c:547, there is
    if (type == 235) val *= 0.01; // C -> 0.1C
    which is strange twice. This probably should read
    if (type == 235) val *= 0.1; // 0.1C -> C

A sample, manually created patch could look as follows:
Level.c.patch

Please advise whether a scripted approach or a manual patch is more appropriate.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions