From 1d849fb74ed5129c579c97aef1078e99b4546490 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Wed, 28 Jul 2021 13:15:01 -0600 Subject: [PATCH] Per #1843, check for divide by zero when computing SI... this could happen if comparing the same input file to itself with Grid-Stat. --- met/src/libcode/vx_statistics/compute_stats.cc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/met/src/libcode/vx_statistics/compute_stats.cc b/met/src/libcode/vx_statistics/compute_stats.cc index b6c193b90e..e147c30908 100644 --- a/met/src/libcode/vx_statistics/compute_stats.cc +++ b/met/src/libcode/vx_statistics/compute_stats.cc @@ -121,7 +121,12 @@ void compute_cntinfo(const SL1L2Info &s, bool aflag, CNTInfo &cnt_info) { cnt_info.rmse.v = sqrt(cnt_info.mse.v); // Compute Scatter Index (SI) - cnt_info.si.v = cnt_info.rmse.v / cnt_info.me.v; + if(!is_eq(cnt_info.me.v, 0.0)) { + cnt_info.si.v = cnt_info.rmse.v / cnt_info.me.v; + } + else { + cnt_info.si.v = bad_data_double; + } // Compute normal confidence intervals cnt_info.compute_ci(); @@ -348,7 +353,13 @@ void compute_cntinfo(const PairDataPoint &pd, const NumArray &i_na, // // Compute Scatter Index (SI) // - cnt_info.si.v = cnt_info.rmse.v / cnt_info.me.v; + if(!is_eq(cnt_info.me.v, 0.0)) { + cnt_info.si.v = cnt_info.rmse.v / cnt_info.me.v; + } + else { + cnt_info.si.v = bad_data_double; + } + // // Only compute the Kendall Tau and Spearman's Rank corrleation