Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

GFS要素清单:1-5

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_path
The 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

对流降水

要素名cemcwgrib2eccodesGRIB Key层次类型层次编号
对流降水raincACPCPacpcp(0, 1, 10)--1
field = load_field_from_file(
    gfs_grib2_orig_file_path,
    parameter="ACPCP",
    lazy=True
)
assert field.attrs["GRIB_count"] == 1
field = load_field_from_file(
    gfs_grib2_orig_file_path,
    parameter="acpcp",
    lazy=True
)
assert field.attrs["GRIB_count"] == 1
field = load_field_from_file(
    gfs_grib2_orig_file_path,
    parameter="rainc",
    lazy=True
)
assert field.attrs["GRIB_count"] == 1
field = load_field_from_file(
    gfs_grib2_orig_file_path,
    parameter={
        "discipline": 0,
        "parameterCategory": 1,
        "parameterNumber": 10,
    },
    lazy=True
)
assert field.attrs["GRIB_count"] == 1

大尺度降水

要素名cemcwgrib2eccodesGRIB Key层次类型层次编号
大尺度降水rainncNCPCPncpcp(0, 1, 9)--2
field = load_field_from_file(
    gfs_grib2_orig_file_path,
    parameter="NCPCP",
    lazy=True
)
assert field.attrs["GRIB_count"] == 2
field = load_field_from_file(
    gfs_grib2_orig_file_path,
    parameter="ncpcp",
    lazy=True
)
assert field.attrs["GRIB_count"] == 2
field = load_field_from_file(
    gfs_grib2_orig_file_path,
    parameter="rainnc",
    lazy=True
)
assert field.attrs["GRIB_count"] == 2
field = load_field_from_file(
    gfs_grib2_orig_file_path,
    parameter={
        "discipline": 0,
        "parameterCategory": 1,
        "parameterNumber": 9,
    },
    lazy=True
)
assert field.attrs["GRIB_count"] == 2

总降水

要素名cemcwgrib2eccodesGRIB Key层次类型层次编号
总降水rainAPCP-(0, 1, 8)--3
field = load_field_from_file(
    gfs_grib2_orig_file_path,
    parameter="APCP",
    lazy=True
)
assert field.attrs["GRIB_count"] == 3
field = load_field_from_file(
    gfs_grib2_orig_file_path,
    parameter="rain",
    lazy=True
)
assert field.attrs["GRIB_count"] == 3
field = load_field_from_file(
    gfs_grib2_orig_file_path,
    parameter={
        "discipline": 0,
        "parameterCategory": 1,
        "parameterNumber": 8,
    },
    lazy=True
)
assert field.attrs["GRIB_count"] == 3

降雪量

要素名cemcwgrib2eccodesGRIB Key层次类型层次编号
降雪量snowASNOW-(0, 1, 29)--4
field = load_field_from_file(
    gfs_grib2_orig_file_path,
    parameter="ASNOW",
    lazy=True
)
assert field.attrs["GRIB_count"] == 4
field = load_field_from_file(
    gfs_grib2_orig_file_path,
    parameter={
        "discipline": 0,
        "parameterCategory": 1,
        "parameterNumber": 29,
    },
    lazy=True
)
assert field.attrs["GRIB_count"] == 4

TMP

地表温度

要素名cemcwgrib2eccodesGRIB Key层次类型层次编号
地表温度tsTMPt(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"] == 5
field = load_field_from_file(
    gfs_grib2_orig_file_path,
    parameter="t",
    level_type="surface",
    lazy=True
)
assert field.attrs["GRIB_count"] == 5
field = load_field_from_file(
    gfs_grib2_orig_file_path,
    parameter="ts",
    lazy=True
)
assert field.attrs["GRIB_count"] == 5
field = 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