Create coordinate bounds on the internal-calculation path (WCRP ATTR001) - #647
Merged
Conversation
`areacella` was written with no `lat_bnds`/`lon_bnds` and no `bounds`
attribute on either coordinate, failing two weight-3 WCRP checks:
[ATTR001] Required variable 'lat' attribute 'bounds' is missing.
[ATTR001] Required variable 'lon' attribute 'bounds' is missing.
The missing attribute was a symptom: the bounds variables were never
created. `select_and_process_variables` returns early for
`calculation.type == "internal"`, skipping the
`_get_required_bounds_variables` / `calculate_missing_bounds_variables`
pair that every other path reaches. The vocabulary was already correct —
asked directly it reports `must_have_bounds='yes'` for both axes and
`bnds_required = ['lon_bnds', 'lat_bnds']` — the answer just had no
consumer. `reorder()` already reserves slots for `lat_bnds`/`lon_bnds`,
so their absence was the anomaly, not the design.
Separately, `calculate_areacella` builds a full (145, 2) `lat_bnds` array
to derive the cell areas and then discards it, and never computes
`lon_bnds` at all. Rather than return those, call the existing bounds
machinery before the early return: it fixes the class rather than the one
variable, and `calculate_longitude_bounds` already unwraps the 0°-crossing
first cell (#635), so no new bounds arithmetic is introduced.
`areacella` is currently the only internal-calculation entry in the
ESM1-5 and ESM1-6 mappings. `ocean.py` and `sea_ice.py` carry the same
early return, but have no internal variables to exercise it; left alone
rather than changing untestable paths.
Verified end to end: `lat_bnds`/`lon_bnds` are now bit-identical to
`orog`'s on the shared N96 grid (first lon cell `[-0.9375, 0.9375]`, not
the wrapped form), both ATTR001 bounds checks go `[0, 1]` -> `[1, 1]`, and
the two `[VAR012]` bounds-consistency checks — which could not run before —
pass. `orog` output is byte-for-byte unchanged.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #647 +/- ##
=======================================
+ Coverage 77.2% 77.3% +0.1%
=======================================
Files 40 40
Lines 8522 8524 +2
Branches 1593 1593
=======================================
+ Hits 6583 6590 +7
+ Misses 1610 1604 -6
- Partials 329 330 +1
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:
|
rbeucher
approved these changes
Aug 24, 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.
areacellawas written with nolat_bnds/lon_bndsand noboundsattribute on either coordinate, failing two weight-3 WCRP checks:The missing attribute was a symptom: the bounds variables were never created.
select_and_process_variablesreturns early forcalculation.type == "internal", skipping the_get_required_bounds_variables/calculate_missing_bounds_variablespair that every other path reaches. The vocabulary was already correct — asked directly it reportsmust_have_bounds='yes'for both axes andbnds_required = ['lon_bnds', 'lat_bnds']— the answer just had no consumer.reorder()already reserves slots forlat_bnds/lon_bnds, so their absence was the anomaly, not the design.Separately,
calculate_areacellabuilds a full (145, 2)lat_bndsarray to derive the cell areas and then discards it, and never computeslon_bndsat all. Rather than return those, call the existing bounds machinery before the early return: it fixes the class rather than the one variable, andcalculate_longitude_boundsalready unwraps the 0°-crossing first cell (#635), so no new bounds arithmetic is introduced.areacellais currently the only internal-calculation entry in the ESM1-5 and ESM1-6 mappings.ocean.pyandsea_ice.pycarry the same early return, but have no internal variables to exercise it; left alone rather than changing untestable paths.Verified end to end:
lat_bnds/lon_bndsare now bit-identical toorog's on the shared N96 grid (first lon cell[-0.9375, 0.9375], not the wrapped form), both ATTR001 bounds checks go[0, 1]->[1, 1], and the two[VAR012]bounds-consistency checks — which could not run before — pass.orogoutput is byte-for-byte unchanged.