-
In the current documentation we have this snippet to read a kerchunk file: backend_args = {"consolidated": False, "storage_options": {"fo": d, "remote_protocol": "s3","remote_options": {"anon": True}}}
print(xr.open_dataset("reference://", engine="zarr", backend_kwargs=backend_args)) This throws an exception What would be the correct way of opening a kerchunk reference in xarray using Zarr v3 with fsspec? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
This is one way (note import json
import xarray as xr
with open("mur_kerchunk.json", "r") as f:
refs = json.load(f)
backend_args = {"consolidated": False, "storage_options": {"fo": refs, "remote_protocol": "s3", "remote_options": {"anon": True, "asynchronous": True, }}}
ds = xr.open_dataset("reference://", engine="zarr", backend_kwargs=backend_args)
print(ds) or another: import json
import fsspec
import xarray as xr
import zarr
from fsspec.implementations.asyn_wrapper import AsyncFileSystemWrapper
with open("mur_kerchunk.json", "r") as f:
refs = json.load(f)
fs = fsspec.filesystem("reference", fo=refs, remote_protocol = "s3", remote_options={"anon": True})
store = zarr.storage.FsspecStore(AsyncFileSystemWrapper(fs), read_only=True)
ds = xr.open_zarr(store, zarr_format=2, consolidated=False)
print(ds) |
Beta Was this translation helpful? Give feedback.
-
Just FYI, this worked: fs = fsspec.filesystem("reference",
fo=metadata,
remote_protocol="s3",
asynchronous=True,
remote_options={"asynchronous": True, **daac_fs.storage_options}
)
store = zarr.storage.FsspecStore(fs, read_only=True)
ds = xr.open_zarr(store, zarr_format=2, consolidated=False) notice the |
Beta Was this translation helpful? Give feedback.
This is one way (note
asynchronous=True
inremote_options
).:or another: