From 3043544f68695c9168f81b46d9f3c6323c0a335f Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Mon, 25 Jan 2021 19:59:23 -0700 Subject: [PATCH 1/3] Per #1638, correct the order of arguments in the call to the normal_cdf() utility function. --- met/src/tools/core/grid_stat/grid_stat.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/met/src/tools/core/grid_stat/grid_stat.cc b/met/src/tools/core/grid_stat/grid_stat.cc index 46e579f765..2a8960b28d 100644 --- a/met/src/tools/core/grid_stat/grid_stat.cc +++ b/met/src/tools/core/grid_stat/grid_stat.cc @@ -1070,7 +1070,7 @@ void process_scores() { conf_info.vx_opt[i].interp_info.field); } if(conf_info.vx_opt[i].nc_info.do_climo && !cmn_dp.is_empty() && !csd_dp.is_empty()) { - write_nc((string)"CLIMO_CDF", normal_cdf(cmn_dp, csd_dp, obs_dp), + write_nc((string)"CLIMO_CDF", normal_cdf(obs_dp, cmn_dp, csd_dp), i, mthd, pnts, conf_info.vx_opt[i].interp_info.field); } From 99ac2a1a1f480f5bb2436d018c7600a1a2ccba5f Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Mon, 25 Jan 2021 20:46:53 -0700 Subject: [PATCH 2/3] Per #1638, update the logic in derive_climo_prob(). For CDP thresholds, the constant climo probability should be based on the inequality type where less-than-types match the threshold percentile value while greater-than-types are 1.0 minus the threshold percentile. --- met/src/libcode/vx_statistics/pair_base.cc | 35 ++++++++++++++++++++-- met/src/tools/core/grid_stat/grid_stat.cc | 6 ++-- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/met/src/libcode/vx_statistics/pair_base.cc b/met/src/libcode/vx_statistics/pair_base.cc index c4e5a85272..bfcebaad0c 100644 --- a/met/src/libcode/vx_statistics/pair_base.cc +++ b/met/src/libcode/vx_statistics/pair_base.cc @@ -1026,9 +1026,40 @@ NumArray derive_climo_prob(const NumArray &mn_na, const NumArray &sd_na, n_mn = mn_na.n_valid(); n_sd = sd_na.n_valid(); - // For CDP threshold types, the climo_prob is constant. + // For CDP threshold types, the climo probability is constant if(othresh.get_ptype() == perc_thresh_climo_dist) { - climo_prob.add_const(othresh.get_pvalue()/100.0, n_mn); + + // Climo probability varies based on the threshold type + switch(othresh.get_type()) { + + case thresh_lt: + case thresh_le: + prob = othresh.get_pvalue()/100.0; + break; + + case thresh_eq: + prob = 0.0; + break; + + case thresh_ne: + prob = 1.0; + break; + + case thresh_gt: + case thresh_ge: + prob = 1.0 - othresh.get_pvalue()/100.0; + break; + + default: + mlog << Error << "\n\nderive_climo_prob() -> " + << "climatological threshold \"" << othresh.get_str() + << "\" cannot be converted to a probability!\n\n"; + exit(1); + break; + } + + // Add constant climo probability value + climo_prob.add_const(prob, n_mn); } // If both mean and standard deviation were provided, use them to // derive normal climatological probabilities for the current event diff --git a/met/src/tools/core/grid_stat/grid_stat.cc b/met/src/tools/core/grid_stat/grid_stat.cc index 2a8960b28d..5a90a6464f 100644 --- a/met/src/tools/core/grid_stat/grid_stat.cc +++ b/met/src/tools/core/grid_stat/grid_stat.cc @@ -1803,11 +1803,11 @@ void get_mask_points(const MaskPlane &mask_mp, apply_mask(*obs_ptr, mask_mp, pd.o_na); pd.n_obs = pd.o_na.n(); - if(cmn_ptr) apply_mask(*cmn_ptr, mask_mp, pd.cmn_na); + if(cmn_ptr) apply_mask(*cmn_ptr, mask_mp, pd.cmn_na); else pd.cmn_na.add_const(bad_data_double, pd.n_obs); - if(csd_ptr) apply_mask(*csd_ptr, mask_mp, pd.csd_na); + if(csd_ptr) apply_mask(*csd_ptr, mask_mp, pd.csd_na); else pd.csd_na.add_const(bad_data_double, pd.n_obs); - if(wgt_ptr) apply_mask(*wgt_ptr, mask_mp, pd.wgt_na); + if(wgt_ptr) apply_mask(*wgt_ptr, mask_mp, pd.wgt_na); else pd.wgt_na.add_const(default_grid_weight, pd.n_obs); if(cmn_ptr && csd_ptr) pd.add_climo_cdf(); From 6dd774e28834732807e3907d39db9788a35cd5a2 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Tue, 26 Jan 2021 09:25:38 -0700 Subject: [PATCH 3/3] Per #1638, update normal_cdf() to initialize the output CDF field using the climo mean field instead of the observation data field. This makes the timestamps consistent for the climo mean, stdev, and cdf variables in the Grid-Stat NetCDF matched pairs output file. --- met/src/basic/vx_util/data_plane_util.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/met/src/basic/vx_util/data_plane_util.cc b/met/src/basic/vx_util/data_plane_util.cc index 766764fdbb..7174a36b84 100644 --- a/met/src/basic/vx_util/data_plane_util.cc +++ b/met/src/basic/vx_util/data_plane_util.cc @@ -606,7 +606,7 @@ DataPlane subtract(const DataPlane &dp1, const DataPlane &dp2) { DataPlane normal_cdf(const DataPlane &dp, const DataPlane &mn, const DataPlane &sd) { - DataPlane cdf = dp; + DataPlane cdf = mn; double v; // Check grid dimensions