在读取 NBM 的远程数据集(https://vlab.ncep.noaa.gov/web/mdl/nbm)时,我得到一个xarray.core.variable.MissingDimensionsError
. 我确定我在open_dataset
.
您可以在此处查看数据结构:https ://thredds-jumbo.unidata.ucar.edu/thredds/dodsC/grib/NCEP/NBM/CONUS/TwoD.html 。完整的结构在这里显示使用ncdump -h https://thredds-jumbo.unidata.ucar.edu/thredds/dodsC/grib/NCEP/NBM/CONUS/TwoD
使用的变量time1
:
- Precipitation_type_surface_probability_between_1p0_and_2
import xarray as xr
url = "https://thredds-jumbo.unidata.ucar.edu/thredds/dodsC/grib/NCEP/NBM/CONUS/TwoD"
ds = xr.open_dataset(url)
如果您删除此变量,则它会进入下一次变暗
ds = xr.open_dataset(url, drop_variables="time1")
xarray.core.variable.MissingDimensionsError: 'time2' has more than 1-dimension and the same name as one of its dimensions ('reftime4', 'time2'). xarray disallows such variables because they conflict with the coordinates used to label dimensions.
完整回溯
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/ray.bell/miniconda/envs/test_env/lib/python3.8/site-packages/xarray/backends/api.py", line 575, in open_dataset
ds = maybe_decode_store(store, chunks)
File "/Users/ray.bell/miniconda/envs/test_env/lib/python3.8/site-packages/xarray/backends/api.py", line 471, in maybe_decode_store
ds = conventions.decode_cf(
File "/Users/ray.bell/miniconda/envs/test_env/lib/python3.8/site-packages/xarray/conventions.py", line 600, in decode_cf
ds = Dataset(vars, attrs=attrs)
File "/Users/ray.bell/miniconda/envs/test_env/lib/python3.8/site-packages/xarray/core/dataset.py", line 630, in __init__
variables, coord_names, dims, indexes, _ = merge_data_and_coords(
File "/Users/ray.bell/miniconda/envs/test_env/lib/python3.8/site-packages/xarray/core/merge.py", line 467, in merge_data_and_coords
return merge_core(
File "/Users/ray.bell/miniconda/envs/test_env/lib/python3.8/site-packages/xarray/core/merge.py", line 594, in merge_core
collected = collect_variables_and_indexes(aligned)
File "/Users/ray.bell/miniconda/envs/test_env/lib/python3.8/site-packages/xarray/core/merge.py", line 278, in collect_variables_and_indexes
variable = as_variable(variable, name=name)
File "/Users/ray.bell/miniconda/envs/test_env/lib/python3.8/site-packages/xarray/core/variable.py", line 154, in as_variable
raise MissingDimensionsError(
xarray.core.variable.MissingDimensionsError: 'time1' has more than 1-dimension and the same name as one of its dimensions ('reftime', 'time1'). xarray disallows such variables because they conflict with the coordinates used to label dimensions.
你可以在本地测试
wget https://ftp.ncep.noaa.gov/data/nccf/com/blend/prod/blend.20210214/00/core/blend.t00z.core.f001.co.grib2