You want to dump a specific section of a GRIB message rather than all sections.
You can use the "-p" option of the grib_dump command
To find out the sections and their contents of each edition, see here:
For example let's look at the Grid Description Section of a GRIB 1 file. This would be Section 2 for edition 1 so we use the key "section_2":
% grib_dump -p section_2 data/regular_latlon_surface.grib1 ====================== SECTION_2 ( length=32, padding=0 ) ====================== 1-3 section2Length = 32 4 numberOfVerticalCoordinateValues = 0 5 pvlLocation = 255 6 dataRepresentationType = 0 [Latitude/Longitude Grid (grib1/6.table) ] 7-8 Ni = 16 9-10 Nj = 31 11-13 latitudeOfFirstGridPoint = 60000 14-16 longitudeOfFirstGridPoint = 0 17 resolutionAndComponentFlags = 128 [10000000] 18-20 latitudeOfLastGridPoint = 0 21-23 longitudeOfLastGridPoint = 30000 24-25 iDirectionIncrement = 2000 26-27 jDirectionIncrement = 2000 ... |
And now let's dump the Product Definition Section for a GRIB 2 message. This would be Section 4:
% grib_dump -O -p section_4 samples/GRIB2.tmpl ====================== SECTION_4 ( length=34, padding=0 ) ====================== 1-4 section4Length = 34 5 numberOfSection = 4 6-7 NV = 0 8-9 productDefinitionTemplateNumber = 0 [Analysis or forecast at a horizontal level or in a horizontal layer at a point in time (grib2/tables/4/4.0.table) ] 10 parameterCategory = 0 [Temperature (grib2/tables/4/4.1.0.table) ] 11 parameterNumber = 0 [Temperature (K) (grib2/tables/4/4.2.0.0.table) ] 12 typeOfGeneratingProcess = 0 [Analysis (grib2/tables/4/4.3.table) ] 13 backgroundProcess = 255 14 generatingProcessIdentifier = 128 15-16 hoursAfterDataCutoff = 0 17 minutesAfterDataCutoff = 0 18 indicatorOfUnitOfTimeRange = 1 [Hour (grib2/tables/4/4.4.table) ] 19-22 forecastTime = 0 23 typeOfFirstFixedSurface = 1 [Ground or water surface (grib2/tables/4/4.5.table) ] ... |
If a given section does not exist e.g. section 2 is optional in GRIB 2, then you get an error (Key/value not found).
Of course you can use the other grib_dump options e.g. "-j" to do a JSON dump or "-H" to see values in hex.
Note: This can be a very quick way of checking a set of keys without decoding others. For example if you have a very large data section, the standard grib_dump would decode all its values whereas dumping a given non-data section will skip the data values decoding and hence be quicker.
Related articles appear here based on the labels you select. Click to edit the macro and add or change labels.
|