Commit 0ca9b41a authored by Thibault Hallouin's avatar Thibault Hallouin
Browse files

catch empty observations after NaN filtering

when observations only contain NaNs, the resulting data subset is
empty, which makes the quantile calculation fail

this can happen when evalhyd is used on a period with no observations
(which may rest on the user responsibility), but this can also happen
when subperiods (i.e. via temporal masking) have no observations even
if there are observations in the overall period (which is less easy
for the user to anticipate)
1 merge request!3release v0.1.0
Pipeline #44159 failed with stage
in 3 minutes and 57 seconds
Showing with 19 additions and 10 deletions
+19 -10
...@@ -209,16 +209,25 @@ namespace evalhyd ...@@ -209,16 +209,25 @@ namespace evalhyd
auto obs_filtered = auto obs_filtered =
xt::filter(obs, !xt::isnan(obs)); xt::filter(obs, !xt::isnan(obs));
// lower bound if (obs_filtered.size() > 0)
xt::view(clim_bnds, s, l, m, e, i, 0) = {
xt::quantile( // lower bound
obs_filtered, {quantiles(i, 0)} xt::view(clim_bnds, s, l, m, e, i, 0) =
)(); xt::quantile(
// upper bound obs_filtered, {quantiles(i, 0)}
xt::view(clim_bnds, s, l, m, e, i, 1) = )();
xt::quantile( // upper bound
obs_filtered, {quantiles(i, 1)} xt::view(clim_bnds, s, l, m, e, i, 1) =
)(); xt::quantile(
obs_filtered, {quantiles(i, 1)}
)();
}
else
{
xt::view(clim_bnds, s, l, m, e, i, xt::all()) =
NAN;
}
} }
} }
} }
......
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