Skip to content

Commit

Permalink
Per #3006, update pair_stat to use the newly added GrdFileType::FileT…
Browse files Browse the repository at this point in the history
…ype_Pairs enumerated value.
  • Loading branch information
JohnHalleyGotway committed Dec 26, 2024
1 parent 4a9c387 commit 5325ee9
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 11 deletions.
14 changes: 14 additions & 0 deletions data/config/PairStatConfig_default
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@ obs = {

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

//
// Mapping of message type group name to comma-separated list of values
//
message_type_group_map = [
{ key = "SURFACE"; val = "ADPSFC,SFCSHP,MSONET"; },
{ key = "ANYAIR"; val = "AIRCAR,AIRCFT"; },
{ key = "ANYSFC"; val = "ADPSFC,SFCSHP,ADPUPA,PROFLR,MSONET"; },
{ key = "ONLYSF"; val = "ADPSFC,SFCSHP"; },
{ key = "LANDSF"; val = "ADPSFC,MSONET"; },
{ key = "WATERSF"; val = "SFCSHP"; }
];

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

//
// Forecast and observation data censoring, thresholding, and filtering options
// May be set separately in each "fcst.pairs" or "obs.pairs" entry
Expand Down
16 changes: 14 additions & 2 deletions src/tools/core/pair_stat/pair_stat.cc
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,12 @@ void process_command_line(int argc, char **argv) {
<< "Pairs File(s): " << write_css(pairs_files) << "\n";

// Set the model name
shc.set_model(conf_info.model.c_str());
if(conf_info.model.empty()) {
shc.set_model(na_str);
}
else {
shc.set_model(conf_info.model.c_str());
}

// Use the first verification task to set the random number generator
// and seed value for bootstrap confidence intervals
Expand Down Expand Up @@ -869,7 +874,12 @@ void process_scores() {
if(conf_info.vx_opt[i_vx].vx_pd.fcst_dpa.n_planes() == 0) continue;

// Store the description
shc.set_desc(conf_info.vx_opt[i_vx].vx_pd.desc.c_str());
if(conf_info.vx_opt[i_vx].vx_pd.desc.empty()) {
shc.set_desc(na_str);
}
else {
shc.set_desc(conf_info.vx_opt[i_vx].vx_pd.desc.c_str());
}

// Store the forecast variable name
shc.set_fcst_var(conf_info.vx_opt[i_vx].vx_pd.fcst_info->name_attr());
Expand Down Expand Up @@ -2149,6 +2159,8 @@ void usage() {
<< "\t[-log file]\n"
<< "\t[-v level]\n\n"


// JHG change -pairs file to -pairs file_list to support a long list of inputs
<< "\twhere\t\"-pairs file\" is one or more files containing "
<< "forecast/observation pairs. May be used multiple times "
<< "(required).\n"
Expand Down
16 changes: 8 additions & 8 deletions src/tools/core/pair_stat/pair_stat_conf_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ void PairStatConfInfo::process_config(PairsFormat ftype) {
version = parse_conf_version(&conf);

// Conf: model
model = parse_conf_string(&conf, conf_key_model);
model = parse_conf_string(&conf, conf_key_model, false);

// Conf: point_weight_flag
point_weight_flag = parse_conf_point_weight_flag(&conf);
Expand All @@ -156,9 +156,9 @@ void PairStatConfInfo::process_config(PairsFormat ftype) {
// Conf: message_type_group_map
msg_typ_group_map = parse_conf_message_type_group_map(&conf);

// Conf: fcst.field and obs.field
fdict = conf.lookup_array(conf_key_fcst_field);
odict = conf.lookup_array(conf_key_obs_field);
// Conf: fcst.pairs and obs.pairs
fdict = conf.lookup_array(conf_key_fcst_pairs);
odict = conf.lookup_array(conf_key_obs_pairs);

// Determine the number of fields (name/level) to be verified
n_fvx = parse_conf_n_vx(fdict);
Expand All @@ -168,9 +168,9 @@ void PairStatConfInfo::process_config(PairsFormat ftype) {
if(n_fvx == 0 || n_fvx != n_ovx) {
mlog << Error << "\nPairStatConfInfo::process_config() -> "
<< "The number of verification tasks in \""
<< conf_key_obs_field << "\" (" << n_ovx
<< conf_key_obs_pairs << "\" (" << n_ovx
<< ") must be non-zero and match the number in \""
<< conf_key_fcst_field << "\" (" << n_fvx << ").\n\n";
<< conf_key_fcst_pairs << "\" (" << n_fvx << ").\n\n";
exit(1);
}

Expand Down Expand Up @@ -800,8 +800,8 @@ void PairStatVxOpt::process_config(PairsFormat ftype,
clear();

// Allocate new VarInfo objects
vx_pd.set_fcst_info(info_factory.new_var_info(FileType_None));
vx_pd.set_obs_info(info_factory.new_var_info(FileType_None));
vx_pd.set_fcst_info(info_factory.new_var_info(FileType_Pairs));
vx_pd.set_obs_info(info_factory.new_var_info(FileType_Pairs));

// Set the VarInfo objects
vx_pd.fcst_info->set_dict(fdict);
Expand Down
2 changes: 1 addition & 1 deletion src/tools/core/pair_stat/pair_stat_conf_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ class PairStatConfInfo {
// Pair-Stat configuration object
MetConfig conf;

// Store data parsed from the Pair-Stat configuration object
// Model name from the Pair-Stat config file
ConcatString model; // Model name

std::vector<PairStatVxOpt> vx_opt; // Vector of vx options [n_vx]
Expand Down

0 comments on commit 5325ee9

Please sign in to comment.