Skip to content

Commit

Permalink
Fix bug where status was not updated in a triple collocation validati… (
Browse files Browse the repository at this point in the history
#301)

* Fix bug where status was not updated in a triple collocation validation run

* Update changelog
  • Loading branch information
wpreimes authored Sep 7, 2023
1 parent 2d95e45 commit ddac1a8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit ddac1a8

Please sign in to comment.