diff --git a/doc/quickstart/configure.rst b/doc/quickstart/configure.rst index 4caf7e794b..f3d1793b92 100644 --- a/doc/quickstart/configure.rst +++ b/doc/quickstart/configure.rst @@ -683,7 +683,8 @@ related to CMOR table settings available: extended with variables from the :ref:`custom_cmor_tables` (by default loaded from the ``esmvalcore/cmor/tables/custom`` directory) and it is possible to use variables with a ``mip`` which is different from the MIP table in which - they are defined. + they are defined. Note that this option is always enabled for + :ref:`derived ` variables. * ``cmor_path``: path to the CMOR table. Relative paths are with respect to `esmvalcore/cmor/tables`_. Defaults to the value provided in ``cmor_type`` written in lower case. diff --git a/doc/recipe/preprocessor.rst b/doc/recipe/preprocessor.rst index 7ad4bdbcec..fdac9ec7da 100644 --- a/doc/recipe/preprocessor.rst +++ b/doc/recipe/preprocessor.rst @@ -201,13 +201,15 @@ the ozone 3D field. In this case, a derivation function is provided to vertically integrate the ozone and obtain total column ozone for direct comparison with the observations. -To contribute a new derived variable, it is also necessary to define a name for -it and to provide the corresponding CMOR table. This is to guarantee the proper -metadata definition is attached to the derived data. Such custom CMOR tables -are collected as part of the `ESMValCore package -`_. By default, the variable -derivation will be applied only if the variable is not already available in the -input data, but the derivation can be forced by setting the appropriate flag. +The tool will also look in other ``mip`` tables for the same ``project`` to find +the definition of derived variables. To contribute a completely new derived +variable, it is necessary to define a name for it and to provide the +corresponding CMOR table. This is to guarantee the proper metadata definition +is attached to the derived data. Such custom CMOR tables are collected as part +of the `ESMValCore package `_. +By default, the variable derivation will be applied only if the variable is not +already available in the input data, but the derivation can be forced by +setting the ``force_derivation`` flag. .. code-block:: yaml diff --git a/esmvalcore/cmor/table.py b/esmvalcore/cmor/table.py index ebce5431ae..3ee00696f4 100644 --- a/esmvalcore/cmor/table.py +++ b/esmvalcore/cmor/table.py @@ -296,8 +296,8 @@ def get_variable( pass # If that didn't work, look in all tables (i.e., other MIPs) if - # cmor_strict=False - var_info = self._look_in_all_tables(alt_names_list) + # cmor_strict=False or derived=True + var_info = self._look_in_all_tables(derived, alt_names_list) # If that didn' work either, look in default table if cmor_strict=False # or derived=True @@ -324,10 +324,10 @@ def _look_in_default(self, derived, alt_names_list, table_name): break return var_info - def _look_in_all_tables(self, alt_names_list): + def _look_in_all_tables(self, derived, alt_names_list): """Look for variable in all tables.""" var_info = None - if not self.strict: + if (not self.strict or derived): for alt_names in alt_names_list: var_info = self._look_all_tables(alt_names) if var_info: diff --git a/tests/integration/cmor/test_table.py b/tests/integration/cmor/test_table.py index 8b8d63e57c..793d0249e5 100644 --- a/tests/integration/cmor/test_table.py +++ b/tests/integration/cmor/test_table.py @@ -105,6 +105,11 @@ def test_get_variable_from_alt_names(self): var = self.variables_info.get_variable('SImon', 'sic') self.assertEqual(var.short_name, 'siconc') + def test_get_variable_derived(self): + """Test that derived variable are looked up from other MIP tables.""" + var = self.variables_info.get_variable('3hr', 'sfcWind', derived=True) + self.assertEqual(var.short_name, 'sfcWind') + def test_get_variable_from_custom(self): """Get a variable from default.""" self.variables_info.strict = False