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:
- CMIP7 integration tests for
table_name="aerosol" are driven from CMIP6 AERmon variable names.
AERmon.ua maps to CMIP7 atmos.ua.tavg-al-hxy-u.mon.GLB (model-level / alevel).
- ACCESS
AERmon.ua mapping expects pressure-based vertical dim ("pressure": "plev").
- CMIP7
_get_axes excludes alevel unless resolved via z-axis metadata, so no vertical axis is registered.
- 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
- Correct CMIP6→CMIP7 mapping for
AERmon.ua to a pressure-level CMIP7 target compatible with ACCESS ua mapping (or remove invalid mapping if unsupported).
- Harden CMIP7 axis handling for
alevel when selected via mapping path (ensure lev axis exists before transpose).
- 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.
Summary
CMIP7 integration test for aerosol
uafails withKeyError: 'lev', while the atmosuacase passes.tests/integration/test_full_cmorisation.py::TestFullCMORIntegration::test_cmorisation_variable_cmip7[atmos-ACCESS-ESM1-6-CMIP7_atmos.json-CMIP7-ua]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" -vvWhat happens
The failure occurs in transpose-order construction in
select_and_process_variables:src/access_moppy/atmosphere.pyaroundcmor_dims = re.sub(r"\\w*level", "lev", dimensions)self.vocab.axes[dim]raisesKeyError: 'lev'Root cause
This is a mapping/axis-selection mismatch for the CMIP7 aerosol
uapath:table_name="aerosol"are driven from CMIP6AERmonvariable names.AERmon.uamaps to CMIP7atmos.ua.tavg-al-hxy-u.mon.GLB(model-level /alevel).AERmon.uamapping expects pressure-based vertical dim ("pressure": "plev")._get_axesexcludesalevelunless resolved via z-axis metadata, so no vertical axis is registered.alevel -> lev, and transpose triesself.vocab.axes["lev"], which is missing.Why the atmos case passes:
Amon.uamaps toatmos.ua.tavg-p19-hxy-air.mon.GLB, which aligns with pressure/plev handling and yields a valid vertical axis.Evidence
AERmon.ua->atmos.ua.tavg-al-hxy-u.mon.GLBAmon.ua->atmos.ua.tavg-p19-hxy-air.mon.GLBuausespressure: plev.uaat 10hPa (ua_tavg-10hPa-hxy-air), while currentAERmon.uamapping points into atmos model-level form.Suggested fix options
AERmon.uato a pressure-level CMIP7 target compatible with ACCESSuamapping (or remove invalid mapping if unsupported).alevelwhen selected via mapping path (ensurelevaxis exists before transpose).Acceptance criteria
CMIP7-uaintegration test passes.CMIP7-uatest remains passing.AERday.ua10andAERmonZ.ua.