stac-utils / xpystac

For extending xarray.open_dataset to accept pystac objects
MIT License
32 stars 2 forks source link

Add a test and example for zarr #11

Closed jsignell closed 1 year ago

jsignell commented 1 year ago

With the following set up:

import planetary_computer
import pystac_client

catalog = pystac_client.Client.open(
    "https://planetarycomputer.microsoft.com/api/stac/v1",
    modifier=planetary_computer.sign_inplace,
)
collection = catalog.get_collection("daymet-daily-hi")
asset = collection.assets["zarr-abfs"]

Without xpystac

import xarray as xr

ds = xr.open_zarr(
    asset.href,
    **asset.extra_fields["xarray:open_kwargs"],
    storage_options=asset.extra_fields["xarray:storage_options"]
)
ds

With xpystac

import xarray as xr

ds = xr.open_dataset(asset)
ds

Closes #9

Note: code coverage is up to 93% after this PR.