Skip to content

CMIP7 aerosol ua fails with KeyError 'lev' due to AERmon->CMIP7 vertical-axis mismatch #491

Description

@rbeucher

Summary

CMIP7 integration test for aerosol ua fails with KeyError: 'lev', while the atmos ua case passes.

  • Passing: tests/integration/test_full_cmorisation.py::TestFullCMORIntegration::test_cmorisation_variable_cmip7[atmos-ACCESS-ESM1-6-CMIP7_atmos.json-CMIP7-ua]
  • Failing: tests/integration/test_full_cmorisation.py::TestFullCMORIntegration::test_cmorisation_variable_cmip7[aerosol-ACCESS-ESM1-6-CMIP7_aerosol.json-CMIP7-ua]

Error:
Failed processing ua in AERmon (CMIP version: CMIP7): 'lev'

Reproduction

pixi run -e dev python -m pytest tests/integration/test_full_cmorisation.py -k "cmorisation_variable_cmip7 and aerosol and CMIP7-ua" -vv

What happens

The failure occurs in transpose-order construction in select_and_process_variables:

  • src/access_moppy/atmosphere.py around cmor_dims = re.sub(r"\\w*level", "lev", dimensions)
  • then lookup self.vocab.axes[dim] raises KeyError: 'lev'

Root cause

This is a mapping/axis-selection mismatch for the CMIP7 aerosol ua path:

  1. CMIP7 integration tests for table_name="aerosol" are driven from CMIP6 AERmon variable names.
  2. AERmon.ua maps to CMIP7 atmos.ua.tavg-al-hxy-u.mon.GLB (model-level / alevel).
  3. ACCESS AERmon.ua mapping expects pressure-based vertical dim ("pressure": "plev").
  4. CMIP7 _get_axes excludes alevel unless resolved via z-axis metadata, so no vertical axis is registered.
  5. Later, dimension normalization converts alevel -> lev, and transpose tries self.vocab.axes["lev"], which is missing.

Why the atmos case passes:

  • Amon.ua maps to atmos.ua.tavg-p19-hxy-air.mon.GLB, which aligns with pressure/plev handling and yields a valid vertical axis.

Evidence

  • CMIP6→CMIP7 mapping:
    • AERmon.ua -> atmos.ua.tavg-al-hxy-u.mon.GLB
    • Amon.ua -> atmos.ua.tavg-p19-hxy-air.mon.GLB
  • ACCESS mapping for ua uses pressure: plev.
  • CMIP7 aerosol table has ua at 10hPa (ua_tavg-10hPa-hxy-air), while current AERmon.ua mapping points into atmos model-level form.

Suggested fix options

  1. Correct CMIP6→CMIP7 mapping for AERmon.ua to a pressure-level CMIP7 target compatible with ACCESS ua mapping (or remove invalid mapping if unsupported).
  2. Harden CMIP7 axis handling for alevel when selected via mapping path (ensure lev axis exists before transpose).
  3. Add an explicit guard/error message when CMIP7 selected variable vertical axis is incompatible with model mapping dimensions.

Acceptance criteria

  • The failing aerosol CMIP7-ua integration test passes.
  • Atmos CMIP7-ua test remains passing.
  • No regression for AERday.ua10 and AERmonZ.ua.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions