Fix WCRP Geophysical Variable Detection for hybrid-height variables (cl/cli/clw)#403
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #403 +/- ##
=======================================
+ Coverage 74.9% 75.0% +0.1%
=======================================
Files 28 28
Lines 5246 5258 +12
Branches 963 967 +4
=======================================
+ Hits 3929 3941 +12
Misses 1092 1092
Partials 225 225
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
rbeucher
approved these changes
May 28, 2026
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
After CMORisation renames the hybrid-height coordinate variables, the
coordinatesandformula_termsattribute strings still referenced thepre-rename input names. Those names no longer exist in the output, so the WCRP
wcrp_cmip6:1.0Geophysical Variable Detection check mis-classified theformula-term variables (
b,orog) as data variables.Problem
Dataset.rename()relabels variables but not the attribute strings thatreference them. For
cl(andcli/clw):The real variables are
b,orog,lev. Because the checker only excludes avariable when it is referenced by a
coordinatesattribute (it ignoresformula_terms),bandorogwere counted as geophysical:Fix
New helper
Atmosphere_CMORiser._retarget_renamed_references(rename_map), calledright after
self.ds.rename(rename_map), rewrites everycoordinates/formula_termsstring to the post-rename names. Only tokens that are keys inthe rename map are changed, so non-hybrid variables are untouched.
The full intended rename
{**bounds_rename_map, **axes_rename_map}is passed(not the filtered map used by
rename()): thecl_level_to_heightdataset_function renames
theta_level_height -> levitself, so that key isabsent from the filtered map yet still appears in the attribute strings.
(There is no missing
avariable: theaterm is the level-height coordinate,i.e.
lev.)