Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion esmvalcore/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,10 @@ def configure_logging(cfg_file=None, output=None, console_log_level=None):
def get_project_config(project):
"""Get developer-configuration for project."""
logger.debug("Retrieving %s configuration", project)
return CFG[project]
if project in CFG:
return CFG[project]
else:
raise ValueError(f"Project '{project}' not in config-developer.yml")


def get_institutes(variable):
Expand Down
53 changes: 36 additions & 17 deletions esmvalcore/_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,26 +386,45 @@ def _add_fxvar_keys(fx_var_dict, variable):


def _get_correct_fx_file(variable, fx_varname, config_user):
"""Wrapper to standard file getter to recover the correct fx file."""
"""Get fx files (searching all possible mips)."""
# TODO: allow user to specify certain mip if desired
var = dict(variable)
if var['project'] in ['CMIP5', 'OBS', 'OBS6', 'obs4mips']:
fx_var = _add_fxvar_keys({'short_name': fx_varname, 'mip': 'fx'}, var)
elif var['project'] == 'CMIP6':
if fx_varname == 'sftlf':
fx_var = _add_fxvar_keys({'short_name': fx_varname, 'mip': 'fx'},
var)
elif fx_varname == 'sftof':
fx_var = _add_fxvar_keys({'short_name': fx_varname, 'mip': 'Ofx'},
var)
# TODO allow availability for multiple mip's for sftgif
elif fx_varname == 'sftgif':
fx_var = _add_fxvar_keys({'short_name': fx_varname, 'mip': 'fx'},
var)
var_project = variable['project']
cmor_table = CMOR_TABLES[var_project]

# Get all fx-related mips ('fx' always first, original mip last)
fx_mips = ['fx']
fx_mips.extend(
[key for key in cmor_table.tables if 'fx' in key and key != 'fx'])
fx_mips.append(variable['mip'])

# Search all mips for available variables
searched_mips = []
for fx_mip in fx_mips:
fx_variable = cmor_table.get_variable(fx_mip, fx_varname)
if fx_variable is not None:
searched_mips.append(fx_mip)
fx_var = _add_fxvar_keys(
{'short_name': fx_varname, 'mip': fx_mip}, var)
logger.debug("For CMIP6 fx variable '%s', found table '%s'",
fx_varname, fx_mip)
fx_files = _get_input_files(fx_var, config_user)

# If files found, return them
if fx_files:
logger.debug("Found CMIP6 fx variables '%s':\n%s",
fx_varname, pformat(fx_files))
break
else:
# No files found
fx_files = []

# If fx variable was not found in any table, raise exception
if not searched_mips:
raise RecipeError(
f"Project {var['project']} not supported with fx variables")
f"Requested fx variable '{fx_varname}' not available in "
f"any 'fx'-related CMOR table ({fx_mips}) for '{var_project}'")

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]
Expand Down Expand Up @@ -726,7 +745,7 @@ def _get_single_preprocessor_task(variables,
order = _extract_preprocessor_order(profile)
ancestor_products = [p for task in ancestor_tasks for p in task.products]

if variables[0]['frequency'] == 'fx':
if variables[0].get('frequency') == 'fx':
check.check_for_temporal_preprocs(profile)
ancestor_products = None

Expand Down
Loading