import numpy as np
import pandas as pd
import xarray as xr
from reki.format.grib.eccodes import load_field_from_file/home/wangdp/project/cedarkit/notebook-project/notebook-devel/repo/data-notebook-project/data-notebook/.venv/lib/python3.14/site-packages/gribapi/__init__.py:23: UserWarning: ecCodes 2.42.0 or higher is recommended. You are running version 2.34.1
warnings.warn(
from data_notebook.data import get_data_file
gfs_grib2_orig_file_path = get_data_file("cma-gfs")
gfs_grib2_orig_file_pathThe history saving thread hit an unexpected error (OperationalError('attempt to write a readonly database')).History will not be written to the database.
PosixPath('/home/wangdp/project/cedarkit/notebook-project/notebook-devel/repo/data-notebook-project/data-notebook/data/cma-gfs/grib2/orig/Z_NAFP_C_BABJ_20260811000000_P_NWPC-GRAPES-GFS-GLB-02400.grib2')ACPCP/NCPCP/APCP/ASNOW¶
对流降水¶
| 要素名 | cemc | wgrib2 | eccodes | GRIB Key | 层次类型 | 层次 | 编号 |
|---|---|---|---|---|---|---|---|
| 对流降水 | rainc | ACPCP | acpcp | (0, 1, 10) | - | - | 1 |
field = load_field_from_file(
gfs_grib2_orig_file_path,
parameter="ACPCP",
lazy=True
)
assert field.attrs["GRIB_count"] == 1field = load_field_from_file(
gfs_grib2_orig_file_path,
parameter="acpcp",
lazy=True
)
assert field.attrs["GRIB_count"] == 1field = load_field_from_file(
gfs_grib2_orig_file_path,
parameter="rainc",
lazy=True
)
assert field.attrs["GRIB_count"] == 1field = load_field_from_file(
gfs_grib2_orig_file_path,
parameter={
"discipline": 0,
"parameterCategory": 1,
"parameterNumber": 10,
},
lazy=True
)
assert field.attrs["GRIB_count"] == 1大尺度降水¶
| 要素名 | cemc | wgrib2 | eccodes | GRIB Key | 层次类型 | 层次 | 编号 |
|---|---|---|---|---|---|---|---|
| 大尺度降水 | rainnc | NCPCP | ncpcp | (0, 1, 9) | - | - | 2 |
field = load_field_from_file(
gfs_grib2_orig_file_path,
parameter="NCPCP",
lazy=True
)
assert field.attrs["GRIB_count"] == 2field = load_field_from_file(
gfs_grib2_orig_file_path,
parameter="ncpcp",
lazy=True
)
assert field.attrs["GRIB_count"] == 2field = load_field_from_file(
gfs_grib2_orig_file_path,
parameter="rainnc",
lazy=True
)
assert field.attrs["GRIB_count"] == 2field = load_field_from_file(
gfs_grib2_orig_file_path,
parameter={
"discipline": 0,
"parameterCategory": 1,
"parameterNumber": 9,
},
lazy=True
)
assert field.attrs["GRIB_count"] == 2总降水¶
| 要素名 | cemc | wgrib2 | eccodes | GRIB Key | 层次类型 | 层次 | 编号 |
|---|---|---|---|---|---|---|---|
| 总降水 | rain | APCP | - | (0, 1, 8) | - | - | 3 |
field = load_field_from_file(
gfs_grib2_orig_file_path,
parameter="APCP",
lazy=True
)
assert field.attrs["GRIB_count"] == 3field = load_field_from_file(
gfs_grib2_orig_file_path,
parameter="rain",
lazy=True
)
assert field.attrs["GRIB_count"] == 3field = load_field_from_file(
gfs_grib2_orig_file_path,
parameter={
"discipline": 0,
"parameterCategory": 1,
"parameterNumber": 8,
},
lazy=True
)
assert field.attrs["GRIB_count"] == 3降雪量¶
| 要素名 | cemc | wgrib2 | eccodes | GRIB Key | 层次类型 | 层次 | 编号 |
|---|---|---|---|---|---|---|---|
| 降雪量 | snow | ASNOW | - | (0, 1, 29) | - | - | 4 |
field = load_field_from_file(
gfs_grib2_orig_file_path,
parameter="ASNOW",
lazy=True
)
assert field.attrs["GRIB_count"] == 4field = load_field_from_file(
gfs_grib2_orig_file_path,
parameter={
"discipline": 0,
"parameterCategory": 1,
"parameterNumber": 29,
},
lazy=True
)
assert field.attrs["GRIB_count"] == 4TMP¶
地表温度¶
| 要素名 | cemc | wgrib2 | eccodes | GRIB Key | 层次类型 | 层次 | 编号 |
|---|---|---|---|---|---|---|---|
| 地表温度 | ts | TMP | t | (0, 0, 0) | surface | - | 5 |
field = load_field_from_file(
gfs_grib2_orig_file_path,
parameter="TMP",
level_type="sfc",
lazy=True
)
assert field.attrs["GRIB_count"] == 5field = load_field_from_file(
gfs_grib2_orig_file_path,
parameter="t",
level_type="surface",
lazy=True
)
assert field.attrs["GRIB_count"] == 5field = load_field_from_file(
gfs_grib2_orig_file_path,
parameter="ts",
lazy=True
)
assert field.attrs["GRIB_count"] == 5field = load_field_from_file(
gfs_grib2_orig_file_path,
parameter={
"discipline": 0,
"parameterCategory": 0,
"parameterNumber": 0,
},
level_type="sfc",
lazy=True
)
assert field.attrs["GRIB_count"] == 5