diff --git a/src/basic/vx_config/config_constants.h b/src/basic/vx_config/config_constants.h index e7f872f6b5..344e7295dc 100644 --- a/src/basic/vx_config/config_constants.h +++ b/src/basic/vx_config/config_constants.h @@ -50,7 +50,7 @@ enum class FieldType { // Enumeration for set logic // -enum class SetLogic { +enum class SetLogic { None, // Default Union, // Union Intersection, // Intersection @@ -256,12 +256,14 @@ struct TimeSummaryInfo { // Enumeration for bootstrapping interval configuration parameter // -enum BootIntervalType { - BootIntervalType_None, // Default - BootIntervalType_BCA, // Bias-Corrected and adjusted method - BootIntervalType_Percentile // Percentile method +enum class BootIntervalType { + None, // Default + BCA, // Bias-Corrected and adjusted method + PCTile // Percentile method }; +//////////////////////////////////////////////////////////////////////// + // // Struct to store bootstrapping information // diff --git a/src/basic/vx_config/config_util.cc b/src/basic/vx_config/config_util.cc index 1eec001151..6f1bf64021 100644 --- a/src/basic/vx_config/config_util.cc +++ b/src/basic/vx_config/config_util.cc @@ -1268,7 +1268,7 @@ BootInfo & BootInfo::operator=(const BootInfo &a) noexcept { /////////////////////////////////////////////////////////////////////////////// void BootInfo::clear() { - interval = BootIntervalType_None; + interval = BootIntervalType::None; rep_prop = bad_data_double; n_rep = 0; rng.clear(); @@ -1292,8 +1292,12 @@ BootInfo parse_conf_boot(Dictionary *dict) { v = dict->lookup_int(conf_key_boot_interval); // Convert integer to enumerated BootIntervalType - if(v == conf_const.lookup_int(conf_val_bca)) info.interval = BootIntervalType_BCA; - else if(v == conf_const.lookup_int(conf_val_pctile)) info.interval = BootIntervalType_Percentile; + if(v == conf_const.lookup_int(conf_val_bca)) { + info.interval = BootIntervalType::BCA; + } + else if(v == conf_const.lookup_int(conf_val_pctile)) { + info.interval = BootIntervalType::PCTile; + } else { mlog << Error << "\nparse_conf_boot() -> " << "Unexpected config file value of " << v << " for \"" @@ -2731,6 +2735,32 @@ STATLineType string_to_statlinetype(const char *s) { /////////////////////////////////////////////////////////////////////////////// +const char * bootintervaltype_to_string(const BootIntervalType t) { + const char *s = (const char *) nullptr; + + switch(t) { + case(BootIntervalType::BCA): s = conf_val_bca; break; + case(BootIntervalType::PCTile): s = conf_val_pctile; break; + default: s = conf_val_none; break; + } + + return s; +} + +/////////////////////////////////////////////////////////////////////////////// + +BootIntervalType string_to_bootintervaltype(const char *s) { + BootIntervalType t; + + if(strcasecmp(s, conf_val_bca) == 0) t = BootIntervalType::BCA; + else if(strcasecmp(s, conf_val_pctile) == 0) t = BootIntervalType::PCTile; + else t = BootIntervalType::None; + + return t; +} + +/////////////////////////////////////////////////////////////////////////////// + FieldType int_to_fieldtype(int v) { FieldType t = FieldType::None; diff --git a/src/basic/vx_config/config_util.h b/src/basic/vx_config/config_util.h index 316c8eb14a..4ca142903d 100644 --- a/src/basic/vx_config/config_util.h +++ b/src/basic/vx_config/config_util.h @@ -105,6 +105,9 @@ extern const char * statlinetype_to_string(const STATLineType); extern void statlinetype_to_string(const STATLineType, char *); extern STATLineType string_to_statlinetype(const char *); +extern const char * bootintervaltype_to_string(const BootIntervalType); +extern BootIntervalType string_to_bootintervaltype(const char *); + extern FieldType int_to_fieldtype(int); extern ConcatString fieldtype_to_string(FieldType); diff --git a/src/basic/vx_util/util_constants.h b/src/basic/vx_util/util_constants.h index f80be6f21c..e2520efd18 100644 --- a/src/basic/vx_util/util_constants.h +++ b/src/basic/vx_util/util_constants.h @@ -95,10 +95,6 @@ static const char ws_reg_exp[] = "[ \t\r\n]"; static const char ws_line_reg_exp[] = "^[ \t\r\n]*$"; static const char sep_str[] = "--------------------------------------------------------------------------------"; -// Bootstrap methods -static const int boot_bca_flag = 0; -static const int boot_perc_flag = 1; - //////////////////////////////////////////////////////////////////////// static const int max_line_len = 2048; diff --git a/src/libcode/vx_analysis_util/stat_job.cc b/src/libcode/vx_analysis_util/stat_job.cc index c36758f8db..e65db03548 100644 --- a/src/libcode/vx_analysis_util/stat_job.cc +++ b/src/libcode/vx_analysis_util/stat_job.cc @@ -199,7 +199,7 @@ void STATAnalysisJob::clear() { out_wind_logic = SetLogic::Union; out_alpha = bad_data_double; - boot_interval = bad_data_int; + boot_interval = BootIntervalType::None; boot_rep_prop = bad_data_double; n_boot_rep = bad_data_int; @@ -621,7 +621,7 @@ void STATAnalysisJob::dump(ostream & out, int depth) const { << swing_width << "\n"; out << prefix << "boot_interval = " - << boot_interval << "\n"; + << bootintervaltype_to_string(boot_interval) << "\n"; out << prefix << "boot_rep_prop = " << boot_rep_prop << "\n"; @@ -1592,7 +1592,7 @@ void STATAnalysisJob::parse_job_command(const char *jobstring) { i++; } else if(jc_array[i] == "-boot_interval") { - boot_interval = atoi(jc_array[i+1].c_str()); + boot_interval = string_to_bootintervaltype(jc_array[i+1].c_str()); i++; } else if(jc_array[i] == "-boot_rep_prop") { @@ -2821,7 +2821,7 @@ ConcatString STATAnalysisJob::get_jobstring() const { out_line_type.has(stat_nbrcnt_str))) { // Bootstrap Information - js << "-boot_interval " << boot_interval << " "; + js << "-boot_interval " << bootintervaltype_to_string(boot_interval) << " "; js << "-boot_rep_prop " << boot_rep_prop << " "; js << "-n_boot_rep " << n_boot_rep << " "; js << "-boot_rng " << boot_rng << " "; diff --git a/src/libcode/vx_analysis_util/stat_job.h b/src/libcode/vx_analysis_util/stat_job.h index e88ba5b1d8..36d00c8dfa 100644 --- a/src/libcode/vx_analysis_util/stat_job.h +++ b/src/libcode/vx_analysis_util/stat_job.h @@ -305,9 +305,8 @@ class STATAnalysisJob { // // Type of bootstrap confidence interval method: - // 0 = BCA, 1 = Percentile (Default = 1) // - int boot_interval; + BootIntervalType boot_interval; // // When using the percentile method, this is the proportion diff --git a/src/tools/core/grid_stat/grid_stat.cc b/src/tools/core/grid_stat/grid_stat.cc index 752a4bcfcb..86c99906a3 100644 --- a/src/tools/core/grid_stat/grid_stat.cc +++ b/src/tools/core/grid_stat/grid_stat.cc @@ -1988,7 +1988,7 @@ void do_cts(CTSInfo *&cts_info, int i_vx, // Compute the counts, stats, normal confidence intervals, and // bootstrap confidence intervals // - if(conf_info.vx_opt[i_vx].boot_info.interval == BootIntervalType_BCA) { + if(conf_info.vx_opt[i_vx].boot_info.interval == BootIntervalType::BCA) { compute_cts_stats_ci_bca(rng_ptr, *pd_ptr, conf_info.vx_opt[i_vx].boot_info.n_rep, cts_info, n_cts, @@ -2037,7 +2037,7 @@ void do_mcts(MCTSInfo &mcts_info, int i_vx, // Compute the counts, stats, normal confidence intervals, and // bootstrap confidence intervals // - if(conf_info.vx_opt[i_vx].boot_info.interval == BootIntervalType_BCA) { + if(conf_info.vx_opt[i_vx].boot_info.interval == BootIntervalType::BCA) { compute_mcts_stats_ci_bca(rng_ptr, *pd_ptr, conf_info.vx_opt[i_vx].boot_info.n_rep, mcts_info, @@ -2164,7 +2164,7 @@ void do_cnt_sl1l2(const GridStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { // Compute the stats, normal confidence intervals, and // bootstrap confidence intervals - if(vx_opt.boot_info.interval == BootIntervalType_BCA) { + if(vx_opt.boot_info.interval == BootIntervalType::BCA) { compute_cnt_stats_ci_bca(rng_ptr, pd, precip_flag, vx_opt.rank_corr_flag, vx_opt.boot_info.n_rep, @@ -2469,7 +2469,7 @@ void do_nbrcts(NBRCTSInfo *&nbrcts_info, // Compute the stats, normal confidence intervals, and // bootstrap confidence intervals // - if(conf_info.vx_opt[i_vx].boot_info.interval == BootIntervalType_BCA) { + if(conf_info.vx_opt[i_vx].boot_info.interval == BootIntervalType::BCA) { compute_nbrcts_stats_ci_bca(rng_ptr, *pd_ptr, conf_info.vx_opt[i_vx].boot_info.n_rep, nbrcts_info, n_nbrcts, @@ -2530,7 +2530,7 @@ void do_nbrcnt(NBRCNTInfo &nbrcnt_info, // Compute the stats, normal confidence intervals, and // bootstrap confidence intervals // - if(conf_info.vx_opt[i_vx].boot_info.interval == BootIntervalType_BCA) { + if(conf_info.vx_opt[i_vx].boot_info.interval == BootIntervalType::BCA) { compute_nbrcnt_stats_ci_bca(rng_ptr, *pd_ptr, *pd_thr_ptr, conf_info.vx_opt[i_vx].boot_info.n_rep, nbrcnt_info, diff --git a/src/tools/core/point_stat/point_stat.cc b/src/tools/core/point_stat/point_stat.cc index 80d16a6145..c911779718 100644 --- a/src/tools/core/point_stat/point_stat.cc +++ b/src/tools/core/point_stat/point_stat.cc @@ -1365,7 +1365,7 @@ void do_cts(CTSInfo *&cts_info, int i_vx, const PairDataPoint *pd_ptr) { // Compute the stats, normal confidence intervals, and bootstrap // bootstrap confidence intervals // - if(conf_info.vx_opt[i_vx].boot_info.interval == BootIntervalType_BCA) { + if(conf_info.vx_opt[i_vx].boot_info.interval == BootIntervalType::BCA) { compute_cts_stats_ci_bca(rng_ptr, *pd_ptr, conf_info.vx_opt[i_vx].boot_info.n_rep, cts_info, n_cat, @@ -1416,7 +1416,7 @@ void do_mcts(MCTSInfo &mcts_info, int i_vx, const PairDataPoint *pd_ptr) { // Compute the stats, normal confidence intervals, and bootstrap // bootstrap confidence intervals // - if(conf_info.vx_opt[i_vx].boot_info.interval == BootIntervalType_BCA) { + if(conf_info.vx_opt[i_vx].boot_info.interval == BootIntervalType::BCA) { compute_mcts_stats_ci_bca(rng_ptr, *pd_ptr, conf_info.vx_opt[i_vx].boot_info.n_rep, mcts_info, @@ -1544,7 +1544,7 @@ void do_cnt_sl1l2(const PointStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { // Compute the stats, normal confidence intervals, and // bootstrap confidence intervals - if(vx_opt.boot_info.interval == BootIntervalType_BCA) { + if(vx_opt.boot_info.interval == BootIntervalType::BCA) { compute_cnt_stats_ci_bca(rng_ptr, pd, precip_flag, vx_opt.rank_corr_flag, vx_opt.boot_info.n_rep, diff --git a/src/tools/core/series_analysis/series_analysis.cc b/src/tools/core/series_analysis/series_analysis.cc index e7a05ad78a..3b1108b709 100644 --- a/src/tools/core/series_analysis/series_analysis.cc +++ b/src/tools/core/series_analysis/series_analysis.cc @@ -930,7 +930,7 @@ void do_cts(int n, const PairDataPoint *pd_ptr) { // Compute the counts, stats, normal confidence intervals, and // bootstrap confidence intervals - if(conf_info.boot_interval == BootIntervalType_BCA) { + if(conf_info.boot_interval == BootIntervalType::BCA) { compute_cts_stats_ci_bca(rng_ptr, *pd_ptr, conf_info.n_boot_rep, cts_info, n_cts, true, @@ -994,7 +994,7 @@ void do_mcts(int n, const PairDataPoint *pd_ptr) { // Compute the counts, stats, normal confidence intervals, and // bootstrap confidence intervals - if(conf_info.boot_interval == BootIntervalType_BCA) { + if(conf_info.boot_interval == BootIntervalType::BCA) { compute_mcts_stats_ci_bca(rng_ptr, *pd_ptr, conf_info.n_boot_rep, mcts_info, true, @@ -1060,7 +1060,7 @@ void do_cnt(int n, const PairDataPoint *pd_ptr) { int precip_flag = (conf_info.fcst_info[0]->is_precipitation() && conf_info.obs_info[0]->is_precipitation()); - if(conf_info.boot_interval == BootIntervalType_BCA) { + if(conf_info.boot_interval == BootIntervalType::BCA) { compute_cnt_stats_ci_bca(rng_ptr, pd, precip_flag, conf_info.rank_corr_flag, conf_info.n_boot_rep, diff --git a/src/tools/core/series_analysis/series_analysis_conf_info.cc b/src/tools/core/series_analysis/series_analysis_conf_info.cc index 6e79c25863..c4a9e2fa50 100644 --- a/src/tools/core/series_analysis/series_analysis_conf_info.cc +++ b/src/tools/core/series_analysis/series_analysis_conf_info.cc @@ -70,7 +70,7 @@ void SeriesAnalysisConfInfo::clear() { cnt_logic = SetLogic::None; cdf_info.clear(); ci_alpha.clear(); - boot_interval = BootIntervalType_None; + boot_interval = BootIntervalType::None; boot_rep_prop = bad_data_double; n_boot_rep = bad_data_int; boot_rng.clear(); diff --git a/src/tools/core/stat_analysis/aggr_stat_line.cc b/src/tools/core/stat_analysis/aggr_stat_line.cc index 3ca4cfcaff..dd53c0a3e6 100644 --- a/src/tools/core/stat_analysis/aggr_stat_line.cc +++ b/src/tools/core/stat_analysis/aggr_stat_line.cc @@ -3927,7 +3927,7 @@ void mpr_to_cts(STATAnalysisJob &job, const AggrMPRInfo &info, // bootstrap confidence intervals // cts_info_ptr = &cts_info; - if(job.boot_interval == boot_bca_flag) { + if(job.boot_interval == BootIntervalType::BCA) { compute_cts_stats_ci_bca(rng_ptr, info.pd, job.n_boot_rep, cts_info_ptr, 1, 1, @@ -3997,7 +3997,7 @@ void mpr_to_mcts(STATAnalysisJob &job, const AggrMPRInfo &info, // Compute the counts, stats, normal confidence intervals, and // bootstrap confidence intervals // - if(job.boot_interval == boot_bca_flag) { + if(job.boot_interval == BootIntervalType::BCA) { compute_mcts_stats_ci_bca(rng_ptr, info.pd, job.n_boot_rep, mcts_info, 1, @@ -4064,14 +4064,12 @@ void mpr_to_cnt(STATAnalysisJob &job, const AggrMPRInfo &info, // Compute the stats, normal confidence intervals, and // bootstrap confidence intervals // - if(job.boot_interval == boot_bca_flag) { - + if(job.boot_interval == BootIntervalType::BCA) { compute_cnt_stats_ci_bca(rng_ptr, pd_thr, precip_flag, job.rank_corr_flag, job.n_boot_rep, cnt_info, tmp_dir); } else { - compute_cnt_stats_ci_perc(rng_ptr, pd_thr, precip_flag, job.rank_corr_flag, job.n_boot_rep, job.boot_rep_prop, cnt_info, tmp_dir); diff --git a/src/tools/core/stat_analysis/stat_analysis_job.cc b/src/tools/core/stat_analysis/stat_analysis_job.cc index da0807f2ec..d47c82c080 100644 --- a/src/tools/core/stat_analysis/stat_analysis_job.cc +++ b/src/tools/core/stat_analysis/stat_analysis_job.cc @@ -1130,7 +1130,7 @@ void write_job_summary(STATAnalysisJob &job, // // Compute a bootstrap confidence interval for the mean. // - if(job.boot_interval == boot_bca_flag) { + if(job.boot_interval == BootIntervalType::BCA) { compute_mean_stdev_ci_bca(rng_ptr, val_it->second, job.n_boot_rep, job.out_alpha, mean_ci, stdev_ci);