From d520fef7876e615e94cc28cc3bc9126aa94af4c4 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Thu, 10 Oct 2024 15:47:15 +0000 Subject: [PATCH] Per #2279, add point_weight_flag to the Point-Stat and Ensemble-Stat config class. Also remove sue unneeded wgt_dp argument for the add_point_obs() functions. Plan to add logic to set the point weights only AFTER all the observations have been collected for each verification task. --- src/basic/vx_util/util_constants.h | 2 +- src/libcode/vx_statistics/apply_mask.cc | 2 +- src/libcode/vx_statistics/pair_base.h | 10 +++++---- .../vx_statistics/pair_data_ensemble.cc | 10 ++------- .../vx_statistics/pair_data_ensemble.h | 2 +- src/libcode/vx_statistics/pair_data_point.cc | 18 ++++----------- src/libcode/vx_statistics/pair_data_point.h | 16 +++++++------- .../ensemble_stat/ensemble_stat_conf_info.cc | 5 ++++- .../ensemble_stat/ensemble_stat_conf_info.h | 5 +++-- src/tools/core/grid_stat/grid_stat.cc | 2 +- .../core/point_stat/point_stat_conf_info.cc | 4 ++++ .../core/point_stat/point_stat_conf_info.h | 2 ++ .../core/series_analysis/series_analysis.cc | 2 +- .../core/stat_analysis/aggr_stat_line.cc | 22 +++++++++---------- .../core/stat_analysis/parse_stat_line.cc | 1 - src/tools/other/gsi_tools/gsidens2orank.cc | 4 ++-- 16 files changed, 51 insertions(+), 56 deletions(-) diff --git a/src/basic/vx_util/util_constants.h b/src/basic/vx_util/util_constants.h index e2520efd18..c24ffdec88 100644 --- a/src/basic/vx_util/util_constants.h +++ b/src/basic/vx_util/util_constants.h @@ -102,7 +102,7 @@ static const int tmp_buf_size = 512; static const double grib_earth_radius_km = 6371.20; static const int default_nc_compression = 0; static const int default_precision = 5; -static const double default_grid_weight = 1.0; +static const double default_weight = 1.0; static const char default_tmp_dir[] = "/tmp"; //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_statistics/apply_mask.cc b/src/libcode/vx_statistics/apply_mask.cc index c299d8d3d0..3777adc5f0 100644 --- a/src/libcode/vx_statistics/apply_mask.cc +++ b/src/libcode/vx_statistics/apply_mask.cc @@ -138,7 +138,7 @@ void parse_grid_weight(const Grid &grid, const GridWeightType t, w = grid.calc_area(x, y); } else { - w = default_grid_weight; + w = default_weight; } // Store the current weight diff --git a/src/libcode/vx_statistics/pair_base.h b/src/libcode/vx_statistics/pair_base.h index 37a7244635..f928a4cd4b 100644 --- a/src/libcode/vx_statistics/pair_base.h +++ b/src/libcode/vx_statistics/pair_base.h @@ -173,12 +173,14 @@ class PairBase { const ClimoPntInfo &, double); void set_point_obs(int, const char *, double, double, double, double, - unixtime, double, double, double, - const char *, const ClimoPntInfo &, double); + unixtime, double, double, double, const char *, + const ClimoPntInfo &, double); - void add_grid_obs(double, const ClimoPntInfo &, double); + void add_grid_obs(double, + const ClimoPntInfo &, double); - void add_grid_obs(double, double, double, const ClimoPntInfo &, double); + void add_grid_obs(double, double, double, + const ClimoPntInfo &, double); void add_climo(double, const ClimoPntInfo &); diff --git a/src/libcode/vx_statistics/pair_data_ensemble.cc b/src/libcode/vx_statistics/pair_data_ensemble.cc index af9f80de15..62cd93b688 100644 --- a/src/libcode/vx_statistics/pair_data_ensemble.cc +++ b/src/libcode/vx_statistics/pair_data_ensemble.cc @@ -1170,8 +1170,7 @@ void VxPairDataEnsemble::add_point_obs(float *hdr_arr, int *hdr_typ_arr, const char *hdr_sid_str, unixtime hdr_ut, const char *obs_qty, float *obs_arr, - Grid &gr, const char *var_name, - const DataPlane *wgt_dp) { + Grid &gr, const char *var_name) { // Check the observation VarInfo file type if(obs_info->file_type() != FileType_Gb1) { @@ -1303,17 +1302,12 @@ void VxPairDataEnsemble::add_point_obs(float *hdr_arr, int *hdr_typ_arr, gr, obs_x, obs_y, obs_v, obs_lvl, obs_hgt, cpi)) continue; - // Compute weight for current point - double wgt_v = (wgt_dp == nullptr ? - default_grid_weight : - wgt_dp->get(x, y)); - // Add the observation value // Weight is from the nearest grid point int n = three_to_one(i_msg_typ, i_mask, i_interp); if(!pd[n].add_point_obs(hdr_sid_str, hdr_lat, hdr_lon, obs_x, obs_y, hdr_ut, obs_lvl, obs_hgt, - obs_v, obs_qty, cpi, wgt_v)) { + obs_v, obs_qty, cpi, default_weight)) { if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { mlog << Debug(REJECT_DEBUG_LEVEL) diff --git a/src/libcode/vx_statistics/pair_data_ensemble.h b/src/libcode/vx_statistics/pair_data_ensemble.h index f621c23abf..fa44ea77b1 100644 --- a/src/libcode/vx_statistics/pair_data_ensemble.h +++ b/src/libcode/vx_statistics/pair_data_ensemble.h @@ -217,7 +217,7 @@ class VxPairDataEnsemble : public VxPairBase { void add_point_obs(float *, int *, const char *, const char *, unixtime, const char *, float *, Grid &, - const char * = 0, const DataPlane * = 0); + const char *); void add_ens(int, bool mn, Grid &); }; diff --git a/src/libcode/vx_statistics/pair_data_point.cc b/src/libcode/vx_statistics/pair_data_point.cc index a22194a297..304e91c8d1 100644 --- a/src/libcode/vx_statistics/pair_data_point.cc +++ b/src/libcode/vx_statistics/pair_data_point.cc @@ -503,8 +503,7 @@ void VxPairDataPoint::set_size(int types, int masks, int interps) { void VxPairDataPoint::add_point_obs(float *hdr_arr, const char *hdr_typ_str, const char *hdr_sid_str, unixtime hdr_ut, const char *obs_qty, float *obs_arr, - Grid &gr, const char *var_name, - const DataPlane *wgt_dp) { + Grid &gr, const char *var_name) { // Increment the number of tries count n_try++; @@ -553,11 +552,7 @@ void VxPairDataPoint::add_point_obs(float *hdr_arr, const char *hdr_typ_str, obs_info->is_specific_humidity(); bool precip_flag = fcst_info->is_precipitation() && obs_info->is_precipitation(); - int precip_interval = bad_data_int; - if(precip_flag) { - if(wgt_dp) precip_interval = wgt_dp->accum(); - else precip_interval = fcst_dpa[0].accum(); - } + int precip_interval = fcst_dpa[0].accum(); bool has_seeps = false; SeepsScore *seeps = nullptr; @@ -623,17 +618,12 @@ void VxPairDataPoint::add_point_obs(float *hdr_arr, const char *hdr_typ_str, continue; } - // Compute weight for current point - double wgt_v = (wgt_dp == nullptr ? - default_grid_weight : - wgt_dp->get(x, y)); - // Add the forecast, climatological, and observation data // Weight is from the nearest grid point int n = three_to_one(i_msg_typ, i_mask, i_interp); if(!pd[n].add_point_pair(hdr_sid_str, hdr_lat, hdr_lon, obs_x, obs_y, hdr_ut, obs_lvl, - obs_hgt, fcst_v, obs_v, obs_qty, cpi, wgt_v)) { + obs_hgt, fcst_v, obs_v, obs_qty, cpi, default_weight)) { if(mlog.verbosity_level() >= REJECT_DEBUG_LEVEL) { mlog << Debug(REJECT_DEBUG_LEVEL) @@ -954,7 +944,7 @@ void subset_wind_pairs(const PairDataPoint &pd_u, const PairDataPoint &pd_v, // Loop over the pairs for(i=0; i mask_sid_map; + PointWeightType point_weight_flag; // Point weighting flag + ConcatString tmp_dir; // Directory for temporary files ConcatString output_prefix; // String to customize output file name ConcatString version; // Config file version diff --git a/src/tools/core/series_analysis/series_analysis.cc b/src/tools/core/series_analysis/series_analysis.cc index fa2d4a8ef7..0511217fe9 100644 --- a/src/tools/core/series_analysis/series_analysis.cc +++ b/src/tools/core/series_analysis/series_analysis.cc @@ -970,7 +970,7 @@ void process_scores() { (ocsd_flag ? ocsd_dp(x, y) : bad_data_double)); pd_block[i].add_grid_pair(fcst_dp(x, y), obs_dp(x, y), - cpi, default_grid_weight); + cpi, default_weight); } // end for i } // end for i_series diff --git a/src/tools/core/stat_analysis/aggr_stat_line.cc b/src/tools/core/stat_analysis/aggr_stat_line.cc index 8f34490a0b..ba2a37d3db 100644 --- a/src/tools/core/stat_analysis/aggr_stat_line.cc +++ b/src/tools/core/stat_analysis/aggr_stat_line.cc @@ -1727,8 +1727,8 @@ void aggr_wind_lines(LineDataFile &f, STATAnalysisJob &job, // Append the unit vectors with no climatological values // ClimoPntInfo cpi; - m[key].pd_u.add_grid_pair(uf, uo, cpi, default_grid_weight); - m[key].pd_v.add_grid_pair(vf, vo, cpi, default_grid_weight); + m[key].pd_u.add_grid_pair(uf, uo, cpi, default_weight); + m[key].pd_v.add_grid_pair(vf, vo, cpi, default_weight); // // Keep track of the unique header column entries @@ -1843,8 +1843,8 @@ void aggr_mpr_wind_lines(LineDataFile &f, STATAnalysisJob &job, aggr.hdr_sa.add(hdr); ClimoPntInfo u_cpi(ufcmn, ufcsd, uocmn, uocsd); ClimoPntInfo v_cpi(vfcmn, vfcsd, vocmn, vocsd); - aggr.pd_u.add_grid_pair(uf, uo, u_cpi, default_grid_weight); - aggr.pd_v.add_grid_pair(vf, vo, v_cpi, default_grid_weight); + aggr.pd_u.add_grid_pair(uf, uo, u_cpi, default_weight); + aggr.pd_v.add_grid_pair(vf, vo, v_cpi, default_weight); // // Add the new map entry @@ -1908,8 +1908,8 @@ void aggr_mpr_wind_lines(LineDataFile &f, STATAnalysisJob &job, m[key].hdr_sa.add(hdr); ClimoPntInfo u_cpi(ufcmn, ufcsd, uocmn, uocsd); ClimoPntInfo v_cpi(vfcmn, vfcsd, vocmn, vocsd); - m[key].pd_u.add_grid_pair(uf, uo, u_cpi, default_grid_weight); - m[key].pd_v.add_grid_pair(vf, vo, v_cpi, default_grid_weight); + m[key].pd_u.add_grid_pair(uf, uo, u_cpi, default_weight); + m[key].pd_v.add_grid_pair(vf, vo, v_cpi, default_weight); } } @@ -2054,8 +2054,8 @@ void aggr_mpr_wind_lines(LineDataFile &f, STATAnalysisJob &job, it->second.pd_v.f_na[i], uf, vf); convert_u_v_to_unit(it->second.pd_u.o_na[i], it->second.pd_v.o_na[i], uo, vo); - aggr.pd_u.add_grid_pair(uf, uo, cpi, default_grid_weight); - aggr.pd_v.add_grid_pair(vf, vo, cpi, default_grid_weight); + aggr.pd_u.add_grid_pair(uf, uo, cpi, default_weight); + aggr.pd_v.add_grid_pair(vf, vo, cpi, default_weight); } // @@ -2137,7 +2137,7 @@ void aggr_mpr_lines(LineDataFile &f, STATAnalysisJob &job, aggr.pd.ocmn_na.add(cur.obs_climo_mean); aggr.pd.ocsd_na.add(cur.obs_climo_stdev); aggr.pd.ocdf_na.add(cur.obs_climo_cdf); - aggr.pd.wgt_na.add(default_grid_weight); + aggr.pd.wgt_na.add(default_weight); aggr.fcst_var = cur.fcst_var; aggr.obs_var = cur.obs_var; @@ -2168,7 +2168,7 @@ void aggr_mpr_lines(LineDataFile &f, STATAnalysisJob &job, m[key].pd.ocmn_na.add(cur.obs_climo_mean); m[key].pd.ocsd_na.add(cur.obs_climo_stdev); m[key].pd.ocdf_na.add(cur.obs_climo_cdf); - m[key].pd.wgt_na.add(default_grid_weight); + m[key].pd.wgt_na.add(default_weight); // // Only aggregate consistent variable names @@ -3065,7 +3065,7 @@ void aggr_orank_lines(LineDataFile &f, STATAnalysisJob &job, // ClimoPntInfo cpi(cur.fcst_climo_mean, cur.fcst_climo_stdev, cur.obs_climo_mean, cur.obs_climo_stdev); - m[key].ens_pd.add_grid_obs(cur.obs, cpi, default_grid_weight); + m[key].ens_pd.add_grid_obs(cur.obs, cpi, default_weight); m[key].ens_pd.skip_ba.add(false); m[key].ens_pd.n_pair++; m[key].ens_pd.r_na.add(cur.rank); diff --git a/src/tools/core/stat_analysis/parse_stat_line.cc b/src/tools/core/stat_analysis/parse_stat_line.cc index 501365dd88..16bd880e17 100644 --- a/src/tools/core/stat_analysis/parse_stat_line.cc +++ b/src/tools/core/stat_analysis/parse_stat_line.cc @@ -61,7 +61,6 @@ void parse_fho_ctable(STATLine &l, TTContingencyTable &ct) { double h_rate = atof(l.get_item("H_RATE")); double o_rate = atof(l.get_item("O_RATE")); - // MET #2887: JHG multiple by the sum of the weights here instead? double fy = n_pairs * f_rate; double fy_oy = n_pairs * h_rate; double oy = n_pairs * o_rate; diff --git a/src/tools/other/gsi_tools/gsidens2orank.cc b/src/tools/other/gsi_tools/gsidens2orank.cc index 39edb87cc5..31aa675774 100644 --- a/src/tools/other/gsi_tools/gsidens2orank.cc +++ b/src/tools/other/gsi_tools/gsidens2orank.cc @@ -271,7 +271,7 @@ void process_conv_data(ConvData &d, int i_mem) { bad_data_double, bad_data_double); ens_pd.add_point_obs(d.sid.c_str(), d.lat, d.lon, bad_data_double, bad_data_double, d.obs_ut, d.prs, - d.elv, d.obs, na_str, cpi, default_grid_weight); + d.elv, d.obs, na_str, cpi, default_weight); // Initialize ensemble members and mean to bad data for(i=0; i