Consider adding opt-in support for circular axes when calling `bounds_to_vertices` (related to #594)
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 38/100
Research direction
Start by reading the bounds_to_vertices implementation and the context in issues #594 and #595. Define the expected behavior for circular_period and start, including seam rotation and periodic axes beyond longitude. Done means an opt-in API handles mixed circular coordinates without NotImplementedError while preserving existing ascending and descending behavior.
Written by the indexing model from the issue text.
Description
Description
The latest bounds_to_vertices() function in cf-xarray v0.10.7+ only handles core dimensions that are in ascending or descending order. Core dims that are in mixed order instead raise a NotImplementedError #595 with a message for the user to normalize coordinates to a monotonic convention (related comment).
Examples
-
Ascending
[0, 1, 2, ..., 357, 358, 359] -
Descending
[359, 358, 357, ..., 2, 1, 0] -
Mixed (wraps at seam)
[0, 1, 2, ..., 179, -180, -179, ..., -1]
bounds_to_vertices() works in the first two cases but fails in the third.
Proposed solution
For a long-term solution, it might be worth considering opt-in support for circular axes, e.g.:
bounds_to_vertices(..., circular_period=360.0, start=None)
With circular_period set, cf-xarray could:
- Detect circular monotonicity
- Rotate away from the seam
- Proceed safely as if the dimension were monotonic
While longitude (circular_period=360.0) is the most common use case, the same approach could generalize to other periodic axes (e.g. angles, phases).
Why it is useful
- Users working with model output that mixes
0–360and−180–180conventions may encounterNotImplementedErrortoday and must manually normalize coordinates before downstream operations. - This affects packages such as xESMF, which rely on
bounds_to_vertices()but do not implement detection/normalization for circular axes. - I’ve opened a related xESMF issue for visibility: https://github.com/pangeo-data/xESMF/issues/454
- Dominant language
- Python
- Stars
- 181
- Forks
- 49
- Avg merge
- 43m
- Merged PRs (30d)
- 1
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from xarray-contrib/cf-xarray
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
xarray-contrib/cf-xarray#623 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 25/100
xarray-contrib/cf-xarray#570 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 15/100
xarray-contrib/cf-xarray#568 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
xarray-contrib/cf-xarray#566 · 2 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
xarray-contrib/cf-xarray#543 · 14 comments ·
All issues in xarray-contrib/cf-xarray
Similar issues
-
bug confirmed issue
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
open-webui/open-webui#30750 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
OpenwaterHealth/openmotion-bloodflow-app#604 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
good first issue
Difficulty 1/5 Under an hour Newbie friendliness 90/100