我正在尝试使用xarray
和从 DWD 的 ICON 模型加载 GRIB2 文件cfgrib
。大多数变量都可以正常工作,但对于某些变量(例如CLCL
),xarray.open_dataset
会引发以下错误:
Traceback (most recent call last):
File "/shared/conda/envs/devtools/lib/python3.8/site-packages/xarray/core/dataset.py", line 1398, in _construct_dataarray
variable = self._variables[name]
KeyError: 'CLCL'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "DAT-2634/grib_file_loaders.py", line 276, in <module>
df_cfgrib_sf = read_cfgrib_sf(grib_fns, nodes, params)
File "DAT-2634/grib_file_loaders.py", line 115, in read_cfgrib_sf
x = xr.open_dataset(
File "/shared/conda/envs/devtools/lib/python3.8/site-packages/xarray/core/dataset.py", line 1502, in __getitem__
return self._construct_dataarray(key)
File "/shared/conda/envs/devtools/lib/python3.8/site-packages/xarray/core/dataset.py", line 1400, in _construct_dataarray
_, name, variable = _get_virtual_variable(
File "/shared/conda/envs/devtools/lib/python3.8/site-packages/xarray/core/dataset.py", line 173, in _get_virtual_variable
ref_var = variables[ref_name]
KeyError: 'CLCL'
grib_ls
当我通过我检查文件时
$ grib_ls ICON_europe_reg_0.125x0.125_2021101900_f000.grib2 | grep CLCL
2 edzw 20211019 fc regular_ll 0 unknown 800 CLCL grid_simple
我在cfgrib
问题#195和#213中读到这可能是由于使用了本地代码,并且我可能能够使用适当的代码表来解决问题。DWD 确实为 ecCodes 提供了 GRIB 表,但我不确定如何将它们与cfgrib
.
如何使用自定义代码表cfgrib
?还是有另一种方法来加载这些变量?