Skip to content

Add a grid option in areacella calculation process - #676

Open
rhaegar325 wants to merge 1 commit into
mainfrom
fix-areacella-grid-selection
Open

Add a grid option in areacella calculation process#676
rhaegar325 wants to merge 1 commit into
mainfrom
fix-areacella-grid-selection

Conversation

@rhaegar325

@rhaegar325 rhaegar325 commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

Fix #672

Summary

areacella can now be built on any of the four ACCESS atmosphere stagger points
instead of only the theta points. CMIP7 only.

ACCESS_ESM_CMORiser(
    compound_name="atmos.areacella.ti-u-hxy-u.fx.glb",
    match_variable="ta",      # same cells as ta -> 144 rows, grid_label g110
)
variable_resources:
  atmos.areacella.ti-u-hxy-u.fx.glb:
    match_variable: ta        # or: grid_label: g110

Changes

calculate_areacella takes a grid_keyderivations/calc_atmos.py

  • New first argument grid_key: "default" | "U" | "V" | "other", the same
    keys resolve_atmosphere_grid_key returns. Defaults to the theta points.
  • Only the latitude/longitude vectors vary by point. The bounds and the area
    formula are untouched: the existing midpoint-plus-pole-clamp bounds are already
    correct for both the 145 theta rows and the 144 lat_v rows.
  • nlat still counts theta rows; "V" and "other" derive nlat - 1 from them.
  • An unknown grid_key raises instead of falling back to the theta grid.
  • The output comment names the point (theta/u/v/uv) from
    GRID_KEY_POINT_NAMES, which ATMOS_GRID_KEYS is also derived from, so the two
    cannot fall out of sync. The published text uses the UM's names for the points,
    not our configuration keys.

New match_variable argumentdriver.py

  • Resolution order: match_variable → an explicit grid_label, read back through
    the model's own cmip7_grid_labels → the mapping entry's own dimensions.
  • Once resolved, the areacella entry's dimensions are rewritten for that point
    and grid_key is injected into calculation.kwargs, so the computed areas, the
    dimensions and the grid label all describe the same cells. The CMORiser is
    unchanged — it already forwards calculation.kwargs to the internal function.
  • Rejected rather than ignored: a match_variable that is unknown, is not on the
    atmosphere grid, contradicts an explicit grid_label, names anything other than
    a computed areacella, or is used with cmip_version != "CMIP7".

Two helpersutilities.py

  • load_variable_entry(cmor_name, model_id) looks up a mapping entry by bare CMOR
    name. load_model_mappings now delegates to it and behaves as before.
  • invert_atmosphere_grid_labels(grid_labels) maps g110 → "other". A label
    configured for more than one point is omitted rather than resolved arbitrarily.

Batch configtemplates/cmor_job_script.j2, templates/cmor_python_script.j2

  • match_variable rides the existing variable_resources channel, next to
    grid_label.

Scope

CMIP7 only: the grid label is what tells the four points apart, and only CMIP7
registers one per point. CMIP6 publishes them all under gn and its areacella
table entry asks for the mass-point areas, so CMIP6 output is unchanged and
match_variable is rejected there.

@codecov

codecov Bot commented Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.3%. Comparing base (ab89a41) to head (89488d6).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##            main    #676     +/-   ##
=======================================
+ Coverage   78.1%   78.3%   +0.2%     
=======================================
  Files         40      40             
  Lines       8822    8877     +55     
  Branches    1664    1676     +12     
=======================================
+ Hits        6891    6951     +60     
+ Misses      1594    1591      -3     
+ Partials     337     335      -2     
Flag Coverage Δ
unit 78.3% <100.0%> (+0.2%) ⬆️

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

☔ View full report in Codecov by Harness.
📢 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.

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.

areacella is only ever computed on the theta grid, so staggered variables name the wrong cell measure

1 participant