Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature #2830 bootstrap enum #2843

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/basic/vx_config/config_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ enum class FieldType {
// Enumeration for set logic
//

enum class SetLogic {
enum class SetLogic {
None, // Default
Union, // Union
Intersection, // Intersection
Expand Down Expand Up @@ -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
//
Expand Down
36 changes: 33 additions & 3 deletions src/basic/vx_config/config_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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 \""
Expand Down Expand Up @@ -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;

Expand Down
3 changes: 3 additions & 0 deletions src/basic/vx_config/config_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 0 additions & 4 deletions src/basic/vx_util/util_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/libcode/vx_analysis_util/stat_job.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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") {
Expand Down Expand Up @@ -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 << " ";
Expand Down
3 changes: 1 addition & 2 deletions src/libcode/vx_analysis_util/stat_job.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/tools/core/grid_stat/grid_stat.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions src/tools/core/point_stat/point_stat.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions src/tools/core/series_analysis/series_analysis.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
8 changes: 3 additions & 5 deletions src/tools/core/stat_analysis/aggr_stat_line.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/tools/core/stat_analysis/stat_analysis_job.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down