Skip to content

regrid pre-processor removes coordinates that may be useful #2839

@sloosvel

Description

@sloosvel

Describe the bug
In #2672 , unwanted coordinates were removed from the source cube in order to perform the regridding.

However, if a recipe contains a dataset that has a horizontal grid close enough to the target_grid, and therefore the dataset is ultimately not regridded, the cube loses necessary coordinates and steps like multi_model_statistics cannot be computed afterwards because the affected cube is missing coordinates:

ValueError: Multi-model statistics failed to merge input cubes into a single array:
0: surface_temperature / (K)           (time: 365; -- : 412; -- : 424)
1: surface_temperature / (K)           (time: 365; grid_latitude: 412; grid_longitude: 424)
  Coordinates in cube.dim_coords differ: grid_latitude, grid_longitude.
  Coordinate-to-dimension mapping differs for cube.dim_coords.

A solution would be to perform this removal after the check for the horizontal grid is performed.

Example recipe with two datasets with the same grid that then fails at the multi_model_statistics step:

documentation:
  title: |
    test
  authors:
    - loosveldt-tomas_saskia
  description: |
    test

preprocessors:
  ts_pp:
    regrid:
      target_grid: RCA4
      scheme: linear
    multi_model_statistics:
      span: overlap
      statistics: [mean]


datasets:
  - {project: CORDEX, domain: EUR-11, dataset: RCA4, driver: CNRM-CERFACS-CNRM-CM5, ensemble: r1i1p1, institute: SMHI, rcm_version: v1}
  - {project: CORDEX, domain: EUR-11, dataset: REMO2015, driver: IPSL-IPSL-CM5A-LR, ensemble: r1i1p1, institute: GERICS, rcm_version: v1}
diagnostics:
  bias:
    variables:
      ts_cordex:
        short_name: ts
        mip: day
        exp: historical
        timerange: 2003/2003
        preprocessor: ts_pp
    scripts: null

The regridding step could be skipped in this case, but in cases like recipe ESMValGroup/ESMValTool#4199 where there are datasets in the same grid and datasets in a different grid, this issue prevents the recipe from running properly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions