Skip to content

Commit

Permalink
Add driver and sub_experiment tags to generate dataset aliases (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
sloosvel authored Jan 13, 2023
1 parent 155335a commit fe2e8cf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
4 changes: 2 additions & 2 deletions esmvalcore/_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -1253,8 +1253,8 @@ def _get_preprocessor_task(variables, profiles, config_user, task_name):
class Recipe:
"""Recipe object."""

info_keys = ('project', 'activity', 'dataset', 'exp', 'ensemble',
'version')
info_keys = ('project', 'activity', 'driver', 'dataset', 'exp',
'sub_experiment', 'ensemble', 'version')
"""List of keys to be used to compose the alias, ordered by priority."""

def __init__(self,
Expand Down
20 changes: 18 additions & 2 deletions tests/integration/test_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -1769,7 +1769,7 @@ def test_alias_generation(tmp_path, patched_datafinder, config_user):
diagnostics:
diagnostic_name:
variables:
ta:
pr:
project: CMIP5
mip: Amon
exp: historical
Expand All @@ -1779,28 +1779,39 @@ def test_alias_generation(tmp_path, patched_datafinder, config_user):
type: reanaly
tier: 2
version: latest
domain: EUR-11
rcm_version: 1
additional_datasets:
- {dataset: GFDL-CM3, ensemble: r1i1p1}
- {dataset: EC-EARTH, ensemble: r1i1p1}
- {dataset: EC-EARTH, ensemble: r2i1p1}
- {dataset: EC-EARTH, ensemble: r3i1p1, alias: my_alias}
- {dataset: FGOALS-g3, sub_experiment: s1960, ensemble: r1}
- {dataset: FGOALS-g3, sub_experiment: s1961, ensemble: r1}
- {project: OBS, dataset: ERA-Interim, version: 1}
- {project: OBS, dataset: ERA-Interim, version: 2}
- {project: CMIP6, activity: CMP, dataset: GF3, ensemble: r1}
- {project: CMIP6, activity: CMP, dataset: GF2, ensemble: r1}
- {project: CMIP6, activity: HRMP, dataset: EC, ensemble: r1}
- {project: CMIP6, activity: HRMP, dataset: HA, ensemble: r1}
- {project: CORDEX, driver: ICHEC-EC-EARTH, dataset: SMHI-RCA4, ensemble: r1, mip: mon}
- {project: CORDEX, driver: MIROC-MIROC5, dataset: SMHI-RCA4, ensemble: r1, mip: mon}
scripts: null
""") # noqa:

recipe = get_recipe(tmp_path, content, config_user)
assert len(recipe.diagnostics) == 1
diag = recipe.diagnostics['diagnostic_name']
var = diag['preprocessor_output']['ta']
var = diag['preprocessor_output']['pr']
for dataset in var:
if dataset['project'] == 'CMIP5':
if dataset['dataset'] == 'GFDL-CM3':
assert dataset['alias'] == 'CMIP5_GFDL-CM3'
elif dataset['dataset'] == 'FGOALS-g3':
if dataset['sub_experiment'] == 's1960':
assert dataset['alias'] == 'CMIP5_FGOALS-g3_s1960'
else:
assert dataset['alias'] == 'CMIP5_FGOALS-g3_s1961'
else:
if dataset['ensemble'] == 'r1i1p1':
assert dataset['alias'] == 'CMIP5_EC-EARTH_r1i1p1'
Expand All @@ -1817,6 +1828,11 @@ def test_alias_generation(tmp_path, patched_datafinder, config_user):
assert dataset['alias'] == 'CMIP6_HRMP_EC'
else:
assert dataset['alias'] == 'CMIP6_HRMP_HA'
elif dataset['project'] == 'CORDEX':
if dataset['driver'] == 'ICHEC-EC-EARTH':
assert dataset['alias'] == 'CORDEX_ICHEC-EC-EARTH'
else:
assert dataset['alias'] == 'CORDEX_MIROC-MIROC5'
else:
if dataset['version'] == 1:
assert dataset['alias'] == 'OBS_1'
Expand Down

0 comments on commit fe2e8cf

Please sign in to comment.