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

Fixed usage of statistics=std_dev option in multi-model statistics preprocessors #1478

Merged
merged 3 commits into from
Feb 7, 2022
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
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@
'numpy': ('https://numpy.org/doc/stable/', None),
'pyesgf': ('https://esgf-pyclient.readthedocs.io/en/latest/', None),
'python': ('https://docs.python.org/3/', None),
'scipy': ('https://docs.scipy.org/doc/scipy/reference/', None),
'scipy': ('https://scipy.github.io/devdocs/', None),
}

# -- Custom Document processing ----------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion doc/recipe/preprocessor.rst
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,7 @@ observational data, these biases have a significantly lower statistical impact
when using a multi-model ensemble. ESMValTool has the capability of computing a
number of multi-model statistical measures: using the preprocessor module
``multi_model_statistics`` will enable the user to ask for either a multi-model
``mean``, ``median``, ``max``, ``min``, ``std``, and / or ``pXX.YY`` with a set
``mean``, ``median``, ``max``, ``min``, ``std_dev``, and / or ``pXX.YY`` with a set
of argument parameters passed to ``multi_model_statistics``. Percentiles can be
specified like ``p1.5`` or ``p95``. The decimal point will be replaced by a dash
in the output file.
Expand Down
3 changes: 2 additions & 1 deletion esmvalcore/_recipe_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from ._data_finder import get_start_end_year
from .exceptions import InputFilesNotFound, RecipeError
from .preprocessor import TIME_PREPROCESSORS, PreprocessingTask
from .preprocessor._multimodel import STATISTIC_MAPPING

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -221,7 +222,7 @@ def extract_shape(settings):

def _verify_statistics(statistics, step):
"""Raise error if multi-model statistics cannot be verified."""
valid_names = ["mean", "median", "std", "min", "max"]
valid_names = ['std'] + list(STATISTIC_MAPPING.keys())
valid_patterns = [r"^(p\d{1,2})(\.\d*)?$"]

for statistic in statistics:
Expand Down
20 changes: 6 additions & 14 deletions tests/integration/test_recipe_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,15 +282,11 @@ def test_invalid_multi_model_settings():


def test_invalid_multi_model_statistics():
with pytest.raises(RecipeError) as rec_err:
msg = (r"Invalid value encountered for `statistic` in preprocessor "
r"multi_model_statistics. Valid values are .* Got 'wrong'.")
with pytest.raises(RecipeError, match=msg):
check._verify_statistics(
INVALID_MM_SETTINGS['statistics'], 'multi_model_statistics')
assert str(rec_err.value) == (
"Invalid value encountered for `statistic` in preprocessor "
"multi_model_statistics. Valid values are "
"['mean', 'median', 'std', 'min', 'max'] "
"or patterns matching ['^(p\\\\d{1,2})(\\\\.\\\\d*)?$']. "
"Got 'wrong'.")


def test_invalid_multi_model_span():
Expand Down Expand Up @@ -323,11 +319,7 @@ def test_invalid_multi_model_keep_input():


def test_invalid_ensemble_statistics():
with pytest.raises(RecipeError) as rec_err:
msg = (r"Invalid value encountered for `statistic` in preprocessor "
r"ensemble_statistics. Valid values are .* Got 'wrong'.")
with pytest.raises(RecipeError, match=msg):
check._verify_statistics(['wrong'], 'ensemble_statistics')
assert str(rec_err.value) == (
"Invalid value encountered for `statistic` in preprocessor "
"ensemble_statistics. Valid values are "
"['mean', 'median', 'std', 'min', 'max'] "
"or patterns matching ['^(p\\\\d{1,2})(\\\\.\\\\d*)?$']. "
"Got 'wrong'.")