From f04c2e1931f3f5ed27310fac4e29686cab46517c Mon Sep 17 00:00:00 2001 From: Lee de Mora Date: Tue, 14 Jan 2020 11:30:20 +0000 Subject: [PATCH 1/7] Addex mip6 Ofx Omon fix --- esmvalcore/_recipe.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/esmvalcore/_recipe.py b/esmvalcore/_recipe.py index 02c3781279..f010bedc3b 100644 --- a/esmvalcore/_recipe.py +++ b/esmvalcore/_recipe.py @@ -401,6 +401,15 @@ def _get_correct_fx_file(variable, fx_varname, config_user): elif fx_varname == 'sftgif': fx_var = _add_fxvar_keys({'short_name': fx_varname, 'mip': 'fx'}, var) + elif fx_varname == 'volcello': + if var['dataset'] in ['UKESM1-0-LL', 'GFDL-CM4', 'HadGEM3-GC31-LL', ]: + fx_var = _add_fxvar_keys({'short_name': fx_varname, 'mip': var['mip']}, + var) + else: + fx_var = _add_fxvar_keys({'short_name': fx_varname, 'mip': 'Ofx'}, + var) + + print(fx_var, var['dataset'], var['mip']) else: raise RecipeError( f"Project {var['project']} not supported with fx variables") @@ -409,7 +418,6 @@ def _get_correct_fx_file(variable, fx_varname, config_user): # allow for empty lists corrected for by NE masks if fx_files: fx_files = fx_files[0] - return fx_files From 47a2d51eef669040ce09c22602e47d1426cf8ef6 Mon Sep 17 00:00:00 2001 From: Lee de Mora Date: Tue, 14 Jan 2020 11:52:38 +0000 Subject: [PATCH 2/7] minor cosmetic change --- esmvalcore/_recipe.py | 1 + 1 file changed, 1 insertion(+) diff --git a/esmvalcore/_recipe.py b/esmvalcore/_recipe.py index f010bedc3b..fe59cb378f 100644 --- a/esmvalcore/_recipe.py +++ b/esmvalcore/_recipe.py @@ -418,6 +418,7 @@ def _get_correct_fx_file(variable, fx_varname, config_user): # allow for empty lists corrected for by NE masks if fx_files: fx_files = fx_files[0] + return fx_files From 01709c917294a02d0c4dd3d2cd24d85b80b30821 Mon Sep 17 00:00:00 2001 From: Lee de Mora Date: Tue, 14 Jan 2020 12:00:00 +0000 Subject: [PATCH 3/7] Who put that print statement in there? Get rid of it. --- esmvalcore/_recipe.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/esmvalcore/_recipe.py b/esmvalcore/_recipe.py index fe59cb378f..39af097de4 100644 --- a/esmvalcore/_recipe.py +++ b/esmvalcore/_recipe.py @@ -405,11 +405,9 @@ def _get_correct_fx_file(variable, fx_varname, config_user): if var['dataset'] in ['UKESM1-0-LL', 'GFDL-CM4', 'HadGEM3-GC31-LL', ]: fx_var = _add_fxvar_keys({'short_name': fx_varname, 'mip': var['mip']}, var) - else: + else: fx_var = _add_fxvar_keys({'short_name': fx_varname, 'mip': 'Ofx'}, var) - - print(fx_var, var['dataset'], var['mip']) else: raise RecipeError( f"Project {var['project']} not supported with fx variables") From 6e2736cce11fc678a9a1de7ae1b1288a8fbe59f1 Mon Sep 17 00:00:00 2001 From: Lee de Mora Date: Tue, 14 Jan 2020 12:10:47 +0000 Subject: [PATCH 4/7] Implemented @valeriupredoi suggestion in https://github.com/ESMValGroup/ESMValCore/issues/405#issuecomment-574144142 --- esmvalcore/_recipe.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/esmvalcore/_recipe.py b/esmvalcore/_recipe.py index 39af097de4..7f4a5fb431 100644 --- a/esmvalcore/_recipe.py +++ b/esmvalcore/_recipe.py @@ -401,18 +401,24 @@ def _get_correct_fx_file(variable, fx_varname, config_user): elif fx_varname == 'sftgif': fx_var = _add_fxvar_keys({'short_name': fx_varname, 'mip': 'fx'}, var) - elif fx_varname == 'volcello': - if var['dataset'] in ['UKESM1-0-LL', 'GFDL-CM4', 'HadGEM3-GC31-LL', ]: - fx_var = _add_fxvar_keys({'short_name': fx_varname, 'mip': var['mip']}, - var) - else: - fx_var = _add_fxvar_keys({'short_name': fx_varname, 'mip': 'Ofx'}, - var) + # elif fx_varname == 'volcello': + # if var['dataset'] in ['UKESM1-0-LL', 'GFDL-CM4', 'HadGEM3-GC31-LL', ]: + # fx_var = _add_fxvar_keys({'short_name': fx_varname, 'mip': var['mip']}, + # var) + # else: + # fx_var = _add_fxvar_keys({'short_name': fx_varname, 'mip': 'Ofx'}, + # var) else: raise RecipeError( f"Project {var['project']} not supported with fx variables") fx_files = _get_input_files(fx_var, config_user) + + # If can't find Ofx files, then try with original variable mip + if not fx_files and fx_var['mip'] == 'Ofx': + fx_var['mip'] = var['mip'] + fx_files = _get_input_files(fx_var, config_user) + # allow for empty lists corrected for by NE masks if fx_files: fx_files = fx_files[0] From ea869074250be9bc36ead0c1ff64a8ef10d22192 Mon Sep 17 00:00:00 2001 From: Lee de Mora Date: Tue, 14 Jan 2020 12:21:30 +0000 Subject: [PATCH 5/7] bug fix --- esmvalcore/_recipe.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/esmvalcore/_recipe.py b/esmvalcore/_recipe.py index 7f4a5fb431..f61a852002 100644 --- a/esmvalcore/_recipe.py +++ b/esmvalcore/_recipe.py @@ -401,6 +401,10 @@ def _get_correct_fx_file(variable, fx_varname, config_user): elif fx_varname == 'sftgif': fx_var = _add_fxvar_keys({'short_name': fx_varname, 'mip': 'fx'}, var) + elif fx_varname == 'volcello': + fx_var = _add_fxvar_keys({'short_name': fx_varname, 'mip': 'Ofx'}, + var) + # elif fx_varname == 'volcello': # if var['dataset'] in ['UKESM1-0-LL', 'GFDL-CM4', 'HadGEM3-GC31-LL', ]: # fx_var = _add_fxvar_keys({'short_name': fx_varname, 'mip': var['mip']}, From 9d11ce1ee1da694b119d4a8d8e1b857b54f654d1 Mon Sep 17 00:00:00 2001 From: Lee de Mora Date: Tue, 14 Jan 2020 15:47:31 +0000 Subject: [PATCH 6/7] PEP8 compliance --- esmvalcore/_recipe.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/esmvalcore/_recipe.py b/esmvalcore/_recipe.py index f61a852002..3fcd2d4330 100644 --- a/esmvalcore/_recipe.py +++ b/esmvalcore/_recipe.py @@ -403,15 +403,7 @@ def _get_correct_fx_file(variable, fx_varname, config_user): var) elif fx_varname == 'volcello': fx_var = _add_fxvar_keys({'short_name': fx_varname, 'mip': 'Ofx'}, - var) - - # elif fx_varname == 'volcello': - # if var['dataset'] in ['UKESM1-0-LL', 'GFDL-CM4', 'HadGEM3-GC31-LL', ]: - # fx_var = _add_fxvar_keys({'short_name': fx_varname, 'mip': var['mip']}, - # var) - # else: - # fx_var = _add_fxvar_keys({'short_name': fx_varname, 'mip': 'Ofx'}, - # var) + var) else: raise RecipeError( f"Project {var['project']} not supported with fx variables") From 3a8ad09b6223e73481e5950e3c40bdbfdb5a9d5d Mon Sep 17 00:00:00 2001 From: Lee de Mora Date: Tue, 14 Jan 2020 16:29:20 +0000 Subject: [PATCH 7/7] added warning message if fx files are not found. --- esmvalcore/_recipe.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/esmvalcore/_recipe.py b/esmvalcore/_recipe.py index 3fcd2d4330..9857b33a0d 100644 --- a/esmvalcore/_recipe.py +++ b/esmvalcore/_recipe.py @@ -415,6 +415,9 @@ def _get_correct_fx_file(variable, fx_varname, config_user): fx_var['mip'] = var['mip'] fx_files = _get_input_files(fx_var, config_user) + if not fx_files: + logger.warning("Unable to locate Fx files in Ofx or %s", var['mip']) + # allow for empty lists corrected for by NE masks if fx_files: fx_files = fx_files[0]