Skip to content

Support spatial:dimensions and group-level spatial: attrs#93

Merged
dcherian merged 4 commits into
mainfrom
spatial-dimensions
Jun 3, 2026
Merged

Support spatial:dimensions and group-level spatial: attrs#93
dcherian merged 4 commits into
mainfrom
spatial-dimensions

Conversation

@dcherian

@dcherian dcherian commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Use the Zarr spatial convention's spatial:dimensions attribute to auto-detect x/y dimension names in assign_index, so non-standard dim names (e.g. Y/X) work without passing x_dim/y_dim. The names are interpreted positionally as [y, x], following the convention's examples; spatial:transform uses standard Affine coefficient ordering [a, b, c, d, e, f] mapping (col, row) -> (x, y).
  • Look up spatial: convention attributes on data variables and on the Dataset (group-level), not just DataArray.attrs. Array-level attrs take precedence over group-level attrs, per the convention. Previously get_affine ignored spatial: metadata entirely for Datasets.
  • The zarr_conventions registration gate is unchanged: bare spatial: attrs without the registration entry are still ignored (now test-covered).
  • Consolidate the zarr-convention registration checks (spatial:/proj:) into a shared _has_zarr_convention helper in lib.py, moving the proj: metadata typing there from utils.py.
  • Document the convention on the Creating and Heuristics doc pages (example verified to run).

Test plan

  • New tests: spatial:dimensions on a DataArray; group-level attrs on a Dataset; variable-level attrs (with both local and group-level registration); unregistered attrs ignored; dim-name mismatch raises.
  • Full suite passes: 102 passed, 7 skipped.

🤖 Generated with Claude Code

- Use the Zarr spatial convention's spatial:dimensions attribute to
  auto-detect x/y dimension names in assign_index. The order of the
  listed names is not significant per the convention: X is whichever
  named dimension comes last in the array's dimension order.
- Look up spatial: convention attributes on data variables and on the
  Dataset (group-level), not just DataArray attrs; array-level attrs
  take precedence per the convention.
- Document the convention in the Creating and Heuristics doc pages.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dcherian dcherian force-pushed the spatial-dimensions branch from 3bc3c7c to 681a63c Compare June 2, 2026 22:25
dcherian and others added 3 commits June 2, 2026 16:28
Share one _has_zarr_convention helper between the spatial: and proj:
convention registration checks, and move the proj: metadata typing from
utils.py to lib.py alongside it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Per the convention, the list order carries no normative meaning and
consumers define their own ordering rule; adopt the [y, x] order used by
all of the convention's examples. This removes the array-dim-order
inference and the guess_dims_from_spatial_zarr_convention wrapper:
assign_index now consumes spatial_dims_from_zarr_convention directly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dcherian dcherian merged commit b1d506c into main Jun 3, 2026
11 checks passed
@dcherian dcherian deleted the spatial-dimensions branch June 3, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant