Skip to content

Commit

Permalink
Per #2286, port this fix in the logic over from the Point-Stat code t…
Browse files Browse the repository at this point in the history
…o Ensemble-Stat when verifying against point observations.
  • Loading branch information
JohnHalleyGotway committed Sep 30, 2022
1 parent 891b319 commit 6193e1b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 17 deletions.
13 changes: 6 additions & 7 deletions src/tools/core/ensemble_stat/ensemble_stat.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//
////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -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() -> "
Expand All @@ -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;
Expand All @@ -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());
Expand Down Expand Up @@ -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
Expand All @@ -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();

Expand Down
37 changes: 29 additions & 8 deletions src/tools/core/ensemble_stat/ensemble_stat_conf_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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; i<n_vx; i++) {
i_odict = parse_conf_i_vx_dict(odict, i);
vx_opt[i].vx_pd.obs_info->add_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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions src/tools/core/ensemble_stat/ensemble_stat_conf_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 &);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 6193e1b

Please sign in to comment.