Skip to content

Commit

Permalink
sqme: zarr chunk store
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirill888 committed Jun 25, 2024
1 parent 6079376 commit a5887e7
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions odc/loader/_zarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import numpy as np
import xarray as xr
from dask.delayed import Delayed, delayed
from fsspec.core import url_to_fs
from odc.geo.geobox import GeoBox
from odc.geo.xr import ODCExtensionDa, ODCExtensionDs, xr_coords, xr_reproject

Expand Down Expand Up @@ -59,11 +60,23 @@ def _from_zarr_spec(
fsspec_opts: dict[str, Any] | None = None,
) -> xr.Dataset:
fsspec_opts = fsspec_opts or {}
rfs = fsspec.filesystem(
"reference", fo=spec_doc, fs=fs, target=target, **fsspec_opts
chunk_store = None
if target is not None:
if fs is None:
fs, target = url_to_fs(target, **fsspec_opts)

if fs is not None:
chunk_store = fs.get_mapper(target)

md_store = fsspec.filesystem("reference", fo=spec_doc).get_mapper("")
xx = xr.open_dataset(
md_store,
chunk_store=chunk_store,
chunks=chunks,
engine="zarr",
consolidated=True,
mode="r",
)

xx = xr.open_dataset(rfs.get_mapper(""), engine="zarr", mode="r", chunks=chunks)
gbox = xx.odc.geobox
if gbox is not None and regen_coords:
# re-gen x,y coords from geobox
Expand Down

0 comments on commit a5887e7

Please sign in to comment.