diff --git a/include/evalhyd/detail/probabilist/evaluator.hpp b/include/evalhyd/detail/probabilist/evaluator.hpp index 8a4785cc19c71e2a769dc98ea942cf6fab1340a5..b4981c6a4f3b2aa225463353c7cb0e58e72c7ab4 100644 --- a/include/evalhyd/detail/probabilist/evaluator.hpp +++ b/include/evalhyd/detail/probabilist/evaluator.hpp @@ -91,7 +91,7 @@ namespace evalhyd xtl::xoptional<xt::xtensor<double, 6>, bool> CSI; xtl::xoptional<xt::xtensor<double, 5>, bool> ROCSS; // > Ranks-based - xtl::xoptional<xt::xtensor<double, 6>, bool> REL_DIAG; + xtl::xoptional<xt::xtensor<double, 6>, bool> RANK_DIAG; xtl::xoptional<xt::xtensor<double, 4>, bool> DS; xtl::xoptional<xt::xtensor<double, 4>, bool> AS; @@ -543,16 +543,16 @@ namespace evalhyd return ROCSS.value(); }; - xt::xtensor<double, 6> get_REL_DIAG() + xt::xtensor<double, 6> get_RANK_DIAG() { - if (!REL_DIAG.has_value()) + if (!RANK_DIAG.has_value()) { - REL_DIAG = metrics::calc_REL_DIAG( + RANK_DIAG = metrics::calc_RANK_DIAG( get_o_j(), t_msk, b_exp, n_sit, n_ldt, n_mbr, n_msk, n_exp ); } - return REL_DIAG.value(); + return RANK_DIAG.value(); }; xt::xtensor<double, 4> get_DS() diff --git a/include/evalhyd/detail/probabilist/ranks.hpp b/include/evalhyd/detail/probabilist/ranks.hpp index e21028521c7911305a2bd5f34f4012de86cfc434..3df9d3970bedef05cba405e0e420e1d0f7490a67 100644 --- a/include/evalhyd/detail/probabilist/ranks.hpp +++ b/include/evalhyd/detail/probabilist/ranks.hpp @@ -184,8 +184,7 @@ namespace evalhyd namespace metrics { - /// Compute the reliability diagram X and Y axes, the forecast - /// probability and the observed relative frequency, respectively. + /// Compute the rank diagram, also known as Talagrand diagram. /// /// \param o_j /// Tallies of streamflow observations for all possible ranks. @@ -207,9 +206,9 @@ namespace evalhyd /// \param n_exp /// Number of bootstrap samples. /// \return - /// X and Y axes of the reliability diagram. - /// shape: (sites, lead times, subsets, samples, ranks, axes) - inline xt::xtensor<double, 6> calc_REL_DIAG( + /// Rank diagram. + /// shape: (sites, lead times, subsets, samples, ranks) + inline xt::xtensor<double, 6> calc_RANK_DIAG( const xt::xtensor<double, 5>& o_j, const xt::xtensor<bool, 4>& t_msk, const std::vector<xt::xkeep_slice<int>>& b_exp, @@ -239,16 +238,9 @@ namespace evalhyd // calculate length of subset auto l = xt::sum(t_msk_sampled, -1); - // compute the forecast probability $y_i$ - // [X-axis] - xt::view(REL_DIAG, xt::all(), xt::all(), m, e, xt::all(), 0) = - xt::arange<double>(double(n_mbr + 1)) / n_mbr; - - // compute the observed relative frequency - // [Y-axis] - // $\bar{o_j} = \frac{1}{n} \sum_{k \in M_j} r_k$ - xt::view(REL_DIAG, xt::all(), xt::all(), m, e, xt::all(), 1) = - xt::cumsum( + // compute the rank diagram + xt::view(REL_DIAG, xt::all(), xt::all(), m, e, xt::all()) = + xt::sum( xt::view(o_j, xt::all(), xt::all(), m, e, xt::all()) / l, diff --git a/include/evalhyd/evalp.hpp b/include/evalhyd/evalp.hpp index 26b34330d700785be3dc6767d284ca170b972ecf..1686ed609b22ef57f289f7563a526d6adb1e048e 100644 --- a/include/evalhyd/evalp.hpp +++ b/include/evalhyd/evalp.hpp @@ -199,7 +199,7 @@ namespace evalhyd {"BS", "BSS", "BS_CRD", "BS_LBD", "QS", "CRPS", "POD", "POFD", "FAR", "CSI", "ROCSS", - "REL_DIAG", "DS", "AS"} + "RANK_DIAG", "DS", "AS"} ); // check optional parameters @@ -437,10 +437,10 @@ namespace evalhyd uncertainty::summarise(evaluator.get_ROCSS(), summary) ); } - else if ( metric == "REL_DIAG" ) + else if ( metric == "RANK_DIAG" ) { r.emplace_back( - uncertainty::summarise(evaluator.get_REL_DIAG(), summary) + uncertainty::summarise(evaluator.get_RANK_DIAG(), summary) ); } else if ( metric == "DS" )