Skip to content

Commit

Permalink
Per #2279, add new PointWeightType enumeration along with code to par…
Browse files Browse the repository at this point in the history
…se it.
  • Loading branch information
JohnHalleyGotway committed Oct 9, 2024
1 parent 4bbe2ae commit d3069d0
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 2 deletions.
4 changes: 4 additions & 0 deletions data/config/ConfigConstants
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ NONE = 1;
COS_LAT = 2;
AREA = 3;

// Point weight flag settings
NONE = 1;
SID = 2;

// Duplicate flag settings
NONE = 1;
UNIQUE = 2;
Expand Down
15 changes: 15 additions & 0 deletions src/basic/vx_config/config_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,17 @@ enum class GridWeightType {

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

//
// Enumeration for point_weight_flag configuration parameter
//

enum class PointWeightType {
None, // Apply no point weighting
SID // Apply station ID weighting
};

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

//
// Enumeration for grid_decomp_flag configuration parameter
//
Expand Down Expand Up @@ -780,6 +791,7 @@ static const char conf_key_topo_mask[] = "topo_mask";
static const char conf_key_topo_mask_flag[] = "topo_mask.flag";
static const char conf_key_use_obs_thresh[] = "use_obs_thresh";
static const char conf_key_interp_fcst_thresh[] = "interp_fcst_thresh";
static const char conf_key_point_weight_flag[] = "point_weight_flag";

//
// Grid-Stat specific parameter key names
Expand Down Expand Up @@ -1327,6 +1339,9 @@ static const char conf_val_bca[] = "BCA";
static const char conf_val_cos_lat[] = "COS_LAT";
static const char conf_val_area[] = "AREA";

// Point weight flag values
static const char conf_val_sid[] = "SID";

// Duplicate flag values
static const char conf_val_unique[] = "UNIQUE";

Expand Down
34 changes: 32 additions & 2 deletions src/basic/vx_config/config_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2284,9 +2284,10 @@ HiRAInfo parse_conf_hira(Dictionary *dict) {
GridWeightType parse_conf_grid_weight_flag(Dictionary *dict) {
GridWeightType t = GridWeightType::None;
int v;
const char *method_name = "parse_conf_grid_weight_flag() -> ";

if(!dict) {
mlog << Error << "\nparse_conf_grid_weight_flag() -> "
mlog << Error << "\n" << method_name
<< "empty dictionary!\n\n";
exit(1);
}
Expand All @@ -2299,7 +2300,7 @@ GridWeightType parse_conf_grid_weight_flag(Dictionary *dict) {
else if(v == conf_const.lookup_int(conf_val_cos_lat)) t = GridWeightType::Cos_Lat;
else if(v == conf_const.lookup_int(conf_val_area)) t = GridWeightType::Area;
else {
mlog << Error << "\nparse_conf_grid_weight_flag() -> "
mlog << Error << "\n" << method_name
<< "Unexpected config file value of " << v << " for \""
<< conf_key_grid_weight_flag << "\".\n\n";
exit(1);
Expand All @@ -2310,6 +2311,35 @@ GridWeightType parse_conf_grid_weight_flag(Dictionary *dict) {

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

PointWeightType parse_conf_point_weight_flag(Dictionary *dict) {
PointWeightType t = PointWeightType::None;
int v;
const char *method_name = "parse_conf_point_weight_flag() -> ";

if(!dict) {
mlog << Error << "\n" << method_name
<< "empty dictionary!\n\n";
exit(1);
}

// Get the integer flag value for the current entry
v = dict->lookup_int(conf_key_point_weight_flag);

// Convert integer to enumerated GridWeightType
if(v == conf_const.lookup_int(conf_val_none)) t = PointWeightType::None;
else if(v == conf_const.lookup_int(conf_val_sid)) t = PointWeightType::SID;
else {
mlog << Error << "\n" << method_name
<< "Unexpected config file value of " << v << " for \""
<< conf_key_point_weight_flag << "\".\n\n";
exit(1);
}

return t;
}

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

DuplicateType parse_conf_duplicate_flag(Dictionary *dict) {
DuplicateType t = DuplicateType::None;
int v;
Expand Down
1 change: 1 addition & 0 deletions src/basic/vx_config/config_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ extern InterpInfo parse_conf_interp(Dictionary *dict, const char *);
extern NbrhdInfo parse_conf_nbrhd(Dictionary *dict, const char *);
extern HiRAInfo parse_conf_hira(Dictionary *dict);
extern GridWeightType parse_conf_grid_weight_flag(Dictionary *dict);
extern PointWeightType parse_conf_point_weight_flag(Dictionary *dict);
extern DuplicateType parse_conf_duplicate_flag(Dictionary *dict);
extern ObsSummary parse_conf_obs_summary(Dictionary *dict);
extern ConcatString parse_conf_tmp_dir(Dictionary *dict);
Expand Down

0 comments on commit d3069d0

Please sign in to comment.