Commit 8745886b authored by Thibault Hallouin's avatar Thibault Hallouin
Browse files

deal with 0 divide in skill scores to return -INF

in particular, BSS was returning 0 when BS reference was null, but 0 is
a meaningful value for such score, so it is preferable to return -INF
to indicate that the denominator was null and hence the division
undefined

the same philosophy is also used where relevant (i.e. in AWN, AWI, WSS)
1 merge request!3release v0.1.0
Pipeline #44109 failed with stage
in 3 minutes and 25 seconds
Showing with 14 additions and 4 deletions
+14 -4
......@@ -5,6 +5,8 @@
#ifndef EVALHYD_PROBABILIST_BRIER_HPP
#define EVALHYD_PROBABILIST_BRIER_HPP
#include <limits>
#include <xtensor/xtensor.hpp>
#include <xtensor/xview.hpp>
#include <xtensor/xmasked_view.hpp>
......@@ -790,7 +792,7 @@ namespace evalhyd
xt::nanmean(
xt::where(
xt::equal(bs_ref, 0),
0,
- std::numeric_limits<double>::infinity(),
1 - (bs_masked_sampled / bs_ref)
),
-1
......
......@@ -5,6 +5,8 @@
#ifndef EVALHYD_PROBABILIST_INTERVALS_HPP
#define EVALHYD_PROBABILIST_INTERVALS_HPP
#include <limits>
#include <xtensor/xtensor.hpp>
#include <xtensor/xview.hpp>
#include <xtensor/xindex_view.hpp>
......@@ -470,7 +472,9 @@ namespace evalhyd
}
}
return (AW / mean_obs);
return xt::where(mean_obs > 0,
AW / mean_obs,
- std::numeric_limits<double>::infinity());
}
/// Compute the Average Width Index (AWI).
......@@ -496,7 +500,9 @@ namespace evalhyd
- xt::view(clim_bnds, xt::all(), xt::all(), xt::all(),
xt::all(), xt::all(), 0);
return 1 - (AW / AW_clim);
return xt::where(AW_clim > 0,
1 - (AW / AW_clim),
- std::numeric_limits<double>::infinity());
}
/// Compute the Winkler scores (WS), also known as interval score.
......@@ -623,7 +629,9 @@ namespace evalhyd
}
// compute the Winkler skill score
return 1 - (WS / WS_clim);
return xt::where(WS_clim > 0,
1 - (WS / WS_clim),
- std::numeric_limits<double>::infinity());
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment