Commit 54efcfea authored by Thibault Hallouin's avatar Thibault Hallouin
Browse files

add another unittest for new mean/median/quantile# masking conditions

there was none for the determinist side
No related merge requests found
Pipeline #39153 passed with stages
in 3 minutes and 12 seconds
Showing with 34 additions and 1 deletion
+34 -1
......@@ -217,7 +217,7 @@ TEST(DeterministTests, TestMaskingConditions)
// generate dummy empty masks required to access next optional argument
xt::xtensor<bool, 2> masks;
// conditions on streamflow ________________________________________________
// conditions on streamflow values _________________________________________
// compute scores using masking conditions on streamflow to subset whole record
xt::xtensor<std::array<char, 32>, 2> q_conditions ={
......@@ -248,6 +248,39 @@ TEST(DeterministTests, TestMaskingConditions)
) << "Failure for (" << metrics[m] << ")";
}
// conditions on streamflow statistics _____________________________________
// compute scores using masking conditions on streamflow to subset whole record
xt::xtensor<std::array<char, 32>, 2> q_conditions_ ={
{{"q_obs{>=mean}"}}
};
double mean = xt::mean(observed, {1})();
std::vector<xt::xarray<double>> metrics_q_conditioned_ =
evalhyd::evald<2>(
observed, predicted, metrics,
"none", 1, -9, masks, q_conditions_
);
// compute scores using "NaN-ed" time indices where conditions on streamflow met
std::vector<xt::xarray<double>> metrics_q_preconditioned_ =
evalhyd::evald<2>(
xt::where(observed >= mean, observed, NAN),
predicted,
metrics
);
// check results are identical
for (int m = 0; m < metrics.size(); m++)
{
EXPECT_TRUE(
xt::allclose(
metrics_q_conditioned[m], metrics_q_preconditioned[m]
)
) << "Failure for (" << metrics[m] << ")";
}
// conditions on temporal indices __________________________________________
// compute scores using masking conditions on time indices to subset whole record
......
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