sort when encoding coordinates for deterministic outputs #8034
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.
whats-new.rst
[ ] New functions/methods are listed inapi.rst
The PR changes
conventions._encode_coordinates
to addsorted
during the creation of "coordinates" strings de novo. It does not touch user-specified coordinates attributes or encodings.The PR adds a test, but also changes two pre-existing tests that allowed for non-deterministic ordering of the coordinates string.
In reviewing the netCDF data model and CF convenstions, I confirmed that there is no requirement on the ordering of names in the coordinates attribute. I also learned that the global coordinates attribute created by XArray for non-dimension coordinates that are not associated with a variable is not compliant with CF conventions, as was discussed in 2014. In 2021, CF-Conventions 1.9 added "Domain Variables", which appear to provide a CF compliant way to handle this situation. I will likely open an enhancement issue to weigh making that change.