cedarkit-plots 不限定数据加载的工具库,可以支持多种数据源。 只要加载后的数据对象满足下面给出的基本条件,就可以被正确识别。
示例¶
使用 reki 加载 CMA-MESO 的 2 米温度场
# 数据环境配置:使用本地数据目录(可用环境变量 CEDARKIT_NOTEBOOK_DATA_ROOT 覆盖)
from cedarkit_notebook.data import get_data_root, get_dataset_query
DATA_CLASS = "cmadaas"
STORAGE_BASE = str(get_data_root())import pandas as pd
from reki.data_finder import find_local_file
from reki.format.grib.eccodes import load_field_from_file
# 起报时次与预报时效固定为本地已下载数据(见 data/metadata/cma-meso-3km.yaml)
query = get_dataset_query("cma-meso-3km")
start_time = pd.to_datetime(query["start_time"], format="%Y%m%d%H")
forecast_time = pd.to_timedelta(query["forecast_time"])
file_path = find_local_file(
"cma_meso_3km/grib2/orig",
start_time=start_time,
forecast_time=forecast_time,
data_class=DATA_CLASS,
storage_base=STORAGE_BASE,
)
t_2m_field = load_field_from_file(
file_path,
parameter="2t",
) - 273.15
t_2m_field/home/wangdp/project/cedarkit/notebook-project/notebook-devel/repo/cedarkit-notebook-project/cedarkit-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(
Loading...
上述要素场包含两个维度属性
latitude:纬度longitude:经度
同时包含其他非维度的坐标属性
time:起报时次step:预报时效valid_time:预报时间heightAboveGround:层次类型,离地面高度,单位米