Drop dangling grid_mapping (and um_stash_source) from atmosphere CMOR output#468
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #468 +/- ##
=====================================
Coverage 77.2% 77.2%
=====================================
Files 31 31
Lines 6030 6032 +2
Branches 1122 1122
=====================================
+ Hits 4653 4655 +2
Misses 1126 1126
Partials 251 251
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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
CMORised ACCESS-ESM1-5 atmosphere (
Amon) files failed the CF check:The fix drops the model-native
grid_mappingattribute (and the relatedum_stash_sourceprovenance attribute) that leak from the raw UM variable into theCMORised output. Affected all 9
Amonvariables in the test set.Root cause
grid_mapping = "latitude_longitude"on each sourcevariable and include a
latitude_longitudegrid-mapping container variable(valid CF).
name (
self.ds.rename({raw_var: cmor_name})), which keeps the source variable'sattributes.
update_attributesthen merges the CMOR-table attributes on top withattrs.update(...), without clearing the inherited ones.latitude_longitudecontainer variable is not carried into the CMORised output(only the target variable + coordinates/bounds are kept).
Net result: the output variable keeps
grid_mapping = "latitude_longitude"pointing at avariable that no longer exists → a dangling reference that fails the CF grid-mapping check.
The same mechanism leaks
um_stash_source(a UM STASH code).This was confirmed against the published reference: official CMIP6
Amon/tashas neithergrid_mappingnor alatitude_longitudevariable — regular lat-lon grids carry no gridmapping.
Change
src/access_moppy/atmosphere.py— inupdate_attributes, alongside the existingattrs.pop("axis")/attrs.pop("positive")cleanup:Tests
tests/unit/test_atmosphere.py—TestUpdateAttributesDecodedTime::test_model_native_attributes_droppedsets
grid_mappingandum_stash_sourceon the variable, runsupdate_attributes, andasserts both are gone.
tests/unit/test_atmosphere.py: 56 passed.