Skip to content

Commit

Permalink
Per #1735, since we are writing multiple output line types to the sam…
Browse files Browse the repository at this point in the history
…e .stat file, adding stat_row counter to the job class. This way all functions that write to it can increment that row counter when needed.
  • Loading branch information
JohnHalleyGotway committed Apr 13, 2021
1 parent 9c013da commit 4042559
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
25 changes: 21 additions & 4 deletions met/src/libcode/vx_analysis_util/stat_job.cc
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ void STATAnalysisJob::clear() {
if(dump_row) { delete [] dump_row; dump_row = (char *) 0; }
if(stat_file) { delete [] stat_file; stat_file = (char *) 0; }

stat_row = 0;

out_line_type.clear();

out_fcst_thresh.clear();
Expand Down Expand Up @@ -307,8 +309,8 @@ void STATAnalysisJob::assign(const STATAnalysisJob & aj) {
wmo_fisher_stats = aj.wmo_fisher_stats;

column_thresh_map = aj.column_thresh_map;
column_str_inc_map = aj.column_str_inc_map;
column_str_exc_map = aj.column_str_exc_map;
column_str_inc_map = aj.column_str_inc_map;
column_str_exc_map = aj.column_str_exc_map;

by_column = aj.by_column;

Expand Down Expand Up @@ -354,6 +356,8 @@ void STATAnalysisJob::assign(const STATAnalysisJob & aj) {
mask_poly = aj.mask_poly;
mask_sid = aj.mask_sid;

stat_row = aj.stat_row;

set_dump_row (aj.dump_row);
set_stat_file(aj.stat_file);

Expand Down Expand Up @@ -1880,6 +1884,8 @@ void STATAnalysisJob::open_stat_file() {

close_stat_file();

stat_row = 0;

if(!stat_file) return;

stat_out = new ofstream;
Expand All @@ -1904,9 +1910,10 @@ void STATAnalysisJob::setup_stat_file(int n_row, int n) {
int i, c, n_col;

//
// Nothing to do unless output STAT file stream is defined
// Nothing to do if no output STAT file stream is defined
// or if the output table has already been setup
//
if(!stat_out) return;
if(!stat_out || stat_at.nrows() > 0) return;

//
// Check for a single output line type
Expand All @@ -1916,6 +1923,11 @@ void STATAnalysisJob::setup_stat_file(int n_row, int n) {
out_lt = (out_sa.n() == 1 ?
string_to_statlinetype(out_sa[0].c_str()) : no_stat_line_type);

//
// Multiply number of rows by the number of output line types
//
n_row *= out_sa.n();

//
// Loop through the output line types and determine the number of
// output columns
Expand Down Expand Up @@ -2029,6 +2041,11 @@ void STATAnalysisJob::setup_stat_file(int n_row, int n) {
break;
}

//
// Initialize the stat row counter after writing the header line
//
stat_row = 1;

return;
}

Expand Down
1 change: 1 addition & 0 deletions met/src/libcode/vx_analysis_util/stat_job.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ class STATAnalysisJob {
char *stat_file; // dump output statistics to a STAT file
ofstream *stat_out; // output file stream for -out_stat
AsciiTable stat_at; // AsciiTable for buffering output STAT data
int stat_row; // Counter for the current stat row

StringArray out_line_type; // output line types
ThreshArray out_fcst_thresh; // output forecast threshold(s)
Expand Down

0 comments on commit 4042559

Please sign in to comment.