Skip to content

Commit 69e2187

Browse files
authored
Add use_standard_grid option for CORDEX datasets (#3059)
1 parent ddd67d7 commit 69e2187

7 files changed

Lines changed: 629 additions & 78 deletions

File tree

doc/recipe/overview.rst

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ For example, a datasets section could be:
109109
- {dataset: CanESM2, project: CMIP5, exp: historical, ensemble: r1i1p1, start_year: 2001, end_year: 2004}
110110
- {dataset: UKESM1-0-LL, project: CMIP6, exp: historical, ensemble: r1i1p1f2, start_year: 2001, end_year: 2004, grid: gn}
111111
- {dataset: ACCESS-CM2, project: CMIP6, exp: historical, ensemble: r1i1p1f2, timerange: 'P5Y/*', grid: gn}
112+
- {dataset: CCLM4-8-17, project: CORDEX, domain: EUR-11, driver: CNRM-CERFACS-CNRM-CM5, exp: historical, ensemble: r1i1p1, institute: CLMcom, rcm_version: v1, timerange: '2001/2004'}
112113
- {dataset: EC-EARTH3, alias: custom_alias, project: CMIP6, exp: historical, ensemble: r1i1p1f1, start_year: 2001, end_year: 2004, grid: gn}
113114
- {dataset: CMCC-CM2-SR5, project: CMIP6, exp: historical, ensemble: r1i1p1f1, timerange: '2001/P10Y', grid: gn}
114115
- {dataset: HadGEM3-GC31-MM, project: CMIP6, exp: dcppA-hindcast, ensemble: r1i1p1f1, sub_experiment: s2000, grid: gn, start_year: 2000, end_year, 2002}
@@ -378,6 +379,89 @@ When using the ``timerange`` tag to specify the start and end points, possible v
378379
Note that this section is not required, as datasets can also be provided in the
379380
Diagnostics_ section.
380381

382+
CORDEX datasets
383+
---------------
384+
385+
The horizontal coordinates of CORDEX data are often not accurate. Therefore,
386+
the tool provides the option to specify that the standard CORDEX grid for the
387+
domain should be used instead of the grid defined in the files. This can be
388+
enabled by adding ``use_standard_grid: true`` and disabled by adding
389+
``use_standard_grid: false`` to the dataset definition of the CORDEX data.
390+
391+
For example:
392+
393+
.. code-block:: yaml
394+
395+
datasets:
396+
- dataset: CCLM4-8-17
397+
rcm_version: v1
398+
driver: CNRM-CERFACS-CNRM-CM5
399+
institute: CLMcom
400+
project: CORDEX
401+
domain: EUR-11
402+
exp: historical
403+
ensemble: r1i1p1
404+
use_standard_grid: true
405+
406+
will use the standard CORDEX grid for the EUR-11 domain, as defined by the
407+
`py-cordex <https://py-cordex.readthedocs.io>`_ package for datasets on a
408+
rotated pole grid. For datasets on a Lambert conformal grid, ESMValCore provides
409+
an algorithm to calculate the standard grid, but this only works if the
410+
`grid mapping <https://cfconventions.org/Data/cf-conventions/cf-conventions-1.13/cf-conventions.html#grid-mappings-and-projections>`_
411+
is correct.
412+
413+
This feature is disabled by default, but enabled by default for models with
414+
known issues through the default
415+
`CORDEX extra facets file <https://github.com/ESMValGroup/ESMValCore/blob/main/esmvalcore/config/configurations/defaults/extra_facets_cordex.yml>`__.
416+
417+
.. warning::
418+
419+
If ``use_standard_grid: true`` is used, the tool will overwrite the existing grid
420+
information. It is recommended to visualize the resulting data and compare it
421+
to easily recognizable features (e.g. coastlines) to make sure the grid is
422+
correct before using it in an aggregated manner.
423+
424+
Example Python script to visualize the grid of a CORDEX dataset and compare it
425+
to coastlines:
426+
427+
.. code-block:: python
428+
429+
from esmvalcore.dataset import Dataset
430+
import iris.quickplot
431+
import matplotlib.pyplot as plt
432+
433+
ds = Dataset(
434+
short_name="sftlf",
435+
mip="fx",
436+
project="CORDEX",
437+
domain="EUR-11",
438+
dataset="ALADIN63",
439+
driver="CNRM-CERFACS-CNRM-CM5",
440+
institute="CNRM",
441+
exp="historical",
442+
ensemble="r1i1p1",
443+
rcm_version="v2",
444+
use_standard_grid=True,
445+
)
446+
cube = ds.load()
447+
448+
plt.figure()
449+
iris.quickplot.pcolormesh(
450+
cube,
451+
coords=["projection_x_coordinate", "projection_y_coordinate"],
452+
)
453+
plt.gca().coastlines()
454+
455+
plt.figure()
456+
iris.quickplot.pcolormesh(
457+
cube,
458+
coords=["longitude", "latitude"],
459+
)
460+
plt.gca().coastlines()
461+
462+
plt.show()
463+
464+
381465
.. _`yaml`: https://yaml.org/refcard.html
382466

383467
.. _Preprocessors:
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
"""Fixes for rcm ALADIN53 driven by CNRM-CERFACS-CNRM-CM5."""
2+
3+
from __future__ import annotations
4+
5+
from typing import TYPE_CHECKING
6+
7+
from esmvalcore.cmor.fix import Fix
8+
9+
if TYPE_CHECKING:
10+
from collections.abc import Sequence
11+
12+
from iris.cube import Cube
13+
14+
15+
class Sftlf(Fix):
16+
"""Fixes for sftlf."""
17+
18+
def fix_metadata(self, cubes: Sequence[Cube]) -> Sequence[Cube]:
19+
for cube in cubes:
20+
cube.units = "1"
21+
cube.convert_units(self.vardef.units)
22+
return cubes
23+
24+
25+
class Ts(Fix):
26+
"""Fixes for ts."""
27+
28+
def fix_metadata(self, cubes: Sequence[Cube]) -> Sequence[Cube]:
29+
for cube in cubes:
30+
cube.units = "deg_C"
31+
cube.convert_units(self.vardef.units)
32+
return cubes

0 commit comments

Comments
 (0)