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
43 stars 38 forks source link

regridding some CMIP6 datasets fails due to missing coordinate bounds #470

Open jhardenberg opened 4 years ago

jhardenberg commented 4 years ago

Attempting to regrid the following CMIP6 datasets (Amon) (for example in the quantilebias recipe) using the area_weighted scheme

- {dataset: IPSL-CM6A-LR, project: CMIP6, exp: historical, ensemble: r1i1p1f1, start_year: 1979, end_year: 2014, grid: gr}
   - {dataset: FGOALS-f3-L, project: CMIP6, exp: historical, ensemble: r1i1p1f1, start_year: 1979, end_year: 2014, grid: gr}
   - {dataset: CNRM-CM6-1, project: CMIP6, exp: historical, ensemble: r1i1p1f2, start_year: 1979, end_year: 2014, grid: gr}
   - {dataset: CNRM-ESM2-1, project: CMIP6, exp: historical, ensemble: r1i1p1f2, start_year: 1979, end_year: 2014, grid: gr}
   - {dataset: CNRM-CM6-1-HR, project: CMIP6, exp: historical, ensemble: r1i1p1f2, start_year: 1979, end_year: 2014, grid: gr}

fails with

File "/home/jost/miniconda3/envs/esmvaltool/lib/python3.7/site-packages/esmvalcore/preprocessor/_regrid.py", line 257, in regrid
    cube = cube.regrid(target_grid, HORIZONTAL_SCHEMES[scheme])
  File "/home/jost/miniconda3/envs/esmvaltool/lib/python3.7/site-packages/iris/cube.py", line 3745, in regrid
    return regridder(self)
  File "/home/jost/miniconda3/envs/esmvaltool/lib/python3.7/site-packages/iris/analysis/_area_weighted.py", line 113, in __call__
    cube, self._target_grid_cube, mdtol=self._mdtol)
  File "/home/jost/miniconda3/envs/esmvaltool/lib/python3.7/site-packages/iris/experimental/regrid.py", line 680, in regrid_area_weighted_rectilinear_src_and_grid
    raise ValueError("The horizontal grid coordinates of both the source "
ValueError: The horizontal grid coordinates of both the source and grid cubes must have contiguous bounds.

This occurs only with the "area_weighted scheme", not with "linear_extrapolate". All other CMIP6 datasets behave fine instead.

In fact, all these datasets are either missing coordinate bounds or have non-contiguous bounds (FGOALS-f3-L)

zklaus commented 4 years ago

The missing bounds are a clear data error and should be addressed by fix files or better yet by the modelers. I'll have a look at the non-contiguous bounds.

zklaus commented 4 years ago

For FGOALS-f3-L the latitude bounds are a bit odd. Here an excerpt:

       [ -3.9,  -3.1],
       [ -2.9,  -2.1],
       [ -1.9,  -1.1],
       [ -0.9,  -0.1],
       [  0.1,   0.9],
       [  1.1,   1.9],
       [  2.1,   2.9],

In other words they claim a gap of ~.2 degrees between latitude bands. I think this is also a data error.

Hence, I suggest to close this issue in favor of data error issues.

jhardenberg commented 4 years ago

The recently merged PR #166 (guesses missing bounds automatically) solves this issue for most models which I listed, except for FGOALS-f3-L, which indeed does have bounds, but wrong ones. I prepared a working fix

mattiarighi commented 4 years ago

@jhardenberg can you please open a PR with this fix?

zklaus commented 4 years ago

Note to self: convert Jost's branch to PR.