Last active
March 24, 2025 18:59
-
-
Save kylebarron/b07560566a67fe7608613b63d5bca8ae to your computer and use it in GitHub Desktop.
obstore zarr planetary computer example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import pystac_client | |
import xarray as xr | |
from obstore.auth.planetary_computer import PlanetaryComputerCredentialProvider | |
from obstore.store import AzureStore | |
from zarr.storage import ObjectStore | |
catalog = pystac_client.Client.open( | |
"https://planetarycomputer.microsoft.com/api/stac/v1/" | |
) | |
collection = catalog.get_collection("daymet-daily-hi") | |
asset = collection.assets["zarr-abfs"] | |
credential_provider = PlanetaryComputerCredentialProvider.from_asset(asset) | |
azure_store = AzureStore(credential_provider=credential_provider) | |
zarr_store = ObjectStore(azure_store, read_only=True) | |
ds = xr.open_dataset(zarr_store, consolidated=True, engine="zarr") | |
fig, ax = plt.subplots(figsize=(12, 12)) | |
ds.sel(time="2009")["tmax"].mean(dim="time").plot.imshow(ax=ax, cmap="inferno") | |
fig |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[project] | |
name = "zarr-obstore-pc" | |
version = "0.1.0" | |
description = "Add your description here" | |
readme = "README.md" | |
requires-python = ">=3.12" | |
dependencies = [ | |
"matplotlib>=3.10.1", | |
"obstore>=0.6.0", | |
"pystac-client>=0.8.6", | |
"xarray>=2025.3.0", | |
"zarr", | |
] | |
[tool.uv.sources] | |
zarr = { git = "https://github.com/zarr-developers/zarr-python" } | |
[dependency-groups] | |
dev = [ | |
"ipykernel>=6.29.5", | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment