ESMValGroup / ESMValCore

ESMValCore: A community tool for pre-processing data from Earth system models in CMIP and running analysis scripts.
https://www.esmvaltool.org
Apache License 2.0
42 stars 38 forks source link

Multi-Model statistics failing due to different non-scalar aux coord #2365

Open bettina-gier opened 6 months ago

bettina-gier commented 6 months ago

Describe the bug The CO2S derived variable adds a non-scalar auxiliary coordinate for the pressure, which makes the multi-model statistics preprocessor fail with the following error message:

File "/work/bd0854/b309137/esmval/ESMValCore/esmvalcore/preprocessor/_multimodel.py", line 427, in _combine
    raise ValueError(
ValueError: Multi-model statistics failed to merge input cubes into a single array:
0: mole_fraction_of_carbon_dioxide_in_air / (1e-06) (time: 60)
1: mole_fraction_of_carbon_dioxide_in_air / (1e-06) (time: 60)
2: mole_fraction_of_carbon_dioxide_in_air / (1e-06) (time: 60)
  Coordinates in cube.aux_coords (non-scalar) differ: air_pressure.

The recipe runs when using a regridding function before the global mean, as that removes this aux coordinate. Barring the idea of removing the aux coordinate from the derived variable, as this is nice information to have in some circumstances, there are a few options I could see to solve this issue:

  1. Remove non-scalar aux coordinates for multi-model statistics calculations, similar to the regrid preprocessor
  2. Also compute the multi-model statistics for the aux variables (also non-scalar)
  3. Also give errors using the regrid preprocessor in this case because "different aux coordinates mean they should not be mixed"

Personally I'd prefer option 2 from a physical standpoint, as it loses the least amount of information while giving plausible results. Thoughts?

Minimal working recipe:

preprocessors:

  glob_mean:
    #regrid:
    #  target_grid: 2x2
    #  scheme: linear
    area_statistics:
      operator: mean
    multi_model_statistics:
      span: overlap
      statistics: [mean]

diagnostics:

  test:
    description: MMM test
    variables:
      co2s:
        preprocessor: glob_mean
        derive: true
        project: CMIP6
        ensemble: r1i1p1f1
        exp: esm-hist
        mip: Amon
        start_year: 2010
        end_year: 2014
        grid: gn
        additional_datasets:
          - {dataset: ACCESS-ESM1-5}
          - {dataset: CanESM5}
          - {dataset: NorESM2-LM}
    scripts:
      null