Skip to content

Commit

Permalink
Per #2366, move the checking of requested levels into the is_uv_match…
Browse files Browse the repository at this point in the history
…() function. Only enforce this check if the requested levels are non-empty. Note that they ARE empty for python embedding.
  • Loading branch information
JohnHalleyGotway committed Dec 5, 2022
1 parent 72a5273 commit 9ab9091
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 46 deletions.
40 changes: 22 additions & 18 deletions src/tools/core/grid_stat/grid_stat_conf_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,8 @@ void GridStatConfInfo::process_config(GrdFileType ftype,

// Search for corresponding v-wind
for(j=0; j<n_vx; j++) {
if(vx_opt[j].fcst_info->is_v_wind() &&
vx_opt[j].obs_info->is_v_wind() &&
vx_opt[i].fcst_info->req_level_name() ==
vx_opt[j].fcst_info->req_level_name() &&
vx_opt[i].obs_info->req_level_name() ==
vx_opt[j].obs_info->req_level_name() &&
if(vx_opt[j].fcst_info->is_v_wind() &&
vx_opt[j].obs_info->is_v_wind() &&
vx_opt[i].is_uv_match(vx_opt[j])) {

vx_opt[i].fcst_info->set_uv_index(j);
Expand All @@ -204,12 +200,8 @@ void GridStatConfInfo::process_config(GrdFileType ftype,

// Search for corresponding u-wind
for(j=0; j<n_vx; j++) {
if(vx_opt[j].fcst_info->is_u_wind() &&
vx_opt[j].obs_info->is_u_wind() &&
vx_opt[i].fcst_info->req_level_name() ==
vx_opt[j].fcst_info->req_level_name() &&
vx_opt[i].obs_info->req_level_name() ==
vx_opt[j].obs_info->req_level_name() &&
if(vx_opt[j].fcst_info->is_u_wind() &&
vx_opt[j].obs_info->is_u_wind() &&
vx_opt[i].is_uv_match(vx_opt[j])) {

vx_opt[i].fcst_info->set_uv_index(j);
Expand Down Expand Up @@ -904,6 +896,20 @@ void GridStatVxOpt::parse_nc_info(Dictionary &odict) {
bool GridStatVxOpt::is_uv_match(const GridStatVxOpt &v) const {
bool match = true;

//
// 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;

//
// The following do not impact matched pairs:
// desc, var_name, var_suffix,
Expand All @@ -917,12 +923,10 @@ bool GridStatVxOpt::is_uv_match(const GridStatVxOpt &v) const {
// hss_ec_value, rank_corr_flag, output_flag, nc_info
//

if(!(mask_grid == v.mask_grid ) ||
!(mask_poly == v.mask_poly ) ||
!(mask_name == v.mask_name ) ||
!(interp_info == v.interp_info)) {
match = false;
}
else if(!(mask_grid == v.mask_grid ) ||
!(mask_poly == v.mask_poly ) ||
!(mask_name == v.mask_name ) ||
!(interp_info == v.interp_info)) match = false;

return(match);
}
Expand Down
60 changes: 32 additions & 28 deletions src/tools/core/point_stat/point_stat_conf_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,8 @@ void PointStatConfInfo::process_config(GrdFileType ftype) {

// Search for corresponding v-wind
for(j=0; j<n_vx; j++) {
if(vx_opt[j].vx_pd.fcst_info->is_v_wind() &&
vx_opt[j].vx_pd.obs_info->is_v_wind() &&
vx_opt[i].vx_pd.fcst_info->req_level_name() ==
vx_opt[j].vx_pd.fcst_info->req_level_name() &&
vx_opt[i].vx_pd.obs_info->req_level_name() ==
vx_opt[j].vx_pd.obs_info->req_level_name() &&
if(vx_opt[j].vx_pd.fcst_info->is_v_wind() &&
vx_opt[j].vx_pd.obs_info->is_v_wind() &&
vx_opt[i].is_uv_match(vx_opt[j])) {

vx_opt[i].vx_pd.fcst_info->set_uv_index(j);
Expand All @@ -198,12 +194,8 @@ void PointStatConfInfo::process_config(GrdFileType ftype) {

// Search for corresponding u-wind
for(j=0; j<n_vx; j++) {
if(vx_opt[j].vx_pd.fcst_info->is_u_wind() &&
vx_opt[j].vx_pd.obs_info->is_u_wind() &&
vx_opt[i].vx_pd.fcst_info->req_level_name() ==
vx_opt[j].vx_pd.fcst_info->req_level_name() &&
vx_opt[i].vx_pd.obs_info->req_level_name() ==
vx_opt[j].vx_pd.obs_info->req_level_name() &&
if(vx_opt[j].vx_pd.fcst_info->is_u_wind() &&
vx_opt[j].vx_pd.obs_info->is_u_wind() &&
vx_opt[i].is_uv_match(vx_opt[j])) {

vx_opt[i].vx_pd.fcst_info->set_uv_index(j);
Expand Down Expand Up @@ -704,6 +696,20 @@ void PointStatVxOpt::clear() {
bool PointStatVxOpt::is_uv_match(const PointStatVxOpt &v) const {
bool match = true;

//
// 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;

//
// The following do not impact matched pairs:
// fcat_ta, ocat_ta,
Expand All @@ -714,22 +720,20 @@ bool PointStatVxOpt::is_uv_match(const PointStatVxOpt &v) const {
// rank_corr_flag, output_flag
//

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;
}
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;

return(match);
}
Expand Down

0 comments on commit 9ab9091

Please sign in to comment.