You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, when a Dataset has Zarr conventions declared at the dataset level, individual DataArrays within that Dataset cannot inherit the conventions. This leads to inconsistent behavior:
# Dataset has conventions at group levelds=xr.Dataset({"var1": (["y", "x"], data)})
ds.attrs= {
"zarr_conventions": [{"name": "proj:", ...}],
"proj:code": "EPSG:4326"
}
print(ds.rio.crs) # ✅ Works: reads from dataset attrs print(ds["var1"].rio.crs) # ❌ Returns None: DataArray doesn't inherit
According to Zarr conventions, DataArrays should inherit group-level metadata when they don't have their own conventions declared.
Root Cause
xarray doesn't maintain parent-child relationships between Dataset and DataArray
Problem
Currently, when a Dataset has Zarr conventions declared at the dataset level, individual DataArrays within that Dataset cannot inherit the conventions. This leads to inconsistent behavior:
According to Zarr conventions, DataArrays should inherit group-level metadata when they don't have their own conventions declared.
Root Cause
zarr.read_crs(obj)only examinesobj.attrs, not potential parent Dataset attributesXRasterBase.crsproperty has no context about inheritance hierarchyProposed Solutions
Option 1: Explicit Parent Registration
Add explicit inheritance support to
XRasterBase:Pros: Explicit, backward compatible, extensible to all metadata types
Cons: Requires manual setup
Option 2: Enhanced Dataset Accessor
Automatically set up inheritance when accessing DataArrays from Dataset:
Pros: More automatic, better UX
Cons: Requires careful integration with xarray accessors
Implementation Considerations
Breaking Changes
None - inheritance would be opt-in and backward compatible.
Alternative Approaches Considered