title: grib_dump

weight: 2

grib_dump

显示 GRIB 文件内容

使用 grib_dump 显示包含一个或多个 GRIB 消息的文件内容。

支持不同的输出格式:

  • Octet mode: 提供 WMO 风格的输出
  • Debug mode: 打印 GRIB 文件中所有的 key
  • Octet 和 Debug 两种模式不能同时使用
  • Octet 内容可以使用十六进制格式输出。

通过设置选项,还可以输出 key aliases 和 key 的类型信息(key type information)。

支持 JSON 格式输出,便于处理。

使用方法

  1. grib_dump [options] grib_file grib_file ...

基本参数:

参数 含义
-O Octet 模式(WMO 文档风格)
-D Debug 模式
-a 打印 key alias 信息
-t 打印 key 类型信息
-H 十六进制显示的 Octet 模式
-w key[:{s i d}]{= !=}value,… where 子句
-j JSON 输出
-V 打印 ecCodes 版本

示例

以中国气象局数值预报中心的 GRAPES GFS 输出的 GRIB 2 产品为例

  1. $ grib_dump gmf.gra.2018010300000.grb2
  2. ***** FILE: gmf.gra.2018010300000.grb2
  3. #============== MESSAGE 1 ( length=356 ) ==============
  4. GRIB {
  5. # Meteorological products (grib2/tables/4/0.0.table)
  6. discipline = 0;
  7. editionNumber = 2;
  8. # Beijing (RSMC) (common/c-11.table)
  9. centre = 38;
  10. subCentre = 0;
  11. # Analysis (grib2/tables/4/1.2.table)
  12. significanceOfReferenceTime = 0;
  13. dataDate = 20180103;
  14. dataTime = 0;
  15. # Operational products (grib2/tables/4/1.3.table)
  16. productionStatusOfProcessedData = 0;
  17. # Analysis products (grib2/tables/4/1.4.table)
  18. typeOfProcessedData = 0;
  19. numberOfDataPoints = 1036800;
  20. # There is no appended list (grib2/tables/4/3.11.table)
  21. interpretationOfNumberOfPoints = 0;
  22. # Latitude/longitude (Also called equidistant cylindrical, or Plate Carree) (grib2/tables/4/3.1.table)
  23. gridDefinitionTemplateNumber = 0;
  24. # Earth assumed spherical with radius of 6,371,229.0 m (grib2/tables/4/3.2.table)
  25. shapeOfTheEarth = 6;
  26. Ni = 1440;
  27. Nj = 720;
  28. iScansNegatively = 0;
  29. jScansPositively = 0;
  30. jPointsAreConsecutive = 0;
  31. alternativeRowScanning = 0;
  32. latitudeOfFirstGridPointInDegrees = 89.875;
  33. longitudeOfFirstGridPointInDegrees = 0;
  34. latitudeOfLastGridPointInDegrees = -89.875;
  35. longitudeOfLastGridPointInDegrees = 359.75;
  36. iDirectionIncrementInDegrees = 0.25;
  37. jDirectionIncrementInDegrees = 0.25;
  38. gridType = regular_ll;
  39. NV = 0;
  40. # Average, accumulation, extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval (grib2/tables/4/4.0.table)
  41. productDefinitionTemplateNumber = 8;
  42. # Moisture (grib2/tables/4/4.1.0.table)
  43. parameterCategory = 1;
  44. # Convective precipitation (kg m-2) (grib2/tables/4/4.2.0.1.table)
  45. parameterNumber = 10;
  46. #-READ ONLY- parameterUnits = kg m-2;
  47. #-READ ONLY- parameterName = Convective precipitation ;
  48. # Analysis (grib2/tables/4/4.3.table)
  49. typeOfGeneratingProcess = 0;
  50. generatingProcessIdentifier = 15;
  51. # Hour (grib2/tables/4/4.4.table)
  52. indicatorOfUnitOfTimeRange = 1;
  53. # Hour (stepUnits.table)
  54. stepUnits = 1;
  55. forecastTime = 0;
  56. # Ground or water surface (grib2/tables/4/4.5.table)
  57. typeOfFirstFixedSurface = 1;
  58. #-READ ONLY- unitsOfFirstFixedSurface = unknown;
  59. #-READ ONLY- nameOfFirstFixedSurface = Ground or water surface ;
  60. scaleFactorOfFirstFixedSurface = MISSING;
  61. scaledValueOfFirstFixedSurface = MISSING;
  62. # Missing (grib2/tables/4/4.5.table)
  63. typeOfSecondFixedSurface = 255;
  64. #-READ ONLY- unitsOfSecondFixedSurface = unknown;
  65. #-READ ONLY- nameOfSecondFixedSurface = Missing;
  66. scaleFactorOfSecondFixedSurface = MISSING;
  67. scaledValueOfSecondFixedSurface = MISSING;
  68. level = 0;
  69. endStep = 0;
  70. stepRange = 0;
  71. shortNameECMF = acpcp;
  72. shortName = acpcp;
  73. nameECMF = Convective precipitation (water);
  74. name = Convective precipitation (water);
  75. cfNameECMF = lwe_thickness_of_convective_precipitation_amount;
  76. cfName = lwe_thickness_of_convective_precipitation_amount;
  77. cfVarNameECMF = acpcp;
  78. cfVarName = acpcp;
  79. #-READ ONLY- modelName = unknown;
  80. numberOfValues = 1036800;
  81. packingType = grid_jpeg;
  82. # A bit map does not apply to this product (grib2/tables/4/6.0.table)
  83. bitMapIndicator = 255;
  84. bitmapPresent = 0;
  85. values(1036800) = {
  86. 0, 0, 0, 0, 0,
  87. 0, 0, 0, 0, 0,
  88. 0, 0, 0, 0, 0,
  89. 0, 0, 0, 0, 0,
  90. 0, 0, 0, 0, 0,
  91. 0, 0, 0, 0, 0,
  92. 0, 0, 0, 0, 0,
  93. 0, 0, 0, 0, 0,
  94. 0, 0, 0, 0, 0,
  95. 0, 0, 0, 0, 0,
  96. 0, 0, 0, 0, 0,
  97. 0, 0, 0, 0, 0,
  98. 0, 0, 0, 0, 0,
  99. 0, 0, 0, 0, 0,
  100. 0, 0, 0, 0, 0,
  101. 0, 0, 0, 0, 0,
  102. 0, 0, 0, 0, 0,
  103. 0, 0, 0, 0, 0,
  104. 0, 0, 0, 0, 0,
  105. 0, 0, 0, 0, 0
  106. ... 1036700 more values
  107. }
  108. #-READ ONLY- maximum = 0;
  109. #-READ ONLY- minimum = 0;
  110. #-READ ONLY- average = 0;
  111. #-READ ONLY- numberOfMissing = 0;
  112. #-READ ONLY- standardDeviation = 0;
  113. #-READ ONLY- skewness = 0;
  114. #-READ ONLY- kurtosis = 0;
  115. #-READ ONLY- isConstant = 1;
  116. #-READ ONLY- getNumberOfValues = 1036800;
  117. }

使用其他选项

  1. $ grib_dump -OtaH gmf.gra.2018010300000.grb2
  2. ***** FILE: gmf.gra.2018010300000.grb2
  3. #============== MESSAGE 1 ( length=356 ) ==============
  4. 1-4 ascii identifier = GRIB ( 0x47 0x52 0x49 0x42 )
  5. 5-6 unsigned reserved = MISSING ( 0xFF 0xFF )
  6. 7 codetable discipline = 0 ( 0x00 ) [Meteorological products (grib2/tables/4/0.0.table) ]
  7. 8 unsigned editionNumber = 2 ( 0x02 ) [ls.edition]
  8. 9-16 section_length totalLength = 356 ( 0x00 0x00 0x00 0x00 0x00 0x00 0x01 0x64 )
  9. ====================== SECTION_1 ( length=21, padding=0 ) ======================
  10. 1-4 section_length section1Length = 21 ( 0x00 0x00 0x00 0x15 )
  11. 5 unsigned numberOfSection = 1 ( 0x01 )
  12. 6-7 codetable centre = 38 ( 0x00 0x26 ) [Beijing (RSMC) (common/c-11.table) ] [identificationOfOriginatingGeneratingCentre, ls.centre, originatingCentre, centreForLocal]
  13. 8-9 unsigned subCentre = 0 ( 0x00 0x00 )
  14. 10 codetable tablesVersion = 4 ( 0x04 ) [Version implemented on 7 November 2007 (grib2/tables/1.0.table) ] [gribMasterTablesVersionNumber]
  15. 11 codetable localTablesVersion = 1 ( 0x01 ) [Unknown code table entry (grib2/tables/4/1.1.table) ] [versionNumberOfGribLocalTables]
  16. 12 codetable significanceOfReferenceTime = 0 ( 0x00 ) [Analysis (grib2/tables/4/1.2.table) ]
  17. 13-14 unsigned year = 2018 ( 0x07 0xE2 )
  18. 15 unsigned month = 1 ( 0x01 )
  19. 16 unsigned day = 3 ( 0x03 )
  20. 17 unsigned hour = 0 ( 0x00 )
  21. 18 unsigned minute = 0 ( 0x00 )
  22. 19 unsigned second = 0 ( 0x00 )
  23. 20 codetable productionStatusOfProcessedData = 0 ( 0x00 ) [Operational products (grib2/tables/4/1.3.table) ]
  24. 21 codetable typeOfProcessedData = 0 ( 0x00 ) [Analysis products (grib2/tables/4/1.4.table) ] [ls.dataType]
  25. ====================== SECTION_3 ( length=72, padding=0 ) ======================
  26. 1-4 section_length section3Length = 72 ( 0x00 0x00 0x00 0x48 )
  27. 5 unsigned numberOfSection = 3 ( 0x03 )
  28. 6 codetable sourceOfGridDefinition = 0 ( 0x00 ) [Specified in Code table 3.1 (grib2/tables/4/3.0.table) ]
  29. 7-10 unsigned numberOfDataPoints = 1036800 ( 0x00 0x0F 0xD2 0x00 ) [numberOfPoints]
  30. 11 unsigned numberOfOctectsForNumberOfPoints = 0 ( 0x00 )
  31. 12 codetable interpretationOfNumberOfPoints = 0 ( 0x00 ) [There is no appended list (grib2/tables/4/3.11.table) ]
  32. 13-14 codetable gridDefinitionTemplateNumber = 0 ( 0x00 0x00 ) [Latitude/longitude (Also called equidistant cylindrical, or Plate Carree) (grib2/tables/4/3.1.table) ]
  33. 15 codetable shapeOfTheEarth = 6 ( 0x06 ) [Earth assumed spherical with radius of 6,371,229.0 m (grib2/tables/4/3.2.table) ]
  34. 16 unsigned scaleFactorOfRadiusOfSphericalEarth = 0 ( 0x00 )
  35. 17-20 unsigned scaledValueOfRadiusOfSphericalEarth = 0 ( 0x00 0x00 0x00 0x00 )
  36. 21 unsigned scaleFactorOfEarthMajorAxis = 0 ( 0x00 ) [scaleFactorOfMajorAxisOfOblateSpheroidEarth]
  37. 22-25 unsigned scaledValueOfEarthMajorAxis = 0 ( 0x00 0x00 0x00 0x00 ) [scaledValueOfMajorAxisOfOblateSpheroidEarth]
  38. 26 unsigned scaleFactorOfEarthMinorAxis = 0 ( 0x00 ) [scaleFactorOfMinorAxisOfOblateSpheroidEarth]
  39. 27-30 unsigned scaledValueOfEarthMinorAxis = 0 ( 0x00 0x00 0x00 0x00 ) [scaledValueOfMinorAxisOfOblateSpheroidEarth]
  40. 31-34 unsigned Ni = 1440 ( 0x00 0x00 0x05 0xA0 ) [numberOfPointsAlongAParallel, Nx, numberOfColumns]
  41. 35-38 unsigned Nj = 720 ( 0x00 0x00 0x02 0xD0 ) [numberOfPointsAlongAMeridian, Ny, numberOfRows]
  42. 39-42 unsigned basicAngleOfTheInitialProductionDomain = 0 ( 0x00 0x00 0x00 0x00 )
  43. 43-46 unsigned subdivisionsOfBasicAngle = 0 ( 0x00 0x00 0x00 0x00 )
  44. 47-50 signed latitudeOfFirstGridPoint = 89875000 ( 0x05 0x5B 0x62 0x38 ) [La1]
  45. 51-54 signed longitudeOfFirstGridPoint = 0 ( 0x00 0x00 0x00 0x00 ) [Lo1]
  46. 55 codeflag resolutionAndComponentFlags = 48 [00110000] ( 0x30 )
  47. 56-59 signed latitudeOfLastGridPoint = -89875000 ( 0x85 0x5B 0x62 0x38 ) [La2]
  48. 60-63 signed longitudeOfLastGridPoint = 359750000 ( 0x15 0x71 0x59 0x70 ) [Lo2]
  49. 64-67 unsigned iDirectionIncrement = 250000 ( 0x00 0x03 0xD0 0x90 ) [Di, Dx]
  50. 68-71 unsigned jDirectionIncrement = 250000 ( 0x00 0x03 0xD0 0x90 ) [Dj, Dy]
  51. 72 codeflag scanningMode = 0 [00000000] ( 0x00 )
  52. ====================== SECTION_4 ( length=58, padding=0 ) ======================
  53. 1-4 section_length section4Length = 58 ( 0x00 0x00 0x00 0x3A )
  54. 5 unsigned numberOfSection = 4 ( 0x04 )
  55. 6-7 unsigned NV = 0 ( 0x00 0x00 ) [numberOfVerticalCoordinateValues, numberOfCoordinatesValues, numberOfVerticalGridDescriptors]
  56. 8-9 codetable productDefinitionTemplateNumber = 8 ( 0x00 0x08 ) [Average, accumulation, extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval (grib2/tables/4/4.0.table) ]
  57. 10 codetable parameterCategory = 1 ( 0x01 ) [Moisture (grib2/tables/4/4.1.0.table) ]
  58. 11 codetable parameterNumber = 10 ( 0x0A ) [Convective precipitation (kg m-2) (grib2/tables/4/4.2.0.1.table) ]
  59. 12 codetable typeOfGeneratingProcess = 0 ( 0x00 ) [Analysis (grib2/tables/4/4.3.table) ]
  60. 13 unsigned backgroundProcess = 0 ( 0x00 ) [backgroundGeneratingProcessIdentifier]
  61. 14 unsigned generatingProcessIdentifier = 15 ( 0x0F )
  62. 15-16 unsigned hoursAfterDataCutoff = 0 ( 0x00 0x00 ) [hoursAfterReferenceTimeOfDataCutoff]
  63. 17 unsigned minutesAfterDataCutoff = 0 ( 0x00 ) [minutesAfterReferenceTimeOfDataCutoff]
  64. 18 codetable indicatorOfUnitOfTimeRange = 1 ( 0x01 ) [Hour (grib2/tables/4/4.4.table) ]
  65. 19-22 signed forecastTime = 0 ( 0x00 0x00 0x00 0x00 )
  66. 23 codetable typeOfFirstFixedSurface = 1 ( 0x01 ) [Ground or water surface (grib2/tables/4/4.5.table) ] [levelType, mars.levtype]
  67. 24 signed scaleFactorOfFirstFixedSurface = MISSING ( 0xFF )
  68. 25-28 unsigned scaledValueOfFirstFixedSurface = MISSING ( 0xFF 0xFF 0xFF 0xFF )
  69. 29 codetable typeOfSecondFixedSurface = 255 ( 0xFF ) [Missing (grib2/tables/4/4.5.table) ]
  70. 30 signed scaleFactorOfSecondFixedSurface = MISSING ( 0xFF )
  71. 31-34 unsigned scaledValueOfSecondFixedSurface = MISSING ( 0xFF 0xFF 0xFF 0xFF )
  72. 35-36 unsigned yearOfEndOfOverallTimeInterval = 2018 ( 0x07 0xE2 )
  73. 37 unsigned monthOfEndOfOverallTimeInterval = 1 ( 0x01 )
  74. 38 unsigned dayOfEndOfOverallTimeInterval = 3 ( 0x03 )
  75. 39 unsigned hourOfEndOfOverallTimeInterval = 0 ( 0x00 )
  76. 40 unsigned minuteOfEndOfOverallTimeInterval = 0 ( 0x00 )
  77. 41 unsigned secondOfEndOfOverallTimeInterval = 0 ( 0x00 )
  78. 42 unsigned numberOfTimeRange = 1 ( 0x01 ) [n]
  79. 43-46 unsigned numberOfMissingInStatisticalProcess = 0 ( 0x00 0x00 0x00 0x00 ) [totalNumberOfDataValuesMissingInStatisticalProcess]
  80. 47 codetable typeOfStatisticalProcessing = 1 ( 0x01 ) [Accumulation (grib2/tables/4/4.10.table) ]
  81. 48 codetable typeOfTimeIncrement = 2 ( 0x02 ) [Successive times processed have same start time of forecast, forecast time is incremented (grib2/tables/4/4.11.table) ] [typeOfTimeIncrementBetweenSuccessiveFieldsUsedInTheStatisticalProcessing]
  82. 49 codetable indicatorOfUnitForTimeRange = 1 ( 0x01 ) [Hour (grib2/tables/4/4.4.table) ]
  83. 50-53 unsigned lengthOfTimeRange = 0 ( 0x00 0x00 0x00 0x00 )
  84. 54 codetable indicatorOfUnitForTimeIncrement = 255 ( 0xFF ) [Missing (grib2/tables/4/4.4.table) ]
  85. 55-58 unsigned timeIncrement = 0 ( 0x00 0x00 0x00 0x00 ) [timeIncrementBetweenSuccessiveFields]
  86. ====================== SECTION_5 ( length=23, padding=0 ) ======================
  87. 1-4 section_length section5Length = 23 ( 0x00 0x00 0x00 0x17 )
  88. 5 unsigned numberOfSection = 5 ( 0x05 )
  89. 6-9 unsigned numberOfValues = 1036800 ( 0x00 0x0F 0xD2 0x00 ) [numberOfCodedValues, numberOfEffectiveValues]
  90. 10-11 codetable dataRepresentationTemplateNumber = 40 ( 0x00 0x28 ) [JPEG2000 Packing (grib2/tables/4/5.0.table) ]
  91. 12-15 ieeefloat referenceValue = 0 ( 0x00 0x00 0x00 0x00 )
  92. 16-17 signed binaryScaleFactor = 0 ( 0x00 0x00 )
  93. 18-19 signed decimalScaleFactor = 6 ( 0x00 0x06 )
  94. 20 unsigned bitsPerValue = 24 ( 0x18 ) [numberOfBits, numberOfBitsContainingEachPackedValue]
  95. 21 codetable typeOfOriginalFieldValues = 0 ( 0x00 ) [Floating point (grib2/tables/4/5.1.table) ]
  96. 22 codetable typeOfCompressionUsed = 0 ( 0x00 ) [Lossless (grib2/tables/4/5.40.table) ]
  97. 23 unsigned targetCompressionRatio = 255 ( 0xFF )
  98. ====================== SECTION_6 ( length=6, padding=0 ) ======================
  99. 1-4 section_length section6Length = 6 ( 0x00 0x00 0x00 0x06 )
  100. 5 unsigned numberOfSection = 6 ( 0x06 )
  101. 6 codetable bitMapIndicator = 255 ( 0xFF ) [A bit map does not apply to this product (grib2/tables/4/6.0.table) ]
  102. ====================== SECTION_7 ( length=156, padding=0 ) ======================
  103. 1-4 section_length section7Length = 156 ( 0x00 0x00 0x00 0x9C )
  104. 5 unsigned numberOfSection = 7 ( 0x07 )
  105. 6-156 data_jpeg2000_packing codedValues = (1036800,151) [data.packedValues] {
  106. 0.0000000000e+00, 0.0000000000e+00, 0.0000000000e+00, 0.0000000000e+00, 0.0000000000e+00, 0.0000000000e+00, 0.0000000000e+00, 0.0000000000e+00,
  107. 0.0000000000e+00, 0.0000000000e+00, 0.0000000000e+00, 0.0000000000e+00, 0.0000000000e+00, 0.0000000000e+00, 0.0000000000e+00, 0.0000000000e+00,
  108. ... 1036700 more values
  109. } # data_jpeg2000_packing codedValues
  110. ====================== SECTION_8 ( length=4, padding=0 ) ======================
  111. 1-4 ascii 7777 = 7777 ( 0x37 0x37 0x37 0x37 )

Debug 模式会显示 computed key。其中 ls.<key>, mars.<key>, time.<key> 表示 namespace 中的 key。

  1. $ grib_dump -D gmf.gra.2018010300000.grb2
  2. ***** FILE: gmf.gra.2018010300000.grb2
  3. #============== MESSAGE 1 ( length=356 ) ==============
  4. ...
  5. ======> section GRIB (356,356,0)
  6. 0-0 constant tablesVersionLatest = 20
  7. 0-0 constant one = 1 [defaultStepUnits]
  8. 0-0 constant million = 1000000
  9. 0-0 constant grib2divider = 1000000
  10. ...
  11. 0-4 ascii identifier = GRIB
  12. 4-6 unsigned reserved = MISSING
  13. 6-7 codetable discipline = 0 [Meteorological products (grib2/tables/4/0.0.table) ]
  14. 7-8 unsigned editionNumber = 2 [ls.edition]
  15. 8-16 section_length totalLength = 356
  16. 16-16 position startOfHeaders = 16
  17. 16-16 section_pointer section0Pointer = 0 {}
  18. ======> section core (336,336,0)
  19. 16-16 lookup sectionNumber = 1 [? 255 20-1]
  20. 16-16 position sectionPosition = 16
  21. ======> section section_1 (21,21,0)
  22. 16-16 position offsetSection1 = 16
  23. 16-20 section_length section1Length = 21
  24. 20-20 section_pointer section1Pointer = 0 {}
  25. 20-21 unsigned numberOfSection = 1
  26. 21-23 codetable centre = 38 [Beijing (RSMC) (common/c-11.table) ] [identificationOfOriginatingGeneratingCentre, ls.centre, originatingCentre, centreForLocal]
  27. 23-23 codetable_title centreDescription = Beijing
  28. 23-25 unsigned subCentre = 0
  29. 25-26 codetable tablesVersion = 4 [Version implemented on 7 November 2007 (grib2/tables/1.0.table) ] [gribMasterTablesVersionNumber]
  30. 26-26 transient masterDir = grib2/tables/[tablesVersion]
  31. 26-27 codetable localTablesVersion = 1 [Unknown code table entry (grib2/tables/4/1.1.table) ] [versionNumberOfGribLocalTables]
  32. ...
  33. 35-36 codetable productionStatusOfProcessedData = 0 [Operational products (grib2/tables/4/1.3.table) ]
  34. 36-37 codetable typeOfProcessedData = 0 [Analysis products (grib2/tables/4/1.4.table) ] [ls.dataType]
  35. 37-37 md5 md5Section1 = d7dda6eb5f368b9d23d941cc58c0124e
  36. 37-37 select_step_template selectStepTemplateInterval = 1
  37. 37-37 select_step_template selectStepTemplateInstant = 1
  38. 37-37 transient stepTypeInternal = instant
  39. 37-37 concept stepType = accum
  40. 37-37 transient setCalendarId = 0
  41. 37-37 transient deleteCalendarId = 0
  42. 37-37 concept is_uerra = 0
  43. <===== section section_1
  44. 37-37 lookup sectionNumber = 3 [? 255 41-1]
  45. 37-37 transient grib2LocalSectionPresent = 0 [setLocalDefinition]
  46. 37-37 transient deleteLocalDefinition = 0
  47. 37-37 lookup sectionNumber = 3 [? 255 41-1]
  48. 37-37 position sectionPosition = 37
  49. ======> section section_3 (72,72,0)
  50. 37-37 constant gridDescriptionSectionPresent = 1
  51. 37-37 position offsetSection3 = 37

ecCodes 命名空间

ecCodes 命名空间(ecCodes namespace)在 grib_ls 工具中非常有用。

namespace keys
ls centre, shortName, level etc. 被 grib_ls 工具使用
parameter paramId, shortName, units etc. 与气象要素相关
statistics maximum, minimum, average, standard deviation etc. 与数据值的统计有关
time forecast date, validity date, steps etc. 描述预报运行情况
geography bounding box of the grid, number of points along a parallel etc. 描述网格形状
vertical type of the level, list of coefficients of the vertical coordinate etc. 描述层次(levels and layers)
mars class, stream, type etc. 用于描述 MARS 的内容,MARS 是 ECMWF’s Meteorological Archival and Retrieval System

练习

练习使用 grib_dump