To automatically add supplementary variables to a dataset, we need the following information:
- Which facets are required for the data source(s) configured for the project?
- Which facets should be inherited from the main variable?
These facets are then used in the following way:
|
supplementary_facets: Facets = { |
|
facet: "*" |
|
for facet in FACETS.get(project, ["mip"]) |
|
if facet not in _CMOR_KEYS + tuple(INHERITED_FACETS) |
|
} |
|
for key in ("frequency", "version"): |
|
# Do not inherit these facets as they tend to differ from the |
|
# main variable. |
|
if key in facets: |
|
supplementary_facets[key] = "*" |
to figure out which facets and values to use to search for supplementary datasets. The
_CMOR_FACETS in that code are the facets that are automatically added based on the variable definition in the CMOR table and
- the facets used by the data source are currently defined in
esmvalcore.io.esgf.facets.FACETS
- the facets inherited from the main variable are currently defined in
esmvalcore.dataset.INHERITED_FACETS
To make 1) configurable, we could add a facets attribute to all data sources, similar to the one already available on the IntakeESGFDatasource at
. For
esmvalcore.io.local.LocalDataSource this could be automatically added from the file and directory name templates and for
esmvalcore.io.esgf.ESGFDataSource it could be moved from
esmvalcore.io.esgf.facets.FACETS to the configuration files. We could then use this, in combination with the list of inherited facets, to determine which facets from the main variable we need to replace with a
* value.
To make 2) configurable, we could add an option called e.g. facets_inherited_by_supplementary_variables to the project configuration under projects, possibly with a default of ["project", "dataset"].
To automatically add supplementary variables to a dataset, we need the following information:
These facets are then used in the following way:
ESMValCore/esmvalcore/_recipe/to_datasets.py
Lines 253 to 262 in 51b8c0d
to figure out which facets and values to use to search for supplementary datasets. The
_CMOR_FACETSin that code are the facets that are automatically added based on the variable definition in the CMOR table andesmvalcore.io.esgf.facets.FACETSesmvalcore.dataset.INHERITED_FACETSTo make 1) configurable, we could add a
facetsattribute to all data sources, similar to the one already available on theIntakeESGFDatasourceatESMValCore/esmvalcore/io/intake_esgf.py
Line 204 in 51b8c0d
esmvalcore.io.local.LocalDataSourcethis could be automatically added from the file and directory name templates and foresmvalcore.io.esgf.ESGFDataSourceit could be moved fromesmvalcore.io.esgf.facets.FACETSto the configuration files. We could then use this, in combination with the list of inherited facets, to determine which facets from the main variable we need to replace with a*value.To make 2) configurable, we could add an option called e.g.
facets_inherited_by_supplementary_variablesto the project configuration underprojects, possibly with a default of["project", "dataset"].