Skip to content

Commit

Permalink
Per #3006, use ConcatString instead of std::string for consistency.
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnHalleyGotway committed Dec 27, 2024
1 parent eda1b90 commit c6dbfb6
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 21 deletions.
2 changes: 2 additions & 0 deletions src/basic/vx_config/config_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,8 @@ static const char conf_key_censor_thresh[] = "censor_thresh";
static const char conf_key_censor_val[] = "censor_val";
static const char conf_key_mpr_column[] = "mpr_column";
static const char conf_key_mpr_thresh[] = "mpr_thresh";
static const char conf_key_mpr_str_inc[] = "mpr_str_inc";
static const char conf_key_mpr_str_exc[] = "mpr_str_exc";
static const char conf_key_cnt_thresh[] = "cnt_thresh";
static const char conf_key_cnt_logic[] = "cnt_logic";
static const char conf_key_cat_thresh[] = "cat_thresh";
Expand Down
6 changes: 3 additions & 3 deletions src/libcode/vx_statistics/pair_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1436,7 +1436,7 @@ void VxPairBase::set_interp(int i_interp,

////////////////////////////////////////////////////////////////////////

void VxPairBase::set_mpr_thr_inc_map(const map<string,ThreshArray> &m) {
void VxPairBase::set_mpr_thr_inc_map(const map<ConcatString,ThreshArray> &m) {

mpr_thr_inc_map = m;

Expand All @@ -1445,7 +1445,7 @@ void VxPairBase::set_mpr_thr_inc_map(const map<string,ThreshArray> &m) {

////////////////////////////////////////////////////////////////////////

void VxPairBase::set_mpr_str_inc_map(const map<string,StringArray> &m) {
void VxPairBase::set_mpr_str_inc_map(const map<ConcatString,StringArray> &m) {

mpr_str_inc_map = m;

Expand All @@ -1454,7 +1454,7 @@ void VxPairBase::set_mpr_str_inc_map(const map<string,StringArray> &m) {

////////////////////////////////////////////////////////////////////////

void VxPairBase::set_mpr_str_exc_map(const map<string,StringArray> &m) {
void VxPairBase::set_mpr_str_exc_map(const map<ConcatString,StringArray> &m) {

mpr_str_exc_map = m;

Expand Down
12 changes: 6 additions & 6 deletions src/libcode/vx_statistics/pair_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,12 @@ class VxPairBase {

// Mapping of numeric MPR columns or diffs of colums to
// inclusion thresholds
std::map<std::string,ThreshArray> mpr_thr_inc_map;
std::map<ConcatString,ThreshArray> mpr_thr_inc_map;

// Mapping of string MPR columns to list of inclusion
// and exclusion strings
std::map<std::string,StringArray> mpr_str_inc_map;
std::map<std::string,StringArray> mpr_str_exc_map;
std::map<ConcatString,StringArray> mpr_str_inc_map;
std::map<ConcatString,StringArray> mpr_str_exc_map;


//////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -385,9 +385,9 @@ class VxPairBase {
void set_interp(int i_interp, InterpMthd mthd,
int width, GridTemplateFactory::GridTemplates shape);

void set_mpr_thr_inc_map(const std::map<std::string,ThreshArray> &);
void set_mpr_str_inc_map(const std::map<std::string,StringArray> &);
void set_mpr_str_exc_map(const std::map<std::string,StringArray> &);
void set_mpr_thr_inc_map(const std::map<ConcatString,ThreshArray> &);
void set_mpr_str_inc_map(const std::map<ConcatString,StringArray> &);
void set_mpr_str_exc_map(const std::map<ConcatString,StringArray> &);

void set_climo_cdf_info_ptr(const ClimoCDFInfo *);

Expand Down
4 changes: 2 additions & 2 deletions src/libcode/vx_statistics/pair_data_point.cc
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ bool check_fo_thresh(double f, double o, const ClimoPntInfo &cpi,
////////////////////////////////////////////////////////////////////////

bool check_mpr_thresh(double f, double o, const ClimoPntInfo &cpi,
const map<string,ThreshArray> &m,
const map<ConcatString,ThreshArray> &m,
ConcatString *reason_ptr) {
// Initialize
if(reason_ptr) reason_ptr->erase();
Expand Down Expand Up @@ -846,7 +846,7 @@ double get_mpr_column_value(double f, double o, const ClimoPntInfo &cpi,
void apply_mpr_thresh_mask(DataPlane &fcst_dp, DataPlane &obs_dp,
DataPlane &fcmn_dp, DataPlane &fcsd_dp,
DataPlane &ocmn_dp, DataPlane &ocsd_dp,
const map<string,ThreshArray> &m) {
const map<ConcatString,ThreshArray> &m) {

// Check for no work to be done
if(m.size() == 0) return;
Expand Down
4 changes: 2 additions & 2 deletions src/libcode/vx_statistics/pair_data_point.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ extern bool check_fo_thresh(double, double, const ClimoPntInfo &,
const SetLogic);

extern bool check_mpr_thresh(double, double, const ClimoPntInfo &,
const std::map<std::string,ThreshArray> &,
const std::map<ConcatString,ThreshArray> &,
ConcatString * = 0);

extern double get_mpr_column_value(double, double, const ClimoPntInfo &,
Expand All @@ -150,7 +150,7 @@ extern double get_mpr_column_value(double, double, const ClimoPntInfo &,
extern void apply_mpr_thresh_mask(DataPlane &, DataPlane &,
DataPlane &, DataPlane &,
DataPlane &, DataPlane &,
const std::map<std::string,ThreshArray> &);
const std::map<ConcatString,ThreshArray> &);

extern bool check_seeps_thresh(double, double,
const StringArray &, const ThreshArray &,
Expand Down
2 changes: 1 addition & 1 deletion src/tools/core/grid_stat/grid_stat_conf_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class GridStatVxOpt {
// nc_pairs_var_str is deprecated

// Matched pair inclusion thresholds
std::map<string,ThreshArray> mpr_thr_inc_map;
std::map<ConcatString,ThreshArray> mpr_thr_inc_map;

ThreshArray fcat_ta; // fcst categorical thresholds
ThreshArray ocat_ta; // obs categorical thresholds
Expand Down
23 changes: 18 additions & 5 deletions src/tools/core/pair_stat/pair_stat_conf_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,8 @@ void PairStatVxOpt::clear() {
mask_llpnt.clear();

mpr_thr_inc_map.clear();
mpr_str_inc_map.clear();
mpr_str_exc_map.clear();

mask_name.clear();

Expand Down Expand Up @@ -763,6 +765,7 @@ void PairStatVxOpt::process_config(PairsFormat ftype,
VarInfoFactory info_factory;
map<STATLineType,STATOutputType>output_map;
Dictionary *dict;
const char *method_name = "PairStatVxOpt::process_config() -> ";

// Initialize
clear();
Expand All @@ -788,14 +791,14 @@ void PairStatVxOpt::process_config(PairsFormat ftype,
// No support for wind direction
if(vx_pd.fcst_info->is_wind_direction() ||
vx_pd.obs_info->is_wind_direction()) {
mlog << Error << "\nPairStatVxOpt::process_config() -> "
mlog << Error << "\n" << method_name
<< "wind direction may not be verified using pair_stat.\n\n";
exit(1);
}

// Check that the observation field does not contain probabilities
if(vx_pd.obs_info->is_prob()) {
mlog << Error << "\nPairStatVxOpt::process_config() -> "
mlog << Error << "\n" << method_name
<< "the observation field cannot contain probabilities.\n\n";
exit(1);
}
Expand Down Expand Up @@ -842,7 +845,7 @@ void PairStatVxOpt::process_config(PairsFormat ftype,

// Check for the same length
if(mpr_sa.n() != mpr_ta.n()) {
mlog << Error << "\nPairStatVxOpt::process_config() -> "
mlog << Error << "\n" << method_name
<< "The length of \"" << conf_key_mpr_column << "\" and \""
<< conf_key_mpr_thresh << "\" must match (" << mpr_sa.n()
<< " != " << mpr_ta.n() << ")!\n\n";
Expand All @@ -858,6 +861,14 @@ void PairStatVxOpt::process_config(PairsFormat ftype,
mpr_thr_inc_map[(mpr_sa[i])].add(mpr_ta[i]);
}

// Conf: mpr_str_inc
parse_add_conf_key_values_map(&odict, conf_key_mpr_str_inc,
&mpr_str_inc_map, method_name);

// Conf: mpr_str_exc
parse_add_conf_key_values_map(&odict, conf_key_mpr_str_exc,
&mpr_str_exc_map, method_name);

// Dump the contents of the current thresholds
if(mlog.verbosity_level() >= 5) {
mlog << Debug(5)
Expand All @@ -883,7 +894,7 @@ void PairStatVxOpt::process_config(PairsFormat ftype,
if(!vx_pd.fcst_info->is_prob() &&
fcat_ta.n() != ocat_ta.n()) {

mlog << Error << "\nPairStatVxOpt::process_config() -> "
mlog << Error << "\n" << method_name
<< "The number of thresholds for each field in \"fcst."
<< conf_key_cat_thresh
<< "\" must match the number of thresholds for each "
Expand Down Expand Up @@ -986,8 +997,10 @@ void PairStatVxOpt::set_vx_pd(PairStatConfInfo *conf_info) {
// Define the dimensions with n_msg_typ = n_interp = 1
vx_pd.set_size(1, n_mask, 1);

// Store the MPR filtering thresholds
// Store the MPR filtering maps
vx_pd.set_mpr_thr_inc_map(mpr_thr_inc_map);
vx_pd.set_mpr_str_inc_map(mpr_str_inc_map);
vx_pd.set_mpr_str_exc_map(mpr_str_exc_map);

// Store the climo CDF info
vx_pd.set_climo_cdf_info_ptr(&cdf_info);
Expand Down
6 changes: 5 additions & 1 deletion src/tools/core/pair_stat/pair_stat_conf_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,11 @@ class PairStatVxOpt {
StringArray mask_sid; // Masking station ID's

// Matched pair inclusion thresholds
std::map<std::string,ThreshArray> mpr_thr_inc_map;
std::map<ConcatString,ThreshArray> mpr_thr_inc_map;

// Matched pair inclusion and exclusion strings
std::map<ConcatString,StringArray> mpr_str_inc_map;
std::map<ConcatString,StringArray> mpr_str_exc_map;

// Vector of MaskLatLon objects defining Lat/Lon Point masks
std::vector<MaskLatLon> mask_llpnt;
Expand Down
2 changes: 1 addition & 1 deletion src/tools/core/point_stat/point_stat_conf_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class PointStatVxOpt {
StringArray mask_sid; // Masking station ID's

// Matched pair inclusion thresholds
std::map<std::string,ThreshArray> mpr_thr_inc_map;
std::map<ConcatString,ThreshArray> mpr_thr_inc_map;

// Vector of MaskLatLon objects defining Lat/Lon Point masks
std::vector<MaskLatLon> mask_llpnt;
Expand Down

0 comments on commit c6dbfb6

Please sign in to comment.