Within this notebook, we will cover:
Concepts | Importance | Notes |
---|---|---|
Kerchunk Basics | Required | Core |
Xarray Tutorial | Required | Core |
One way of using our reference dataset is opening it with Xarray
. To do this, we will create an fsspec
filesystem and pass it to Xarray
.
# create an fsspec reference filesystem from the Kerchunk output
import fsspec
import xarray as xr
import kerchunk
fs = fsspec.filesystem(
"reference",
fo="references/ARG_combined.json",
remote_protocol="s3",
skip_instance_cache=True,
)
m = fs.get_mapper("")
ds = xr.open_dataset(m, engine="zarr")
Kerchunk
Engine¶As of writing, the latest version of Kerchunk supports opening an reference dataset with Xarray without specifically creating an fsspec filesystem. This is the same behavior as the example above, just a few less lines of code.
storage_options = {
"remote_protocol": "s3",
"skip_instance_cache": True,
} # options passed to fsspec
open_dataset_options = {"chunks": {}} # opens passed to xarray
ds = xr.open_dataset(
"references/ARG_combined.json",
engine="kerchunk",
storage_options=storage_options,
open_dataset_options=open_dataset_options,
)