Skip to content

Fix WCRP Geophysical Variable Detection for hybrid-height variables (cl/cli/clw)#403

Merged
rbeucher merged 1 commit into
mainfrom
fix_cl_geophysical_fails
May 28, 2026
Merged

Fix WCRP Geophysical Variable Detection for hybrid-height variables (cl/cli/clw)#403
rbeucher merged 1 commit into
mainfrom
fix_cl_geophysical_fails

Conversation

@rhaegar325
Copy link
Copy Markdown
Collaborator

Summary

After CMORisation renames the hybrid-height coordinate variables, the
coordinates and formula_terms attribute strings still referenced the
pre-rename input names. Those names no longer exist in the output, so the WCRP
wcrp_cmip6:1.0 Geophysical Variable Detection check mis-classified the
formula-term variables (b, orog) as data variables.

Problem

Dataset.rename() relabels variables but not the attribute strings that
reference them. For cl (and cli/clw):

cl:  coordinates  = "sigma_theta surface_altitude theta_level_height"  # none exist
lev: formula_terms = "a: theta_level_height b: sigma_theta orog: surface_altitude"

The real variables are b, orog, lev. Because the checker only excludes a
variable when it is referenced by a coordinates attribute (it ignores
formula_terms), b and orog were counted as geophysical:

Expected exactly 1 geophysical variable, found 3: ['b', 'cl', 'orog']

Fix

New helper Atmosphere_CMORiser._retarget_renamed_references(rename_map), called
right after self.ds.rename(rename_map), rewrites every coordinates /
formula_terms string to the post-rename names. Only tokens that are keys in
the 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()): the cl_level_to_height
dataset_function renames theta_level_height -> lev itself, so that key is
absent from the filtered map yet still appears in the attribute strings.

cl:  coordinates  = "b orog lev"
lev: formula_terms = "a: lev b: b orog: orog"

(There is no missing a variable: the a term is the level-height coordinate,
i.e. lev.)

@codecov
Copy link
Copy Markdown

codecov Bot commented May 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.0%. Comparing base (85df727) to head (af2754f).

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             
Flag Coverage Δ
unit 75.0% <100.0%> (+0.1%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rhaegar325 rhaegar325 requested a review from rbeucher May 28, 2026 00:49
@rbeucher rbeucher merged commit a87e12d into main May 28, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants