You want to dump a specific section of a GRIB message rather than all its sections.
Step-by-step guide
You can use the "-p" option of the grib_dump command
- Select the section you want the dump for. For example for section 1 you use the key "section_1"
- Invoke "grib_dump -p $key" on the given key
To find out the sections and their contents of each edition, see here:
- GRIB edition 1 sections
- GRIB edition 2 sections
For example let's look at the grid section Grid Description Section of a GRIB edition 1 file. This would be section Section 2 for edition 1 so we use the key "section_2":
Code Block |
---|
% grib_dump -O -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 28 scanningMode = 0 [00000000] 29-32 zeros = ... |
And now let's dump the Product Definition Section for a GRIB edition 2 message. This would be Section 4:
Code Block |
---|
% 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) ] 24 scaleFactorOfFirstFixedSurface = MISSING 25-28 scaledValueOfFirstFixedSurface = MISSING 29 typeOfSecondFixedSurface = 255 [Missing (grib2/tables/4/4.5.table) ] 30 scaleFactorOfSecondFixedSurface = MISSING 31-34 scaledValueOfSecondFixedSurface = MISSING... |
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).
The "-p" option can take one or more standard keys e.g. grib_dump -p Ni,Nj
prints just those two keys and grib_dump -p pl
prints the "pl" array.
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.
Info |
---|
This can be a very efficient 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 decoding the data values and hence be quicker. |
Related articles
Content by Label | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
...
Page properties | ||
---|---|---|
| ||
|