Skip to content

Commit

Permalink
For issue #1746 modified code to allow users to pass in an empty list…
Browse files Browse the repository at this point in the history
… (or NA) for forecast and observation thresholds in order to skip applying the threhsolds, but it will still compute stats with the raw fields. SL
  • Loading branch information
Seth Linden committed Jul 8, 2021
1 parent d2bad01 commit 653a3fe
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 7 deletions.
30 changes: 24 additions & 6 deletions met/src/tools/core/wavelet_stat/wavelet_stat.cc
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ void process_scores() {
shc.set_fcst_thresh(conf_info.fcat_ta[i][k]);
shc.set_obs_thresh(conf_info.ocat_ta[i][k]);

write_isc_row(shc, isc_info[j][k],
write_isc_row(shc, isc_info[j][k],
conf_info.output_flag[i_isc],
stat_at, i_stat_row, isc_at, i_isc_row);
} // end for k
Expand Down Expand Up @@ -939,6 +939,9 @@ void do_intensity_scale(const NumArray &f_na, const NumArray &o_na,
int i, j, k;
ConcatString fcst_thresh_str, obs_thresh_str;

int apply_fcst_thresh = 1;
int apply_obs_thresh = 1;

// Check the NumArray lengths
n = f_na.n_elements();
if(n != o_na.n_elements()) {
Expand Down Expand Up @@ -992,10 +995,22 @@ void do_intensity_scale(const NumArray &f_na, const NumArray &o_na,

// Apply each threshold
for(i=0; i<conf_info.fcat_ta[i_vx].n_elements(); i++) {

fcst_thresh_str = isc_info[i].fthresh.get_abbr_str();
obs_thresh_str = isc_info[i].othresh.get_abbr_str();

// If the forecast threshold is set to NA skip masking below
if(isc_info[i].fthresh.get_type() == thresh_na) {
mlog << Debug(2) << "The forecast threshold is NA (missing), skipping applying threshold" << "\n";
apply_fcst_thresh = 0;
}

// If the observation threshold is set to NA skip masking below
if(isc_info[i].othresh.get_type() == thresh_na) {
mlog << Debug(2) << "The observation threshold is NA (missing), skipping applying threshold" << "\n";
apply_obs_thresh = 0;
}

mlog << Debug(2) << "Computing Intensity-Scale decomposition for "
<< conf_info.fcst_info[i_vx]->magic_str() << " "
<< fcst_thresh_str << " versus "
Expand All @@ -1004,11 +1019,14 @@ void do_intensity_scale(const NumArray &f_na, const NumArray &o_na,

// Apply the threshold to each point to create 0/1 mask fields
for(j=0; j<n; j++) {
f_dat[j] = isc_info[i].fthresh.check(f_na[j]);
o_dat[j] = isc_info[i].othresh.check(o_na[j]);
diff[j] = f_dat[j] - o_dat[j];
if(apply_fcst_thresh)
f_dat[j] = isc_info[i].fthresh.check(f_na[j]);
if(apply_obs_thresh)
o_dat[j] = isc_info[i].othresh.check(o_na[j]);

diff[j] = f_dat[j] - o_dat[j];
} // end for j

// Compute the contingency table for the binary fields
compute_cts(f_dat, o_dat, n, isc_info[i]);

Expand Down
19 changes: 18 additions & 1 deletion met/src/tools/core/wavelet_stat/wavelet_stat_conf_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ void WaveletStatConfInfo::process_config(GrdFileType ftype,
Dictionary i_fdict, i_odict;
gsl_wavelet_type type;

SingleThresh st_NA;
st_NA.set_na();

// Dump the contents of the config file
if(mlog.verbosity_level() >= 5) conf.dump(cout);

Expand Down Expand Up @@ -250,7 +253,21 @@ void WaveletStatConfInfo::process_config(GrdFileType ftype,
<< "Forecast categorical thresholds: " << fcat_ta[i].get_str() << "\n"
<< "Observed categorical thresholds: " << ocat_ta[i].get_str() << "\n";
}


// If the forecast threshold array is an empty list (or NA)
// Add the NA threshold type to the list for downstream iteration
if(fcat_ta[i].n_elements() == 0) {
mlog << Debug(2) << "Found empty list for forecast threshold, setting threshold type to NA" << "\n";
fcat_ta[i].add(st_NA);
}

// If the observation threshold array is an empty list (or NA)
// Add the NA threshold type to the list for downstream iteration
if(ocat_ta[i].n_elements() == 0) {
mlog << Debug(2) << "Found empty list for observation threshold, setting threshold type to NA" << "\n";
ocat_ta[i].add(st_NA);
}

// Check for the same number of fcst and obs thresholds
if(fcat_ta[i].n_elements() != ocat_ta[i].n_elements()) {

Expand Down

0 comments on commit 653a3fe

Please sign in to comment.