2

我正在寻找使用阅读远程 zarr 商店xarray.open_mfdataset()

我得到一个zarr.errors.GroupNotFoundError: group not found at path ''. 追溯在底部。

import xarray as xr
import s3fs

fs = s3fs.S3FileSystem(anon=True)
uri = "s3://era5-pds/zarr/2020/12/data/eastward_wind_at_10_metres.zarr"
file = s3fs.S3Map(uri, s3=fs)
ds = xr.open_mfdataset(file, engine="zarr")

我可以使用打开它xr.open_zarr

ds = xr.open_zarr(file)

如果我要在本地下载 zarr 商店,它可以正常工作

import xarray as xr
import s3fs
fs = s3fs.S3FileSystem(anon=True)
fs.get("s3://era5-pds/zarr/2020/12/data/eastward_wind_at_10_metres.zarr/*", "eastward_wind_at_10_metres.zarr", recursive=True)
ds = xr.open_mfdataset("eastward_wind_at_10_metres.zarr", engine="zarr")

open_mfdataset远程 zarr 商店的引用

>>> ds = xr.open_mfdataset(file, engine="zarr")
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 948, in open_mfdataset
    datasets = [open_(p, **open_kwargs) for p in paths]
  File "/Users/ray.bell/miniconda/envs/test_env/lib/python3.8/site-packages/xarray/backends/api.py", line 948, in <listcomp>
    datasets = [open_(p, **open_kwargs) for p in paths]
  File "/Users/ray.bell/miniconda/envs/test_env/lib/python3.8/site-packages/xarray/backends/api.py", line 572, in open_dataset
    store = opener(filename_or_obj, **extra_kwargs, **backend_kwargs)
  File "/Users/ray.bell/miniconda/envs/test_env/lib/python3.8/site-packages/xarray/backends/zarr.py", line 296, in open_group
    zarr_group = zarr.open_group(store, **open_kwargs)
  File "/Users/ray.bell/miniconda/envs/test_env/lib/python3.8/site-packages/zarr/hierarchy.py", line 1166, in open_group
    raise GroupNotFoundError(path)
zarr.errors.GroupNotFoundError: group not found at path ''
4

1 回答 1

2

我认为 open_mfdataset 正在您的路径上执行某种 glob,因为它需要处理多个路径(因为这是多文件)。

以下确实有效(前者可能只在主人身上)

ds = xr.open_mfdataset(uri, engine="zarr", backend_kwargs=dict(storage_options={'anon': True}))

ds = xr.open_mfdataset([file], engine="zarr")
于 2021-02-10T22:00:56.670 回答