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

FX files - ocean bgc domain don't exist #122

Closed ledm closed 5 years ago

ledm commented 5 years ago

Hi,

just found a bug where esmvaltool is unable to find the fx_files for ocean biogeochemistry because they don't exist. There's no need for the biogeochemistry to have their own fx files, as they are identical to the ocean physics fx files. However, the data finder doesn't know this and looks for ocnBgchem files anyway.

The solution is to add two lines to esmvalcore/_data_finder.py in the function: get_input_fx_filelist

def get_input_fx_filelist(variable, rootpath, drs):
    """Return a dict with the full path to fx input files."""
    fx_files = {}
    for fx_var in variable['fx_files']:
        var = dict(variable)
        var['mip'] = replace_mip_fx(fx_var)
        table = CMOR_TABLES[var['cmor_table']].get_table(var['mip'])
        var['frequency'] = table.frequency
        realm = getattr(table.get(var['short_name']), 'modeling_realm', None)
        var['modeling_realm'] = realm if realm else table.realm

        # Ocean Biogeochemistry does not have dedicated fx files:
        if var['modeling_realm'] == ['ocnBgchem', ]:
            var['modeling_realm'] = ['ocean', ]

        files = _find_input_files(var, rootpath, drs, fx_var)
        fx_files[fx_var] = files[0] if files else None
    return fx_files

The new lines are:

        # Ocean Biogeochemistry does not have dedicated fx files:
        if var['modeling_realm'] == ['ocnBgchem', ]:
            var['modeling_realm'] = ['ocean', ]

Instead of making a full PR for this, I was thinking that @valeriupredoi could add this to one of his PR's on FX files.

valeriupredoi commented 5 years ago

obsolete since #170