diff --git a/src/tools/core/ensemble_stat/ensemble_stat.cc b/src/tools/core/ensemble_stat/ensemble_stat.cc index 6d3309289e..08e66db057 100644 --- a/src/tools/core/ensemble_stat/ensemble_stat.cc +++ b/src/tools/core/ensemble_stat/ensemble_stat.cc @@ -68,6 +68,7 @@ // 036 02/20/22 Halley Gotway MET #1259 Write probabilistic statistics. // 037 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main. // 038 09/06/22 Halley Gotway MET #1908 Remove ensemble processing logic. +// 039 09/29/22 Halley Gotway MET #2286 Refine GRIB1 table lookup logic. // //////////////////////////////////////////////////////////////////////// @@ -369,9 +370,6 @@ void process_command_line(int argc, char **argv) { // Store the input ensemble file type etype = ens_mtddf->file_type(); - // Use a variable index from var_name instead of GRIB code - bool use_var_id = false; - // Observation files are required if(!grid_obs_flag && !point_obs_flag) { mlog << Error << "\nprocess_command_line() -> " @@ -383,9 +381,6 @@ void process_command_line(int argc, char **argv) { // Determine the input observation file type if(point_obs_flag) { otype = FileType_Gb1; - if(point_obs_file_list.n() > 0) { - use_var_id = is_using_var_id(point_obs_file_list[0].c_str()); - } } else if(!grid_obs_flag) { otype = FileType_None; @@ -409,7 +404,7 @@ void process_command_line(int argc, char **argv) { // Process the configuration conf_info.process_config(etype, otype, grid_obs_flag, point_obs_flag, - use_var_id, &ens_file_list, ctrl_file.nonempty()); + &ens_file_list, ctrl_file.nonempty()); // Set output_nc_flag out_nc_flag = (grid_obs_flag && !conf_info.nc_info.all_false()); @@ -930,6 +925,7 @@ void process_point_obs(int i_nc) { } met_point_obs = met_point_file.get_met_point_data(); + use_var_id = met_point_file.is_using_var_id(); } else { #endif @@ -953,6 +949,9 @@ void process_point_obs(int i_nc) { } #endif + // Perform GRIB table lookups, if needed + if(!use_var_id) conf_info.process_grib_codes(); + int hdr_count = met_point_obs->get_hdr_cnt(); int obs_count = met_point_obs->get_obs_cnt(); diff --git a/src/tools/core/ensemble_stat/ensemble_stat_conf_info.cc b/src/tools/core/ensemble_stat/ensemble_stat_conf_info.cc index 29e32e881e..714906c100 100644 --- a/src/tools/core/ensemble_stat/ensemble_stat_conf_info.cc +++ b/src/tools/core/ensemble_stat/ensemble_stat_conf_info.cc @@ -65,6 +65,7 @@ void EnsembleStatConfInfo::clear() { // Initialize values model.clear(); + grib_codes_set = false; obtype.clear(); vld_ens_thresh = bad_data_double; vld_data_thresh = bad_data_double; @@ -116,7 +117,6 @@ void EnsembleStatConfInfo::read_config(const ConcatString default_file_name, void EnsembleStatConfInfo::process_config(GrdFileType etype, GrdFileType otype, bool grid_vx, bool point_vx, - bool use_var_id, StringArray * ens_files, bool use_ctrl) { int i, j, n_ens_files; @@ -276,8 +276,7 @@ void EnsembleStatConfInfo::process_config(GrdFileType etype, // Process the options for this verification task vx_opt[i].process_config(etype, i_fdict, otype, i_odict, - rng_ptr, grid_vx, point_vx, - use_var_id, ens_member_ids, + rng_ptr, grid_vx, point_vx, ens_member_ids, ens_files, use_ctrl, control_id); // For no point verification, store obtype as the message type @@ -306,6 +305,32 @@ void EnsembleStatConfInfo::process_config(GrdFileType etype, //////////////////////////////////////////////////////////////////////// +void EnsembleStatConfInfo::process_grib_codes() { + + // Only needs to be set once + if(grib_codes_set) return; + + mlog << Debug(3) << "Processing each \"" << conf_key_obs_field + << "\" name as a GRIB code abbreviation since the point " + << "observations are specified as GRIB codes.\n"; + + Dictionary *odict = conf.lookup_array(conf_key_obs_field); + Dictionary i_odict; + + // Add the GRIB code by parsing each observation dictionary + for(int i=0; iadd_grib_code(i_odict); + } + + // Flag to prevent processing more than once + grib_codes_set = true; + + return; +} + +//////////////////////////////////////////////////////////////////////// + void EnsembleStatConfInfo::process_flags() { int i, j; bool output_ascii_flag = false; @@ -609,8 +634,7 @@ void EnsembleStatVxOpt::clear() { void EnsembleStatVxOpt::process_config(GrdFileType ftype, Dictionary &fdict, GrdFileType otype, Dictionary &odict, - gsl_rng *rng_ptr, bool grid_vx, - bool point_vx, bool use_var_id, + gsl_rng *rng_ptr, bool grid_vx, bool point_vx, StringArray ens_member_ids, StringArray * ens_files, bool use_ctrl, ConcatString control_id) { @@ -679,9 +703,6 @@ void EnsembleStatVxOpt::process_config(GrdFileType ftype, Dictionary &fdict, // Set the VarInfo objects vx_pd.obs_info->set_dict(odict); - // Set the GRIB code for point observations - if(point_vx && !use_var_id) vx_pd.obs_info->add_grib_code(odict); - // Dump the contents of the current VarInfo if(mlog.verbosity_level() >= 5) { mlog << Debug(5) diff --git a/src/tools/core/ensemble_stat/ensemble_stat_conf_info.h b/src/tools/core/ensemble_stat/ensemble_stat_conf_info.h index a011b89fe4..7a14e4b761 100644 --- a/src/tools/core/ensemble_stat/ensemble_stat_conf_info.h +++ b/src/tools/core/ensemble_stat/ensemble_stat_conf_info.h @@ -144,7 +144,7 @@ class EnsembleStatVxOpt { void process_config(GrdFileType, Dictionary &, GrdFileType, Dictionary &, - gsl_rng *, bool, bool, bool, + gsl_rng *, bool, bool, StringArray, StringArray *, bool, ConcatString); void parse_nc_info(Dictionary &); @@ -213,6 +213,7 @@ class EnsembleStatConfInfo { ConcatString control_id; // Control ID EnsembleStatVxOpt * vx_opt; // Array of vx task options [n_vx] (allocated) + bool grib_codes_set; double vld_ens_thresh; // Required ratio of valid input files double vld_data_thresh; // Required ratio of valid data for each point @@ -242,8 +243,9 @@ class EnsembleStatConfInfo { void clear(); void read_config (const ConcatString , const ConcatString); - void process_config(GrdFileType, GrdFileType, bool, bool, bool, + void process_config(GrdFileType, GrdFileType, bool, bool, StringArray *, bool); + void process_grib_codes(); void process_flags (); void process_masks (const Grid &); void set_vx_pd (const IntArray &, int);