# GRIB

**GRIB**（General Regularly-distributed Information in Binary form，二进制形式通用规则分布信息；WMO FM 92）是由世界气象组织（WMO）定义的一种二进制数据格式，用于交换和存储网格化天气与气候数据，例如数值天气预报的分析场和预报场。<sup>[1](https://help.ceda.ac.uk/article/4426-grib)</sup><sup> • </sup><sup>[2](https://codes.ecmwf.int/grib/format/grib2/regulations/)</sup> GRIB 文件是自描述的：读取数据所需的信息，包括参数、层次、时间、网格几何和打包方法，都携带在文件本身之中。<sup>[1](https://help.ceda.ac.uk/article/4426-grib)</sup>

| 关键事实 | 详情 |
|---|---|
| 全称 | 二进制形式通用规则分布信息，WMO 代码格式 FM 92<sup>[2](https://codes.ecmwf.int/grib/format/grib2/regulations/)</sup><sup> • </sup><sup>[3](https://codes.wmo.int/)</sup> |
| 版本 | 第 0 版由 WMO 于 1985 年引入，第 1 版于 1990 年，第 2 版于 2001 年<sup>[4](https://confluence.ecmwf.int/plugins/viewsource/viewpagesrc.action?pageId=514298435)</sup> |
| 现行标准 | 第 1 版已于 2016 年从《WMO 代码手册》（第 I.2 卷，WMO-No. 306）中移除；GRIB2 是 WMO 的官方格式<sup>[4](https://confluence.ecmwf.int/plugins/viewsource/viewpagesrc.action?pageId=514298435)</sup> |
| 消息定界 | 每条消息以四个八位组“GRIB”开头，以“7777”结尾，两者均以国际字母表第 5 号编码<sup>[2](https://codes.ecmwf.int/grib/format/grib2/regulations/)</sup> |
| GRIB2 段 | 编号段 0 至 8：指示段、标识段、本地使用段、网格定义段、产品定义段、数据表示段、位图片段、数据段，外加结束段<sup>[5](https://codes.ecmwf.int/grib/format/grib2/sections/)</sup> |
| 数据编码 | 数值存储为相对于参考值的非负缩放差值，按数据表示段中指定的方法打包<sup>[2](https://codes.ecmwf.int/grib/format/grib2/regulations/)</sup> |
| 常用软件 | ecCodes（ECMWF）和 wgrib2（NOAA）可读写 GRIB 第 1 版和第 2 版<sup>[6](https://www.ecmwf.int/en/computing/software)</sup><sup> • </sup><sup>[7](https://www.cpc.ncep.noaa.gov/products/tools/wgrib2/limitations.html)</sup> |

## 目的与历史

GRIB 由 WMO 基本系统委员会于 1985 年定义，作为一种在国家气象中心之间交换大量网格数据的代码。<sup>[4](https://confluence.ecmwf.int/plugins/viewsource/viewpagesrc.action?pageId=514298435)</sup><sup> • </sup><sup>[8](https://events.ecmwf.int/event/363/contributions/4110/attachments/2346/4098/intro_grib_decoding_2023-10-31.pdf)</sup> 第 1 版到 20 世纪 90 年代初已变得普遍，并在数十年间一直是大多数业务气象服务机构的工作格式。<sup>[9](https://www.ecmwf.int/en/newsletter/175/computing/migration-grib1-grib2-preparing-ecmwf-model-output-future)</sup> 第 2 版于 2001 年随后推出，而在第 1 版于 2016 年从《WMO 代码手册》中删除后，GRIB2 一直是官方格式；此外还存在一项 GRIB 第 3 版的倡议。<sup>[4](https://confluence.ecmwf.int/plugins/viewsource/viewpagesrc.action?pageId=514298435)</sup>

该格式与机器无关：数据表示为连续的八位组比特流（1 个八位组 = 8 比特），其解释不依赖于任何特定计算机的内部表示。然而，没有软件就无法读取；该代码不适合在没有计算机解释的情况下进行视觉识别。<sup>[10](https://codes.ecmwf.int/grib/format/grib1/overview/)</sup>

## 消息结构

一个 GRIB 文件包含一条或多条消息。每条消息保存一个参数在一个时间、一个层次上的网格数据，并划分为若干编号段。<sup>[1](https://help.ceda.ac.uk/article/4426-grib)</sup> 在 GRIB2 中，这些段是：<sup>[5](https://codes.ecmwf.int/grib/format/grib2/sections/)</sup>

- 第 0 段，指示段，携带字符“GRIB”、数据的学科、版本号以及消息总长度。<sup>[2](https://codes.ecmwf.int/grib/format/grib2/regulations/)</sup>
- 第 1 段，标识段，标识数据的来源中心、参考时间和生产状态。
- 第 2 段，本地使用段，为可选段，携带各中心特定的扩展内容。
- 第 3 段，网格定义段，描述网格几何，例如网格是规则经纬度网格、高斯网格还是某种投影。<sup>[1](https://help.ceda.ac.uk/article/4426-grib)</sup>
- 第 4 段，产品定义段，描述参数、其层次类型和层次，以及在 GRIB2 中用于集合预报、再预报和后处理产品的产品模板。
- 第 5 段，数据表示段，指明打包方法以及对数值应用的缩放。
- 第 6 段，位图片段，可选地标记哪些格点携带数据、哪些被省略。<sup>[10](https://codes.ecmwf.int/grib/format/grib1/overview/)</sup>
- 第 7 段，数据段，包含打包后的数值本身。
- 第 8 段是结束段，始终为四个八位组“7777”。<sup>[2](https://codes.ecmwf.int/grib/format/grib2/regulations/)</sup>

在 GRIB1 中，布局类似但更简单，共有五个段：指示段、产品定义段、可选的网格描述段、可选的位图片段、二进制数据段，以及“7777”结束标记。<sup>[10](https://codes.ecmwf.int/grib/format/grib1/overview/)</sup> 产品定义段和网格定义段是用户最常查阅的段，因为它们携带参数、层次和日期，以及网格类型和分辨率。<sup>[1](https://help.ceda.ac.uk/article/4426-grib)</sup>

## 数据打包

GRIB 通过打包而非存储原始浮点数来紧凑地存储数值。数据被编码为相对于参考值的非负缩放差值，参考值通常是场的最小值，十进制比例因子确定所需精度，二进制比例因子选择传输精度。<sup>[2](https://codes.ecmwf.int/grib/format/grib2/regulations/)</sup> 原始值按 \( Y \cdot 10^{D} = R + (X_{1} + X_{2}) \cdot 2^{E} \) 恢复，其中 \( D \) 是十进制比例因子，\( E \) 是二进制比例因子，\( R \) 是参考值，\( X_{1} \)、\( X_{2} \) 是编码分量。<sup>[2](https://codes.ecmwf.int/grib/format/grib2/regulations/)</sup>

数据表示段中定义了几种打包方案。简单打包以固定比特数存储每个值。复杂打包将数值分成组，并从每组数值中减去一个局部参考值，利用局部冗余来缩小消息，同时相对于简单打包不丢失信息；在分组之前可以应用可选的空间差分预处理。<sup>[2](https://codes.ecmwf.int/grib/format/grib2/regulations/)</sup> GRIB2 还允许无损图像式压缩（PNG 和 JPEG 2000）、IEEE 浮点编码以及 CCSDS/AEC 压缩；wgrib2 支持所有这些读取方式。<sup>[7](https://www.cpc.ncep.noaa.gov/products/tools/wgrib2/limitations.html)</sup><sup> • </sup><sup>[11](https://gdal.org/en/stable/drivers/raster/grib.html)</sup> 压缩在大规模下很重要：ECMWF 的生产系统每天处理约 120 TiB 数据，那里的打包方法必须在 WMO 标准中得到认可、计算高效、可扩展到更高分辨率，并且能逐场压缩，以便用户无需解码整个数据集即可读取单个场。<sup>[12](https://www.ecmwf.int/sites/default/files/elibrary/2022/81320-impact-grib-compression-weather-forecast-data-and-data-handling-applications.pdf)</sup>

## GRIB1 与 GRIB2

GRIB1 的固定设计限制了它能描述的内容。它最多允许 127 个垂直层次——ECMWF 在 2011 年其模式转向 137 个垂直层次时达到了这一限制——并且只允许 128 个不同参数，没有用于集合预报或概率的元数据。集合成员编号等扩展通过本地段添加，但这些未得到 WMO 认可。<sup>[9](https://www.ecmwf.int/en/newsletter/175/computing/migration-grib1-grib2-preparing-ecmwf-model-output-future)</sup>

GRIB2 通过基于模板的设计解决了这些限制。它支持超过 127 个垂直层次、亚公里级水平网格、数百万个参数、集合预报和后处理产品元数据、广泛的压缩方法以及更丰富的参数描述。当需要额外元数据时，可以持续添加新模板，WMO 代码表和模板以每两年一次的快速通道方式扩展。<sup>[9](https://www.ecmwf.int/en/newsletter/175/computing/migration-grib1-grib2-preparing-ecmwf-model-output-future)</sup><sup> • </sup><sup>[4](https://confluence.ecmwf.int/plugins/viewsource/viewpagesrc.action?pageId=514298435)</sup>

**实践中的迁移。** 2022 年，ECMWF 开始了一项多年努力，将其日常业务输出从 GRIB1 迁移到 GRIB2，部分原因是计划开展 1 至 4 公里分辨率的对流可分辨全球预报，而 GRIB1 的网格定义无法容纳。仅提供 GRIB2 的产品包括 EAC5 大气成分再分析、ERA6、ORAS6 和 SEAS6，并且 GRIB2 从 IFS Cycle 51r1 起进入所有预报业务。<sup>[9](https://www.ecmwf.int/en/newsletter/175/computing/migration-grib1-grib2-preparing-ecmwf-model-output-future)</sup><sup> • </sup><sup>[13](https://www.ecmwf.int/en/about/media-centre/focus/2024/migration-grib2-data-format-implications-users)</sup> 自 2011 年 5 月 18 日实施 IFS 周期 37r2 以来，ECMWF 一直在 GRIB2 中生成垂直模式层数据。<sup>[4](https://confluence.ecmwf.int/plugins/viewsource/viewpagesrc.action?pageId=514298435)</sup>

## 读取 GRIB 数据

由于 GRIB 是二进制且由表驱动的，参数和含义被编码为 WMO 代码表中定义的整数代码，因此读取它需要专用软件。<sup>[1](https://help.ceda.ac.uk/article/4426-grib)</sup><sup> • </sup><sup>[4](https://confluence.ecmwf.int/plugins/viewsource/viewpagesrc.action?pageId=514298435)</sup> 广泛使用的工具包括 ECMWF 的 ecCodes（可编码和解码 GRIB 第 1 版和第 2 版，可从 C、Fortran 和 Python 访问）以及 NOAA 的 wgrib2 命令行工具。<sup>[6](https://www.ecmwf.int/en/computing/software)</sup><sup> • </sup><sup>[7](https://www.cpc.ncep.noaa.gov/products/tools/wgrib2/limitations.html)</sup> GDAL 将 GRIB 文件暴露为带有逐波段元数据的栅格波段，并可通过选择数据编码方案写入 GRIB2。<sup>[11](https://gdal.org/en/stable/drivers/raster/grib.html)</sup> 许多科学工作流程将 GRIB 转换为 NetCDF 或 Zarr 以便本地分析；将一个 GFS 预报文件转换为 netCDF-3 会使其大小增至原来的 6.4 倍，这说明了该格式的打包在存储和传输中节省了多少空间。<sup>[14](https://www.ftp.cpc.ncep.noaa.gov/wd51we/wgrib2/intro_grib2.pdf)</sup>

## References

1. [GRIB, Centre for Environmental Data Analysis (CEDA) Help Docs](https://help.ceda.ac.uk/article/4426-grib)
2. [GRIB Edition 2 Regulations, ECMWF](https://codes.ecmwf.int/grib/format/grib2/regulations/)
3. [WMO Codes Registry](https://codes.wmo.int/)
4. [Structure of GRIB1 and GRIB2 messages, ECMWF Confluence](https://confluence.ecmwf.int/plugins/viewsource/viewpagesrc.action?pageId=514298435)
5. [GRIB2 Sections, ECMWF](https://codes.ecmwf.int/grib/format/grib2/sections/)
6. [Software, ECMWF](https://www.ecmwf.int/en/computing/software)
7. [wgrib2: limitations and supported packing schemes, NOAA Climate Prediction Center](https://www.cpc.ncep.noaa.gov/products/tools/wgrib2/limitations.html)
8. [What is GRIB? ECMWF training presentation](https://events.ecmwf.int/event/363/contributions/4110/attachments/2346/4098/intro_grib_decoding_2023-10-31.pdf)
9. [Osinski, R., Griffith, M., Villaume, S. (2023). Migration from GRIB1 to GRIB2: preparing ECMWF model output for the future. ECMWF Newsletter 175.](https://www.ecmwf.int/en/newsletter/175/computing/migration-grib1-grib2-preparing-ecmwf-model-output-future)
10. [GRIB Edition 1 Overview, ECMWF](https://codes.ecmwf.int/grib/format/grib1/overview/)
11. [GRIB driver, GDAL documentation](https://gdal.org/en/stable/drivers/raster/grib.html)
12. [Impact of GRIB compression on weather forecast data and data-handling applications, ECMWF Technical Memorandum 900 (2022)](https://www.ecmwf.int/sites/default/files/elibrary/2022/81320-impact-grib-compression-weather-forecast-data-and-data-handling-applications.pdf)
13. [Migration to GRIB2 data format: implications for users, ECMWF (2024)](https://www.ecmwf.int/en/about/media-centre/focus/2024/migration-grib2-data-format-implications-users)
14. [Introduction to GRIB2 using the GFS forecasts, NOAA CPC (W. Ebisuzaki)](https://www.ftp.cpc.ncep.noaa.gov/wd51we/wgrib2/intro_grib2.pdf)

---
*Initially written Oct 15, 2026 · Edited: Oct 25, 2026*

Topic: 物质世界与数学 › 地球科学 › 气候与天气 › Meteorology and atmospheric science › Weather observation and forecasting › Observation codes and weather reports

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/grib

English original: https://www.edgepedia.org/grib
