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

Fix bug where status was not updated in a triple collocation validati… #301

Merged
merged 2 commits into from Sep 7, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.rst
Expand Up @@ -4,7 +4,8 @@ Changelog

Unreleased changes in master
============================
- Adapters for metric calculatores were introduced. The here implemented adapters compute metrics based on temporal subsets of the time series, which can be used for rolling window metrics, seasonal metrics or multiple arbitrary sub-periods. (PR `#266 <https://github.com/TUW-GEO/pytesmo/pull/266>`_),
- Adapters for metric calculatores were introduced. The here implemented adapters compute metrics based on temporal subsets of the time series, which can be used for rolling window metrics, seasonal metrics or multiple arbitrary sub-periods. (PR `#266 <https://github.com/TUW-GEO/pytesmo/pull/266>`_)
- Fixed a bug where the status code of a successful Triple Collocation run was still set to -1 ("unknown error"). (PR `#266 <https://github.com/TUW-GEO/pytesmo/pull/301>`_)

Version 0.15.2, 2023-06-14
==========================
Expand Down
12 changes: 8 additions & 4 deletions src/pytesmo/validation_framework/metric_calculators.py
Expand Up @@ -1774,10 +1774,14 @@ def calc_metrics(self, data, gpi_info):
ds_names = (self.refname, *othernames)
arrays = (data[name].values for name in ds_names)
if not self.bootstrap_cis:
res = tcol_metrics(*arrays)
for i, name in enumerate(ds_names):
for j, metric in enumerate(["snr", "err_std", "beta"]):
result[(metric, name)][0] = res[j][i]
try:
res = tcol_metrics(*arrays)
for i, name in enumerate(ds_names):
for j, metric in enumerate(["snr", "err_std", "beta"]):
result[(metric, name)][0] = res[j][i]
result["status"][0] = eh.OK
except ValueError:
result["status"] = eh.METRICS_CALCULATION_FAILED
else:
try:
# handle failing bootstrapping because e.g.
Expand Down
1 change: 1 addition & 0 deletions tests/test_validation_framework/test_validation.py
Expand Up @@ -157,6 +157,7 @@ def check_results(
with nc.Dataset(filename, mode="r") as results:
vars = results.variables.keys()
assert sorted(vars) == sorted(vars_should)
assert np.all(results['status'][:] != -1)

for varname, should_values in target_vars.items():
values = results.variables[varname][:]
Expand Down