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.

CMADAAS 数据文件

本节介绍如何使用 reki 内置的配置文件查找 CMADAAS 挂载目录 上的 CEMC 业务系统数据文件路径。

首先加载需要使用的模块

import pandas as pd
import numpy as np
import xarray as xr

from reki.data_finder import find_local_file
# 数据环境配置,用户可按实际环境修改
DATA_CLASS = "cmadaas"
STORAGE_BASE = "/CMADAAS"

生成起报时次和预报时效

start_time = pd.Timestamp.now('UTC').floor(freq='D') - pd.Timedelta(days=2)
start_time_label = start_time.strftime("%Y%m%d%H")
forecast_time_label = "24h"
forecast_time = pd.to_timedelta(forecast_time_label)
print("start_time:", start_time)
print("start_time_label:", start_time_label)
print("forecast_time:", forecast_time)
print("forecast_time_label:", forecast_time_label)
start_time: 2026-08-15 00:00:00+00:00
start_time_label: 2026081500
forecast_time: 1 days 00:00:00
forecast_time_label: 24h

基本用法

reki.data_finder.find_local_file 函数根据内置的配置文件查找CMADAAS 数据文件。

查找 CMA-GFS GRIB2 数据文件路径,使用如下参数

  • data_type: 数据类型,用于定位配置文件路径,这里使用内置的数据类型 "cma_gfs_gmf/grib2/orig"

  • start_time: 起报时次,格式 YYYYMMDDHH

  • forecast_time: 预报时效,通常为小时,理论上也支持分钟级别输出

file_path = find_local_file(
    "cma_gfs_gmf/grib2/orig",
    start_time=start_time,
    forecast_time=forecast_time,
    data_class=DATA_CLASS,
    storage_base=STORAGE_BASE
)
file_path

查找 CMA-GEPS GRIB2 数据文件路径,在上述参数基础上需要使用 number 参数指定集合成员编号。 其中 0 表示控制预报,1-31 表示 31 个集合成员。

file_path = find_local_file(
    "cma_geps/grib2/orig",
    start_time=start_time,
    forecast_time="24h",
    number=0,
    data_class=DATA_CLASS,
    storage_base=STORAGE_BASE
)
file_path
file_path = find_local_file(
    "cma_geps/grib2/orig",
    start_time=start_time,
    forecast_time="24h",
    number=14,
    data_class=DATA_CLASS,
    storage_base=STORAGE_BASE
)
file_path

如果想要查看 find_local_file 函数的具体查找文件过程,可以使用 debug=True 参数。

更多函数

reki.data_finder.get_local_file_name() 函数返回文件名,但不实际查找文件是否存在。

from reki.data_finder import get_local_file_name

file_name = get_local_file_name(
    "cma_meso_3km/grib2/orig",
    start_time=start_time,
    forecast_time=forecast_time,
    data_class=DATA_CLASS,
    storage_base=STORAGE_BASE,
)
file_name
'Z_NAFP_C_BABJ_20260815000000_P_NWPC-GRAPES-3KM-ORIG-02400.grb2'