Skip to content

Commit

Permalink
Per #1954, add NumArray::summarize() function and update the SemiLatL…
Browse files Browse the repository at this point in the history
…on code to use it when dumping info about the grid. Dumping all of the lat/lon values clutters the log output way too much.
  • Loading branch information
JohnHalleyGotway committed Aug 19, 2022
1 parent 76dafdb commit 95d9bdf
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
30 changes: 30 additions & 0 deletions src/basic/vx_util/num_array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,36 @@ ConcatString NumArray::serialize() const
////////////////////////////////////////////////////////////////////////


ConcatString NumArray::summarize() const

{

ConcatString s;

s << "n = " << n_elements();

if(n_elements() > 0) {

double min_v, max_v;
min_v = max_v = e[0];

for(int j=0; j<n_elements(); j++) {
if(is_bad_data(e[j])) continue;
if(e[j] < min_v) min_v = e[j];
if(e[j] > max_v) max_v = e[j];
}

s << ", min = " << min_v << ", max = " << max_v;
}

return(s);

}


////////////////////////////////////////////////////////////////////////


NumArray NumArray::subset(int beg, int end) const

{
Expand Down
1 change: 1 addition & 0 deletions src/basic/vx_util/num_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class NumArray {
double range() const;

ConcatString serialize() const;
ConcatString summarize() const;

int n_elements() const;
int n() const; // same as n_elements()
Expand Down
8 changes: 4 additions & 4 deletions src/libcode/vx_grid/grid_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,10 @@ void SemiLatLonData::dump()

mlog << Debug(grid_debug_level)
<< "\nSemiLatLon Grid Data:\n"
<< " lats: " << lats.serialize() << "\n"
<< " lons: " << lons.serialize() << "\n"
<< " levels: " << levels.serialize() << "\n"
<< " times: " << times.serialize() << "\n\n";
<< " lats: " << lats.summarize() << "\n"
<< " lons: " << lons.summarize() << "\n"
<< " levels: " << levels.summarize() << "\n"
<< " times: " << times.summarize() << "\n\n";
}


Expand Down

0 comments on commit 95d9bdf

Please sign in to comment.