Support spatial:dimensions and group-level spatial: attrs#93
Merged
Conversation
- 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>
3bc3c7c to
681a63c
Compare
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>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
spatial:dimensionsattribute to auto-detect x/y dimension names inassign_index, so non-standard dim names (e.g.Y/X) work without passingx_dim/y_dim. The names are interpreted positionally as[y, x], following the convention's examples;spatial:transformuses standard Affine coefficient ordering[a, b, c, d, e, f]mapping(col, row) -> (x, y).spatial:convention attributes on data variables and on the Dataset (group-level), not justDataArray.attrs. Array-level attrs take precedence over group-level attrs, per the convention. Previouslyget_affineignoredspatial:metadata entirely for Datasets.zarr_conventionsregistration gate is unchanged: barespatial:attrs without the registration entry are still ignored (now test-covered).spatial:/proj:) into a shared_has_zarr_conventionhelper inlib.py, moving theproj:metadata typing there fromutils.py.Test plan
spatial:dimensionson aDataArray; group-level attrs on aDataset; variable-level attrs (with both local and group-level registration); unregistered attrs ignored; dim-name mismatch raises.🤖 Generated with Claude Code