Skip to content

Commit

Permalink
Per #1746, a bit of code cleanup replacing calls to n_elements() with…
Browse files Browse the repository at this point in the history
… n() to make the code more concise.
  • Loading branch information
JohnHalleyGotway committed Jul 15, 2021
1 parent abd2a34 commit 8650b74
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
14 changes: 7 additions & 7 deletions met/src/tools/core/wavelet_stat/wavelet_stat.cc
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ void process_scores() {
// Allocate memory for ISCInfo objects sized as [n_tile][n_thresh]
isc_info = new ISCInfo * [conf_info.get_n_tile()];
for(j=0; j<conf_info.get_n_tile(); j++) {
isc_info[j] = new ISCInfo [conf_info.fcat_ta[i].n_elements()];
isc_info[j] = new ISCInfo [conf_info.fcat_ta[i].n()];
}

// Process percentile thresholds
Expand All @@ -444,7 +444,7 @@ void process_scores() {
do_intensity_scale(f_na, o_na, isc_info[j], i, j);

// Write out the ISC statistics
for(k=0; k<conf_info.fcat_ta[i].n_elements(); k++) {
for(k=0; k<conf_info.fcat_ta[i].n(); k++) {

// Store the tile definition parameters
isc_info[j][k].tile_dim = conf_info.get_tile_dim();
Expand All @@ -468,7 +468,7 @@ void process_scores() {
// Set the mask name
shc.set_mask("TILE_TOT");

for(j=0; j<conf_info.fcat_ta[i].n_elements(); j++) {
for(j=0; j<conf_info.fcat_ta[i].n(); j++) {

// Set the forecast and observation thresholds
shc.set_fcst_thresh(conf_info.fcat_ta[i][j]);
Expand Down Expand Up @@ -944,8 +944,8 @@ void do_intensity_scale(const NumArray &f_na, const NumArray &o_na,
int apply_obs_thresh = 1;

// Check the NumArray lengths
n = f_na.n_elements();
if(n != o_na.n_elements()) {
n = f_na.n();
if(n != o_na.n()) {
mlog << Error << "\ndo_intensity_scale() -> "
<< "the forecast and observation arrays must have equal "
<< "length.\n\n";
Expand All @@ -966,7 +966,7 @@ void do_intensity_scale(const NumArray &f_na, const NumArray &o_na,
ns = conf_info.get_n_scale();

// Set up the ISCInfo thresholds and n_scale
n_isc = conf_info.fcat_ta[i_vx].n_elements();
n_isc = conf_info.fcat_ta[i_vx].n();
for(i=0; i<n_isc; i++) {
isc_info[i].clear();
isc_info[i].fthresh = conf_info.fcat_ta[i_vx][i];
Expand Down Expand Up @@ -995,7 +995,7 @@ 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++) {
for(i=0; i<conf_info.fcat_ta[i_vx].n(); i++) {

fcst_thresh_str = isc_info[i].fthresh.get_abbr_str();
obs_thresh_str = isc_info[i].othresh.get_abbr_str();
Expand Down
14 changes: 7 additions & 7 deletions met/src/tools/core/wavelet_stat/wavelet_stat_conf_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -256,20 +256,20 @@ void WaveletStatConfInfo::process_config(GrdFileType ftype,

// 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) {
if(fcat_ta[i].n() == 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) {
if(ocat_ta[i].n() == 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()) {
if(fcat_ta[i].n() != ocat_ta[i].n()) {
mlog << Error << "\nWaveletStatConfInfo::process_config() -> "
<< "The number of thresholds for each field in \"fcst."
<< conf_key_cat_thresh
Expand All @@ -290,7 +290,7 @@ void WaveletStatConfInfo::process_config(GrdFileType ftype,
}

// Keep track of the maximum number of thresholds
if(fcat_ta[i].n_elements() > max_n_thresh) max_n_thresh = fcat_ta[i].n_elements();
if(fcat_ta[i].n() > max_n_thresh) max_n_thresh = fcat_ta[i].n();

} // end for i

Expand Down Expand Up @@ -532,7 +532,7 @@ void WaveletStatConfInfo::process_tiles(const Grid &grid) {
case(GridDecompType_Tile):

// Number of tiles based on the user-specified locations
n_tile = tile_xll.n_elements();
n_tile = tile_xll.n();

msg << "\nTiling Method: Apply " << n_tile
<< " tile(s) specified in the configuration file "
Expand Down Expand Up @@ -668,9 +668,9 @@ int WaveletStatConfInfo::n_isc_row() {
// Compute the number of output lines for each verification field
for(i=0,n=0; i<n_vx; i++) {

n += (n_scale + 2) * fcat_ta[i].n_elements() * n_tile;
n += (n_scale + 2) * fcat_ta[i].n() * n_tile;

if(n_tile > 1) n += (n_scale + 2) * fcat_ta[i].n_elements();
if(n_tile > 1) n += (n_scale + 2) * fcat_ta[i].n();
}

return(n);
Expand Down

0 comments on commit 8650b74

Please sign in to comment.