exception to indexed-coordinate only inheritance for `coordinates` encoding
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.2k
- Forks
- 1.4k
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 14
Description
Is your feature request related to a problem?
From review of #9475, #10812, and linked PRs, I partially understand the difficulty involved in resolving questions around shared coordinates within datatrees. The decision to support inheritance for indexed-coordinates makes a lot of sense. I think there is a practical use-case for allowing additional inheritance: when decode_cf=True and a CF-Conventions compliant coordinates attribute implies inheritance.
Here is an example of a CF-Convention coordinates attribute:
xarray.DataTree.from_dict(
{
"x": [0, 1],
"y": [0, 1, 2],
"lon": (("x", "y"), [[0, 0, 0], [1, 1, 1]]),
"lat": (("x", "y"), [[0, 1, 2], [0, 1, 2]]),
"products/temp": (
("x", "y"), [[4, 6, 2], [5, 7, 3]], None, {"coordinates": "/lon /lat"}
),
},
)
or in netCDF's CDL:
dimensions:
x = 2 ;
y = 3 ;
variables:
int64 x(x) ;
int64 y(y) ;
int64 lon(x, y) ;
int64 lat(x, y) ;
group: products {
variables:
int64 temp(x, y) ;
temp:coordinates = "/lon /lat" ;
} // group products
Describe the solution you'd like
When a data variable's encoding includes coordinates that identify an "auxiliary coordinate variable" (sensu NUG) or "non-indexed coordinate" (sensu XArray) that is within scope, then that variable should be set as a coordinate and inherited if necessary.
I add "if necessary", because the in-scope coordinate could be within the same group. In which case there is nothing to inherit.
Describe alternatives you've considered
Any variable encoded in a coordinates string could have a (possibly multi-dimensional) index created automatically; so that the indexed-coordinate only inheritance is preserved. I think that would be too expensive.
Additional context
I am supporting refinement of netCDF files distributed by a NASA DAAC, and understanding how XArray is thinking about absolute and relative path-like elements of coordinates encodings would really help us help our data users.
Contributor guide
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.
Research direction
Start with the DataTree.from_dict example and the decode_cf=True path, then trace the existing indexed-coordinate inheritance behavior discussed in issues #9475 and #10812. Determine how CF coordinates encodings are resolved across groups and define tests for same-group and inherited auxiliary coordinates. Done means in-scope coordinates are set and inherited when necessary without creating indexes automatically.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100