diff --git a/src/libcode/vx_data2d/var_info.cc b/src/libcode/vx_data2d/var_info.cc index 135a907b4b..f137281819 100644 --- a/src/libcode/vx_data2d/var_info.cc +++ b/src/libcode/vx_data2d/var_info.cc @@ -933,3 +933,14 @@ ConcatString raw_magic_str(Dictionary i_edict, GrdFileType file_type) { } //////////////////////////////////////////////////////////////////////// + +bool is_req_level_match(const ConcatString &s1, const ConcatString &s2) { + bool match = true; + + // No match if either is non-empty and they are not equal. + if((s1.nonempty() || s2.nonempty()) && !(s1 == s2)) match = false; + + return(match); +} + +//////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_data2d/var_info.h b/src/libcode/vx_data2d/var_info.h index 7ac6399f6b..ebcc1fd91d 100644 --- a/src/libcode/vx_data2d/var_info.h +++ b/src/libcode/vx_data2d/var_info.h @@ -304,6 +304,7 @@ class EnsVarInfo { //////////////////////////////////////////////////////////////////////// ConcatString raw_magic_str(Dictionary i_edict, GrdFileType file_type); +bool is_req_level_match(const ConcatString &, const ConcatString &); /////////////////////////////////////////////////////////////////////////////// diff --git a/src/tools/core/grid_stat/grid_stat_conf_info.cc b/src/tools/core/grid_stat/grid_stat_conf_info.cc index ad5cdfb395..abef1ade0d 100644 --- a/src/tools/core/grid_stat/grid_stat_conf_info.cc +++ b/src/tools/core/grid_stat/grid_stat_conf_info.cc @@ -198,11 +198,13 @@ void GridStatConfInfo::process_config(GrdFileType ftype, vx_opt[i].obs_info->uv_index() >= 0) { mlog << Warning << "\nGridStatConfInfo::process_config() -> " << "For U-wind, found multiple matching V-wind field array entries! " - << "Set the \"level\" strings to differentiate between them.\n\n"; + << "Using the first match found. Set the \"level\" strings to " + << "differentiate between them.\n\n"; + } + else { + vx_opt[i].fcst_info->set_uv_index(j); + vx_opt[i].obs_info->set_uv_index(j); } - - vx_opt[i].fcst_info->set_uv_index(j); - vx_opt[i].obs_info->set_uv_index(j); } } @@ -232,7 +234,8 @@ void GridStatConfInfo::process_config(GrdFileType ftype, vx_opt[i].obs_info->uv_index() >= 0) { mlog << Warning << "\nGridStatConfInfo::process_config() -> " << "For V-wind, found multiple matching U-wind field array entries! " - << "Set the \"level\" strings to differentiate between them.\n\n"; + << "Using the first match found. Set the \"level\" strings to " + << "differentiate between them.\n\n"; } vx_opt[i].fcst_info->set_uv_index(j); @@ -937,18 +940,8 @@ bool GridStatVxOpt::is_uv_match(const GridStatVxOpt &v) const { // // Check that requested forecast and observation levels match. - // Requested levels are empty for python embedding. - // - if( ( fcst_info->req_level_name().nonempty() || - v.fcst_info->req_level_name().nonempty()) && - !( fcst_info->req_level_name() == - v.fcst_info->req_level_name())) match = false; - - else if( ( obs_info->req_level_name().nonempty() || - v.obs_info->req_level_name().nonempty()) && - !( obs_info->req_level_name() == - v.obs_info->req_level_name())) match = false; - + // Requested levels are optional for python embedding and may be empty. + // Check that the masking regions and interpolation options match. // // The following do not impact matched pairs: // desc, var_name, var_suffix, @@ -962,10 +955,14 @@ bool GridStatVxOpt::is_uv_match(const GridStatVxOpt &v) const { // hss_ec_value, rank_corr_flag, output_flag, nc_info // - else if(!(mask_grid == v.mask_grid ) || - !(mask_poly == v.mask_poly ) || - !(mask_name == v.mask_name ) || - !(interp_info == v.interp_info)) match = false; + if(!is_req_level_match( fcst_info->req_level_name(), + v.fcst_info->req_level_name()) || + !is_req_level_match( obs_info->req_level_name(), + v.obs_info->req_level_name()) || + !(mask_grid == v.mask_grid ) || + !(mask_poly == v.mask_poly ) || + !(mask_name == v.mask_name ) || + !(interp_info == v.interp_info)) match = false; return(match); } diff --git a/src/tools/core/point_stat/point_stat_conf_info.cc b/src/tools/core/point_stat/point_stat_conf_info.cc index d3c30dcaaa..a94aac2e9b 100644 --- a/src/tools/core/point_stat/point_stat_conf_info.cc +++ b/src/tools/core/point_stat/point_stat_conf_info.cc @@ -192,7 +192,8 @@ void PointStatConfInfo::process_config(GrdFileType ftype) { vx_opt[i].vx_pd.obs_info->uv_index() >= 0) { mlog << Warning << "\nPointStatConfInfo::process_config() -> " << "For U-wind, found multiple matching V-wind field array entries! " - << "Set the \"level\" strings to differentiate between them.\n\n"; + << "Using the first match found. Set the \"level\" strings to " + << "differentiate between them.\n\n"; } vx_opt[i].vx_pd.fcst_info->set_uv_index(j); @@ -226,11 +227,13 @@ void PointStatConfInfo::process_config(GrdFileType ftype) { vx_opt[i].vx_pd.obs_info->uv_index() >= 0) { mlog << Warning << "\nPointStatConfInfo::process_config() -> " << "For U-wind, found multiple matching V-wind field array entries! " - << "Set the \"level\" strings to differentiate between them.\n\n"; + << "Using the first match found. Set the \"level\" strings to " + << "differentiate between them.\n\n"; + } + else { + vx_opt[i].vx_pd.fcst_info->set_uv_index(j); + vx_opt[i].vx_pd.obs_info->set_uv_index(j); } - - vx_opt[i].vx_pd.fcst_info->set_uv_index(j); - vx_opt[i].vx_pd.obs_info->set_uv_index(j); } } @@ -737,18 +740,8 @@ bool PointStatVxOpt::is_uv_match(const PointStatVxOpt &v) const { // // Check that requested forecast and observation levels match. - // Requested levels are empty for python embedding. - // - if( ( vx_pd.fcst_info->req_level_name().nonempty() || - v.vx_pd.fcst_info->req_level_name().nonempty()) && - !( vx_pd.fcst_info->req_level_name() == - v.vx_pd.fcst_info->req_level_name())) match = false; - - else if( ( vx_pd.obs_info->req_level_name().nonempty() || - v.vx_pd.obs_info->req_level_name().nonempty()) && - !( vx_pd.obs_info->req_level_name() == - v.vx_pd.obs_info->req_level_name())) match = false; - + // Requested levels are optional for python embedding and may be empty. + // Check that several other config options also match. // // The following do not impact matched pairs: // fcat_ta, ocat_ta, @@ -759,20 +752,24 @@ bool PointStatVxOpt::is_uv_match(const PointStatVxOpt &v) const { // rank_corr_flag, output_flag // - else if(!(beg_ds == v.beg_ds ) || - !(end_ds == v.end_ds ) || - !(land_flag == v.land_flag ) || - !(topo_flag == v.topo_flag ) || - !(mask_grid == v.mask_grid ) || - !(mask_poly == v.mask_poly ) || - !(mask_sid == v.mask_sid ) || - !(mask_llpnt == v.mask_llpnt ) || - !(mask_name == v.mask_name ) || - !(interp_info == v.interp_info ) || - !(msg_typ == v.msg_typ ) || - !(duplicate_flag == v.duplicate_flag) || - !(obs_summary == v.obs_summary ) || - !(obs_perc == v.obs_perc )) match = false; + if(!is_req_level_match( vx_pd.fcst_info->req_level_name(), + v.vx_pd.fcst_info->req_level_name()) || + !is_req_level_match( vx_pd.obs_info->req_level_name(), + v.vx_pd.obs_info->req_level_name()) || + !(beg_ds == v.beg_ds ) || + !(end_ds == v.end_ds ) || + !(land_flag == v.land_flag ) || + !(topo_flag == v.topo_flag ) || + !(mask_grid == v.mask_grid ) || + !(mask_poly == v.mask_poly ) || + !(mask_sid == v.mask_sid ) || + !(mask_llpnt == v.mask_llpnt ) || + !(mask_name == v.mask_name ) || + !(interp_info == v.interp_info ) || + !(msg_typ == v.msg_typ ) || + !(duplicate_flag == v.duplicate_flag) || + !(obs_summary == v.obs_summary ) || + !(obs_perc == v.obs_perc )) match = false; return(match); }