From ee74821d1d9270733401e81c949e95d502691fc4 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Fri, 4 Feb 2022 19:25:14 -0700 Subject: [PATCH] Per #1055, ci-run-unit, update the Grid::serialize() member functions to let the caller specify the separator string, with a single space as the default. Write retriving a gridded data plane, also write out it's grid information. --- met/src/libcode/vx_data2d/data_class.cc | 18 +++++++++------- met/src/libcode/vx_grid/gaussian_grid.cc | 8 ++++---- met/src/libcode/vx_grid/gaussian_grid.h | 2 +- met/src/libcode/vx_grid/goes_grid.cc | 8 ++++---- met/src/libcode/vx_grid/goes_grid.h | 2 +- met/src/libcode/vx_grid/grid_base.cc | 4 ++-- met/src/libcode/vx_grid/grid_base.h | 4 ++-- met/src/libcode/vx_grid/latlon_grid.cc | 18 ++++++++-------- met/src/libcode/vx_grid/latlon_grid.h | 2 +- met/src/libcode/vx_grid/lc_grid.cc | 22 ++++++++++---------- met/src/libcode/vx_grid/lc_grid.h | 2 +- met/src/libcode/vx_grid/merc_grid.cc | 24 +++++++++++----------- met/src/libcode/vx_grid/merc_grid.h | 2 +- met/src/libcode/vx_grid/rot_latlon_grid.cc | 24 +++++++++++----------- met/src/libcode/vx_grid/rot_latlon_grid.h | 2 +- met/src/libcode/vx_grid/st_grid.cc | 18 ++++++++-------- met/src/libcode/vx_grid/st_grid.h | 2 +- 17 files changed, 83 insertions(+), 79 deletions(-) diff --git a/met/src/libcode/vx_data2d/data_class.cc b/met/src/libcode/vx_data2d/data_class.cc index c3da14d83f..612c0eb6e3 100644 --- a/met/src/libcode/vx_data2d/data_class.cc +++ b/met/src/libcode/vx_data2d/data_class.cc @@ -361,21 +361,25 @@ if ( vinfo->grid_attr().nxy() > 0 ) { } // - // Print a data summary + // Print the grid information and data summary // if ( mlog.verbosity_level() >= 4 ) { + mlog << Debug(4) << "\n" + << "Grid information:\n " + << Dest_Grid->serialize("\n ") << "\n"; + double min_v, max_v; dp.data_range(min_v, max_v); mlog << Debug(4) << "\n" << "Data plane information:\n" - << " plane min: " << min_v << "\n" - << " plane max: " << max_v << "\n" - << " valid time: " << unix_to_yyyymmdd_hhmmss(dp.valid()) << "\n" - << " lead time: " << sec_to_hhmmss(dp.lead()) << "\n" - << " init time: " << unix_to_yyyymmdd_hhmmss(dp.init()) << "\n" - << " accum time: " << sec_to_hhmmss(dp.accum()) << "\n\n"; + << " plane min: " << min_v << "\n" + << " plane max: " << max_v << "\n" + << " valid time: " << unix_to_yyyymmdd_hhmmss(dp.valid()) << "\n" + << " lead time: " << sec_to_hhmmss(dp.lead()) << "\n" + << " init time: " << unix_to_yyyymmdd_hhmmss(dp.init()) << "\n" + << " accum time: " << sec_to_hhmmss(dp.accum()) << "\n\n"; } diff --git a/met/src/libcode/vx_grid/gaussian_grid.cc b/met/src/libcode/vx_grid/gaussian_grid.cc index 61edbbb7f8..db2cc9c94c 100644 --- a/met/src/libcode/vx_grid/gaussian_grid.cc +++ b/met/src/libcode/vx_grid/gaussian_grid.cc @@ -370,19 +370,19 @@ return; //////////////////////////////////////////////////////////////////////// -ConcatString GaussianGrid::serialize() const +ConcatString GaussianGrid::serialize(const char *sep) const { ConcatString a; char junk[256]; -a << "Projection: Gaussian"; +a << "Projection: Gaussian" << sep; snprintf(junk, sizeof(junk), " Lon_Zero: %.4f", Lon_Zero); a << junk; -a << " Nx: " << Nx; -a << " Ny: " << Ny; +a << "Nx: " << Nx << sep; +a << "Ny: " << Ny; // // done diff --git a/met/src/libcode/vx_grid/gaussian_grid.h b/met/src/libcode/vx_grid/gaussian_grid.h index 1825f853e0..d190f7d117 100644 --- a/met/src/libcode/vx_grid/gaussian_grid.h +++ b/met/src/libcode/vx_grid/gaussian_grid.h @@ -75,7 +75,7 @@ class GaussianGrid : public GridRep { void dump(ostream &, int = 0) const; - ConcatString serialize() const; + ConcatString serialize(const char *sep=" ") const; GridInfo info() const; diff --git a/met/src/libcode/vx_grid/goes_grid.cc b/met/src/libcode/vx_grid/goes_grid.cc index 71e6ff61d5..ec8280b2e5 100644 --- a/met/src/libcode/vx_grid/goes_grid.cc +++ b/met/src/libcode/vx_grid/goes_grid.cc @@ -307,17 +307,17 @@ return; //////////////////////////////////////////////////////////////////////// -ConcatString GoesImagerGrid::serialize() const +ConcatString GoesImagerGrid::serialize(const char *sep) const { ConcatString a; char junk[256]; -a << "Projection: GoesImager"; +a << "Projection: GoesImager" << sep; -a << " Nx: " << Nx; -a << " Ny: " << Ny; +a << "Nx: " << Nx << sep; +a << "Ny: " << Ny; //snprintf(junk, sizeof(junk), " Lat_LL: %.3f", Lat_LL); a << junk; //snprintf(junk, sizeof(junk), " Lon_LL: %.3f", Lon_LL); a << junk; diff --git a/met/src/libcode/vx_grid/goes_grid.h b/met/src/libcode/vx_grid/goes_grid.h index 291428fa33..3ecb68a099 100644 --- a/met/src/libcode/vx_grid/goes_grid.h +++ b/met/src/libcode/vx_grid/goes_grid.h @@ -66,7 +66,7 @@ class GoesImagerGrid : public GridRep { void dump(ostream &, int = 0) const; - ConcatString serialize() const; + ConcatString serialize(const char *sep=" ") const; GridInfo info () const; diff --git a/met/src/libcode/vx_grid/grid_base.cc b/met/src/libcode/vx_grid/grid_base.cc index ece0332ce1..3d26ef18af 100644 --- a/met/src/libcode/vx_grid/grid_base.cc +++ b/met/src/libcode/vx_grid/grid_base.cc @@ -900,13 +900,13 @@ return ( rep->name() ); //////////////////////////////////////////////////////////////////////// -ConcatString Grid::serialize() const +ConcatString Grid::serialize(const char *sep) const { ConcatString s; -if ( rep ) s = rep->serialize(); +if ( rep ) s = rep->serialize(sep); return ( s ); diff --git a/met/src/libcode/vx_grid/grid_base.h b/met/src/libcode/vx_grid/grid_base.h index 5a225f6275..801de26c5b 100644 --- a/met/src/libcode/vx_grid/grid_base.h +++ b/met/src/libcode/vx_grid/grid_base.h @@ -162,7 +162,7 @@ class GridRep : public GridInterface { virtual void dump(ostream &, int = 0) const = 0; - virtual ConcatString serialize() const = 0; + virtual ConcatString serialize(const char *sep=" ") const = 0; virtual GridInfo info() const = 0; @@ -240,7 +240,7 @@ class Grid : public GridInterface { ConcatString name() const; - ConcatString serialize() const; + ConcatString serialize(const char *sep=" ") const; GridInfo info() const; diff --git a/met/src/libcode/vx_grid/latlon_grid.cc b/met/src/libcode/vx_grid/latlon_grid.cc index 11e779cc66..7ba1ea13ec 100644 --- a/met/src/libcode/vx_grid/latlon_grid.cc +++ b/met/src/libcode/vx_grid/latlon_grid.cc @@ -286,7 +286,7 @@ return; //////////////////////////////////////////////////////////////////////// -ConcatString LatLonGrid::serialize() const +ConcatString LatLonGrid::serialize(const char *sep) const { @@ -294,18 +294,18 @@ ConcatString a; char junk[256]; -a << "Projection: Lat/Lon"; +a << "Projection: Lat/Lon" << sep; -a << " Nx: " << Nx; -a << " Ny: " << Ny; +a << "Nx: " << Nx << sep; +a << "Ny: " << Ny << sep; -snprintf(junk, sizeof(junk), " lat_ll: %.3f", lat_ll); a << junk; -snprintf(junk, sizeof(junk), " lon_ll: %.3f", lon_ll); a << junk; +snprintf(junk, sizeof(junk), "lat_ll: %.3f", lat_ll); a << junk << sep; +snprintf(junk, sizeof(junk), "lon_ll: %.3f", lon_ll); a << junk << sep; -snprintf(junk, sizeof(junk), " delta_lat: %.3f", delta_lat); a << junk; -snprintf(junk, sizeof(junk), " delta_lon: %.3f", delta_lon); a << junk; +snprintf(junk, sizeof(junk), "delta_lat: %.3f", delta_lat); a << junk << sep; +snprintf(junk, sizeof(junk), "delta_lon: %.3f", delta_lon); a << junk << sep; -snprintf(junk, sizeof(junk), " wrapLon: %s", bool_to_string(wrapLon)); a << junk; +snprintf(junk, sizeof(junk), "wrapLon: %s", bool_to_string(wrapLon)); a << junk; // // done diff --git a/met/src/libcode/vx_grid/latlon_grid.h b/met/src/libcode/vx_grid/latlon_grid.h index 21c86d6e2c..611c618f2a 100644 --- a/met/src/libcode/vx_grid/latlon_grid.h +++ b/met/src/libcode/vx_grid/latlon_grid.h @@ -71,7 +71,7 @@ class LatLonGrid : public GridRep { void dump(ostream &, int = 0) const; - ConcatString serialize() const; + ConcatString serialize(const char *sep=" ") const; GridInfo info() const; diff --git a/met/src/libcode/vx_grid/lc_grid.cc b/met/src/libcode/vx_grid/lc_grid.cc index 41a2e375e9..1033b6edf4 100644 --- a/met/src/libcode/vx_grid/lc_grid.cc +++ b/met/src/libcode/vx_grid/lc_grid.cc @@ -551,29 +551,29 @@ return; //////////////////////////////////////////////////////////////////////// -ConcatString LambertGrid::serialize() const +ConcatString LambertGrid::serialize(const char *sep) const { ConcatString a; char junk[256]; -a << "Projection: Lambert Conformal"; +a << "Projection: Lambert Conformal" << sep; -a << " Nx: " << Nx; -a << " Ny: " << Ny; +a << "Nx: " << Nx << sep; +a << "Ny: " << Ny << sep; -snprintf(junk, sizeof(junk), " Lat_LL: %.3f", Lat_LL); a << junk; -snprintf(junk, sizeof(junk), " Lon_LL: %.3f", Lon_LL); a << junk; +snprintf(junk, sizeof(junk), "Lat_LL: %.3f", Lat_LL); a << junk << sep; +snprintf(junk, sizeof(junk), "Lon_LL: %.3f", Lon_LL); a << junk << sep; -snprintf(junk, sizeof(junk), " Lon_orient: %.3f", Lon_orient); a << junk; +snprintf(junk, sizeof(junk), "Lon_orient: %.3f", Lon_orient); a << junk << sep; -snprintf(junk, sizeof(junk), " Alpha: %.3f", Alpha); a << junk; +snprintf(junk, sizeof(junk), "Alpha: %.3f", Alpha); a << junk << sep; -snprintf(junk, sizeof(junk), " Cone: %.3f", Cone); a << junk; +snprintf(junk, sizeof(junk), "Cone: %.3f", Cone); a << junk << sep; -snprintf(junk, sizeof(junk), " Bx: %.4f", Bx); a << junk; -snprintf(junk, sizeof(junk), " By: %.4f", By); a << junk; +snprintf(junk, sizeof(junk), "Bx: %.4f", Bx); a << junk << sep; +snprintf(junk, sizeof(junk), "By: %.4f", By); a << junk; // // done diff --git a/met/src/libcode/vx_grid/lc_grid.h b/met/src/libcode/vx_grid/lc_grid.h index 0b3fefdaaa..d31ffc2e61 100644 --- a/met/src/libcode/vx_grid/lc_grid.h +++ b/met/src/libcode/vx_grid/lc_grid.h @@ -112,7 +112,7 @@ class LambertGrid : public GridRep { void dump(ostream &, int = 0) const; - ConcatString serialize() const; + ConcatString serialize(const char *sep=" ") const; GridInfo info () const; diff --git a/met/src/libcode/vx_grid/merc_grid.cc b/met/src/libcode/vx_grid/merc_grid.cc index d89a7898e4..9fdfb92975 100644 --- a/met/src/libcode/vx_grid/merc_grid.cc +++ b/met/src/libcode/vx_grid/merc_grid.cc @@ -503,29 +503,29 @@ return; //////////////////////////////////////////////////////////////////////// -ConcatString MercatorGrid::serialize() const +ConcatString MercatorGrid::serialize(const char *sep) const { ConcatString a; char junk[256]; -a << "Projection: Mercator"; +a << "Projection: Mercator" << sep; -a << " Nx: " << Nx; -a << " Ny: " << Ny; +a << "Nx: " << Nx << sep; +a << "Ny: " << Ny << sep; -snprintf(junk, sizeof(junk), " Lat_LL_radians: %.4f", Lat_LL_radians); a << junk; -snprintf(junk, sizeof(junk), " Lon_LL_radians: %.4f", Lon_LL_radians); a << junk; +snprintf(junk, sizeof(junk), "Lat_LL_radians: %.4f", Lat_LL_radians); a << junk << sep; +snprintf(junk, sizeof(junk), "Lon_LL_radians: %.4f", Lon_LL_radians); a << junk << sep; -snprintf(junk, sizeof(junk), " Lat_UR_radians: %.4f", Lat_UR_radians); a << junk; -snprintf(junk, sizeof(junk), " Lon_UR_radians: %.4f", Lon_UR_radians); a << junk; +snprintf(junk, sizeof(junk), "Lat_UR_radians: %.4f", Lat_UR_radians); a << junk << sep; +snprintf(junk, sizeof(junk), "Lon_UR_radians: %.4f", Lon_UR_radians); a << junk << sep; -snprintf(junk, sizeof(junk), " Mx: %.4f", Mx); a << junk; -snprintf(junk, sizeof(junk), " My: %.4f", My); a << junk; +snprintf(junk, sizeof(junk), "Mx: %.4f", Mx); a << junk << sep; +snprintf(junk, sizeof(junk), "My: %.4f", My); a << junk << sep; -snprintf(junk, sizeof(junk), " Bx: %.4f", Bx); a << junk; -snprintf(junk, sizeof(junk), " By: %.4f", By); a << junk; +snprintf(junk, sizeof(junk), "Bx: %.4f", Bx); a << junk << sep; +snprintf(junk, sizeof(junk), "By: %.4f", By); a << junk; // // done diff --git a/met/src/libcode/vx_grid/merc_grid.h b/met/src/libcode/vx_grid/merc_grid.h index f46a9c3bf8..c40ab09afd 100644 --- a/met/src/libcode/vx_grid/merc_grid.h +++ b/met/src/libcode/vx_grid/merc_grid.h @@ -95,7 +95,7 @@ class MercatorGrid : public GridRep { void dump(ostream &, int = 0) const; - ConcatString serialize() const; + ConcatString serialize(const char *sep=" ") const; GridInfo info() const; diff --git a/met/src/libcode/vx_grid/rot_latlon_grid.cc b/met/src/libcode/vx_grid/rot_latlon_grid.cc index 12b6286135..e4cb6a46fb 100644 --- a/met/src/libcode/vx_grid/rot_latlon_grid.cc +++ b/met/src/libcode/vx_grid/rot_latlon_grid.cc @@ -300,7 +300,7 @@ return; //////////////////////////////////////////////////////////////////////// -ConcatString RotatedLatLonGrid::serialize() const +ConcatString RotatedLatLonGrid::serialize(const char *sep) const { @@ -308,23 +308,23 @@ ConcatString a; char junk[256]; -a << "Projection: Rotated Lat/Lon"; +a << "Projection: Rotated Lat/Lon" << sep; -a << " Nx: " << Nx; -a << " Ny: " << Ny; +a << "Nx: " << Nx << sep; +a << "Ny: " << Ny << sep; -snprintf(junk, sizeof(junk), " rot_lat_ll: %.3f", RData.rot_lat_ll); a << junk; -snprintf(junk, sizeof(junk), " rot_lon_ll: %.3f", RData.rot_lon_ll); a << junk; +snprintf(junk, sizeof(junk), "rot_lat_ll: %.3f", RData.rot_lat_ll); a << junk << sep; +snprintf(junk, sizeof(junk), "rot_lon_ll: %.3f", RData.rot_lon_ll); a << junk << sep; -snprintf(junk, sizeof(junk), " delta_rot_lat: %.3f", RData.delta_rot_lat); a << junk; -snprintf(junk, sizeof(junk), " delta_rot_lon: %.3f", RData.delta_rot_lon); a << junk; +snprintf(junk, sizeof(junk), "delta_rot_lat: %.3f", RData.delta_rot_lat); a << junk << sep; +snprintf(junk, sizeof(junk), "delta_rot_lon: %.3f", RData.delta_rot_lon); a << junk << sep; -snprintf(junk, sizeof(junk), " wrapLon: %s", bool_to_string(wrapLon)); a << junk; +snprintf(junk, sizeof(junk), "wrapLon: %s", bool_to_string(wrapLon)); a << junk << sep; -snprintf(junk, sizeof(junk), " true_lat_south_pole: %.3f", RData.true_lat_south_pole); a << junk; -snprintf(junk, sizeof(junk), " true_lon_south_pole: %.3f", RData.true_lon_south_pole); a << junk; +snprintf(junk, sizeof(junk), "true_lat_south_pole: %.3f", RData.true_lat_south_pole); a << junk << sep; +snprintf(junk, sizeof(junk), "true_lon_south_pole: %.3f", RData.true_lon_south_pole); a << junk << sep; -snprintf(junk, sizeof(junk), " aux_rotation: %.3f", RData.aux_rotation); a << junk; +snprintf(junk, sizeof(junk), "aux_rotation: %.3f", RData.aux_rotation); a << junk; // // done diff --git a/met/src/libcode/vx_grid/rot_latlon_grid.h b/met/src/libcode/vx_grid/rot_latlon_grid.h index 79a75e1869..d4c52bb56d 100644 --- a/met/src/libcode/vx_grid/rot_latlon_grid.h +++ b/met/src/libcode/vx_grid/rot_latlon_grid.h @@ -64,7 +64,7 @@ class RotatedLatLonGrid : public LatLonGrid { void dump(ostream &, int = 0) const; - ConcatString serialize() const; + ConcatString serialize(const char *sep=" ") const; GridInfo info() const; diff --git a/met/src/libcode/vx_grid/st_grid.cc b/met/src/libcode/vx_grid/st_grid.cc index 3b64e4a14d..e6a4e9a631 100644 --- a/met/src/libcode/vx_grid/st_grid.cc +++ b/met/src/libcode/vx_grid/st_grid.cc @@ -483,26 +483,26 @@ return; //////////////////////////////////////////////////////////////////////// -ConcatString StereographicGrid::serialize() const +ConcatString StereographicGrid::serialize(const char *sep) const { ConcatString a; char junk[256]; -a << "Projection: Stereographic"; +a << "Projection: Stereographic" << sep; -a << " Nx: " << Nx; -a << " Ny: " << Ny; +a << "Nx: " << Nx << sep; +a << "Ny: " << Ny << sep; -a << " IsNorthHemisphere: " << ( IsNorthHemisphere ? "true" : "false"); +a << "IsNorthHemisphere: " << ( IsNorthHemisphere ? "true" : "false") << sep; -snprintf(junk, sizeof(junk), " Lon_orient: %.3f", Lon_orient); a << junk; +snprintf(junk, sizeof(junk), "Lon_orient: %.3f", Lon_orient); a << junk << sep; -snprintf(junk, sizeof(junk), " Bx: %.3f", Bx); a << junk; -snprintf(junk, sizeof(junk), " By: %.3f", By); a << junk; +snprintf(junk, sizeof(junk), "Bx: %.3f", Bx); a << junk << sep; +snprintf(junk, sizeof(junk), "By: %.3f", By); a << junk << sep; -snprintf(junk, sizeof(junk), " Alpha: %.4f", Alpha); a << junk; +snprintf(junk, sizeof(junk), "Alpha: %.4f", Alpha); a << junk; // // done diff --git a/met/src/libcode/vx_grid/st_grid.h b/met/src/libcode/vx_grid/st_grid.h index 9fecdba445..0c26daac69 100644 --- a/met/src/libcode/vx_grid/st_grid.h +++ b/met/src/libcode/vx_grid/st_grid.h @@ -93,7 +93,7 @@ class StereographicGrid : public GridRep { void dump(ostream &, int = 0) const; - ConcatString serialize() const; + ConcatString serialize(const char *sep=" ") const; GridInfo info() const;