Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve variable alias managament #595

Merged
merged 13 commits into from
Oct 2, 2020
10 changes: 10 additions & 0 deletions doc/recipe/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,16 @@ define the ``start_year`` and ``end_year`` items in the variable section,
because the diagnostic script assumes that all the data has the same time
range.

Variable short names usually do not change between datasets supported by
ESMValTool, as they are usually changed to match CMIP. Nevertheless, there are
bouweandela marked this conversation as resolved.
Show resolved Hide resolved
small changes in variable names in CMIP6 respect to CMIP5 (i.e. sea ice
jvegreg marked this conversation as resolved.
Show resolved Hide resolved
concentration changed from ``sic`` to ``siconc``). ESMValTool is aware of some
bouweandela marked this conversation as resolved.
Show resolved Hide resolved
of them and can do the automatic translation when needed. It will even do the
translation in the preprocessed file so the diagnostic does not have to default
bouweandela marked this conversation as resolved.
Show resolved Hide resolved
with this complexity. For example, if ``sic`` is requested, ESMValTool will
find ``sic`` or ``siconc`` depending on the project, but all preprocessed files
while use ``sic`` as their short_name.
bouweandela marked this conversation as resolved.
Show resolved Hide resolved

Diagnostic and variable specific datasets
-----------------------------------------
The ``additional_datasets`` option can be used to add datasets beyond those
Expand Down
4 changes: 3 additions & 1 deletion esmvalcore/_data_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,12 @@ def _get_filenames_glob(variable, drs):


def _find_input_files(variable, rootpath, drs):
short_name = variable['short_name']
variable['short_name'] = variable['original_short_name']
input_dirs = _find_input_dirs(variable, rootpath, drs)
filenames_glob = _get_filenames_glob(variable, drs)
files = find_files(input_dirs, filenames_glob)

variable['short_name'] = short_name
return (files, input_dirs, filenames_glob)


Expand Down
4 changes: 3 additions & 1 deletion esmvalcore/_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def _add_cmor_info(variable, override=False):
raise RecipeError(
f"Unable to load CMOR table (project) '{project}' for variable "
f"'{short_name}' with mip '{mip}'")

variable['original_short_name'] = table_entry.short_name
bouweandela marked this conversation as resolved.
Show resolved Hide resolved
for key in cmor_keys:
if key not in variable or override:
value = getattr(table_entry, key, None)
Expand Down Expand Up @@ -348,6 +348,8 @@ def _get_default_settings(variable, config_user, derive=False):

# Configure saving cubes to file
settings['save'] = {'compress': config_user['compress_netcdf']}
if variable['short_name'] != variable['original_short_name']:
settings['save']['alias'] = variable['short_name']
bouweandela marked this conversation as resolved.
Show resolved Hide resolved

return settings

Expand Down
Loading