From a0ce82f1bf2797b6bd659bb13b6908866b48055c Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Fri, 27 Sep 2024 10:02:40 -0500 Subject: [PATCH] Bugfix #2979 develop MTD Grid (#2981) * Per #2979, remove nc_grid.h/.cc and replace it with calls to the read_netcdf_grid(...) and write_netcdf_proj(...) library utility functions. Note that these changes do compile but I haven't tested whether they actually fix the underlying problem. Also note that nc_utils_local.h/.cc can also likely be replaced with calls to common library functions. * Per #2979, remove references to nc_grid.o from the MTD test code. * Per #2979, insert a newline in unit.py output between the env vars and the command. * Per #2979, insert a newline in unit.py output between the env vars and the command. * Per #2979, the write_netcdf_proj(...) utility function adds the lat and lon dimensions. Update mtd to NOT define those dimensions prior to calling write_netcdf_proj(...). * Per #2979, minor changes to is_eq() calls to fix compiler warning messages * Per #2979, for the develop branch, also replace nc_utils_local.h/.cc with calls to common library code. Also remove commented out code. * Per #2979, delete commented out code and make error/warning message formatting consistent. * Fixes for SonarQube --------- Co-authored-by: MET Tools Test Account --- internal/test_unit/python/unit.py | 2 +- .../tools/other/mode_time_domain/Makefile.am | 2 - .../tools/other/mode_time_domain/Makefile.in | 4 - src/basic/vx_math/is_bad_data.h | 8 + src/libcode/vx_statistics/compute_stats.cc | 2 +- src/tools/other/mode_time_domain/2d_att.cc | 17 +- .../other/mode_time_domain/2d_att_array.cc | 40 +- .../other/mode_time_domain/2d_moments.cc | 12 +- src/tools/other/mode_time_domain/2d_moments.h | 4 - src/tools/other/mode_time_domain/3d_att.cc | 221 +----- src/tools/other/mode_time_domain/3d_att.h | 6 - .../mode_time_domain/3d_att_pair_array.cc | 30 +- .../mode_time_domain/3d_att_pair_array.h | 1 - .../mode_time_domain/3d_att_single_array.cc | 14 +- src/tools/other/mode_time_domain/3d_conv.cc | 52 +- .../other/mode_time_domain/3d_moments.cc | 13 +- src/tools/other/mode_time_domain/3d_moments.h | 3 - src/tools/other/mode_time_domain/Makefile.am | 2 - src/tools/other/mode_time_domain/Makefile.in | 40 +- src/tools/other/mode_time_domain/fo_graph.cc | 33 +- src/tools/other/mode_time_domain/fo_graph.h | 7 - src/tools/other/mode_time_domain/fo_node.cc | 2 - .../other/mode_time_domain/fo_node_array.cc | 13 +- .../other/mode_time_domain/interest_calc.cc | 4 - .../other/mode_time_domain/interest_calc.h | 1 - src/tools/other/mode_time_domain/mm_engine.cc | 5 - src/tools/other/mode_time_domain/mtd.cc | 39 - .../other/mode_time_domain/mtd_config_info.cc | 174 +---- .../other/mode_time_domain/mtd_file_base.cc | 66 +- .../other/mode_time_domain/mtd_file_float.cc | 118 +--- .../other/mode_time_domain/mtd_file_int.cc | 195 ++--- .../other/mode_time_domain/mtd_nc_defs.h | 73 +- .../other/mode_time_domain/mtd_nc_output.cc | 32 +- .../other/mode_time_domain/mtd_nc_output.h | 2 - .../other/mode_time_domain/mtd_partition.cc | 64 +- .../other/mode_time_domain/mtd_read_data.cc | 25 +- .../other/mode_time_domain/mtd_txt_output.cc | 30 +- .../mode_time_domain/mtdfiletype_to_string.cc | 1 + src/tools/other/mode_time_domain/nc_grid.cc | 665 ------------------ src/tools/other/mode_time_domain/nc_grid.h | 41 -- .../other/mode_time_domain/nc_utils_local.cc | 191 ----- .../other/mode_time_domain/nc_utils_local.h | 50 -- 42 files changed, 302 insertions(+), 2002 deletions(-) delete mode 100644 src/tools/other/mode_time_domain/nc_grid.cc delete mode 100644 src/tools/other/mode_time_domain/nc_grid.h delete mode 100644 src/tools/other/mode_time_domain/nc_utils_local.cc delete mode 100644 src/tools/other/mode_time_domain/nc_utils_local.h diff --git a/internal/test_unit/python/unit.py b/internal/test_unit/python/unit.py index 3bc2b222a9..1fc3bf681a 100755 --- a/internal/test_unit/python/unit.py +++ b/internal/test_unit/python/unit.py @@ -234,7 +234,7 @@ def unit(test_xml, file_log=None, cmd_only=False, noexit=False, memchk=False, ca # # on failure, print the problematic test and exit, if requested if not (ret_ok and out_ok): - logger.info("\n".join(set_envs) + cmd + cmd_outs + "\n".join(unset_envs) + "\n") + logger.info("\n".join(set_envs) + "\n" + cmd + "\n" + cmd_outs + "\n".join(unset_envs) + "\n") if not noexit: sys.exit(1) diff --git a/internal/test_util/tools/other/mode_time_domain/Makefile.am b/internal/test_util/tools/other/mode_time_domain/Makefile.am index 5bbe02612e..1f9be23d82 100644 --- a/internal/test_util/tools/other/mode_time_domain/Makefile.am +++ b/internal/test_util/tools/other/mode_time_domain/Makefile.am @@ -38,8 +38,6 @@ test_velocity_LDADD = \ ${top_builddir}/src/tools/other/mode_time_domain/mtd-mtd_partition.o \ ${top_builddir}/src/tools/other/mode_time_domain/mtd-mtd_read_data.o \ ${top_builddir}/src/tools/other/mode_time_domain/mtd-mtd_txt_output.o \ - ${top_builddir}/src/tools/other/mode_time_domain/mtd-nc_grid.o \ - ${top_builddir}/src/tools/other/mode_time_domain/mtd-nc_utils_local.o \ -lvx_pxm \ -lvx_plot_util \ -lvx_nav \ diff --git a/internal/test_util/tools/other/mode_time_domain/Makefile.in b/internal/test_util/tools/other/mode_time_domain/Makefile.in index c87b755d7d..b1b08361df 100644 --- a/internal/test_util/tools/other/mode_time_domain/Makefile.in +++ b/internal/test_util/tools/other/mode_time_domain/Makefile.in @@ -125,8 +125,6 @@ test_velocity_DEPENDENCIES = ${top_builddir}/src/tools/other/mode_time_domain/mt ${top_builddir}/src/tools/other/mode_time_domain/mtd-mtd_partition.o \ ${top_builddir}/src/tools/other/mode_time_domain/mtd-mtd_read_data.o \ ${top_builddir}/src/tools/other/mode_time_domain/mtd-mtd_txt_output.o \ - ${top_builddir}/src/tools/other/mode_time_domain/mtd-nc_grid.o \ - ${top_builddir}/src/tools/other/mode_time_domain/mtd-nc_utils_local.o \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) @@ -378,8 +376,6 @@ test_velocity_LDADD = \ ${top_builddir}/src/tools/other/mode_time_domain/mtd-mtd_partition.o \ ${top_builddir}/src/tools/other/mode_time_domain/mtd-mtd_read_data.o \ ${top_builddir}/src/tools/other/mode_time_domain/mtd-mtd_txt_output.o \ - ${top_builddir}/src/tools/other/mode_time_domain/mtd-nc_grid.o \ - ${top_builddir}/src/tools/other/mode_time_domain/mtd-nc_utils_local.o \ -lvx_pxm \ -lvx_plot_util \ -lvx_nav \ diff --git a/src/basic/vx_math/is_bad_data.h b/src/basic/vx_math/is_bad_data.h index 80af0916ef..cb1c4afa8c 100644 --- a/src/basic/vx_math/is_bad_data.h +++ b/src/basic/vx_math/is_bad_data.h @@ -80,6 +80,14 @@ inline int is_eq(float a, float b) { return is_eq((double)a, (double)b); } +inline int is_eq(double a, float b) { + return is_eq(a, (double)b); +} + +inline int is_eq(float a, double b) { + return is_eq((double)a, b); +} + template inline int is_eq(T a, T b) { return (a == b); diff --git a/src/libcode/vx_statistics/compute_stats.cc b/src/libcode/vx_statistics/compute_stats.cc index c0d988efd3..4dc90e4aeb 100644 --- a/src/libcode/vx_statistics/compute_stats.cc +++ b/src/libcode/vx_statistics/compute_stats.cc @@ -1593,7 +1593,7 @@ void compute_aggregated_seeps_grid(const DataPlane &fcst_dp, const DataPlane &ob float obs_value = obs_dp.get(ix, iy); fcst_cat = obs_cat = bad_data_int; seeps_score = bad_data_double; - if (!is_eq(fcst_value, -9999.0) && !is_eq(obs_value, -9999.0)) { + if (!is_bad_data(fcst_value) && !is_bad_data(obs_value)) { SeepsScore *seeps_mpr = seeps_climo->get_record(ix, iy, fcst_value, obs_value); if (seeps_mpr != nullptr) { fcst_cat = seeps_mpr->fcst_cat; diff --git a/src/tools/other/mode_time_domain/2d_att.cc b/src/tools/other/mode_time_domain/2d_att.cc index 2ea1ff0844..f65ed2ae7f 100644 --- a/src/tools/other/mode_time_domain/2d_att.cc +++ b/src/tools/other/mode_time_domain/2d_att.cc @@ -7,7 +7,6 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - //////////////////////////////////////////////////////////////////////// @@ -399,15 +398,7 @@ a.ObjectNumber = obj_number; moments = mask_2d.calc_2d_moments(); -if ( moments.N == 0 ) { - - // mlog << Error << "\n\n calc_2d_single_atts() -> empty object!\n\n"; - - // exit ( 1 ); - - return a; - -} +if ( moments.N == 0 ) return a; a.Xbar = (moments.Sx)/(moments.N); a.Ybar = (moments.Sy)/(moments.N); @@ -430,7 +421,8 @@ values = new float [a.Area]; if ( !values ) { - mlog << Error << "\n\n calc_2d_single_atts() -> memory allocation error\n\n"; + mlog << Error << "\ncalc_2d_single_atts() -> " + << "memory allocation error\n\n"; exit ( 1 ); @@ -626,6 +618,3 @@ return; //////////////////////////////////////////////////////////////////////// - - - diff --git a/src/tools/other/mode_time_domain/2d_att_array.cc b/src/tools/other/mode_time_domain/2d_att_array.cc index 86a3f99081..b805304c0f 100644 --- a/src/tools/other/mode_time_domain/2d_att_array.cc +++ b/src/tools/other/mode_time_domain/2d_att_array.cc @@ -7,20 +7,6 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - -//////////////////////////////////////////////////////////////////////// - - - // - // Warning: This file is machine generated - // - // Do not edit by hand - // - // - // Created by arraygen on September 17, 2015 10:11 am MDT - // - - //////////////////////////////////////////////////////////////////////// @@ -127,13 +113,10 @@ void SingleAtt2DArray::clear() if ( e ) { delete [] e; e = (SingleAtt2D *) nullptr; } - Nelements = 0; Nalloc = 0; -// AllocInc = 50; // don't reset AllocInc - return; @@ -174,7 +157,8 @@ SingleAtt2D * u = new SingleAtt2D [N]; if ( !u ) { - mlog << Error << "SingleAtt2DArray::extend(int) -> memory allocation error\n\n"; + mlog << Error << "\nSingleAtt2DArray::extend(int) -> " + << "memory allocation error\n\n"; exit ( 1 ); @@ -238,7 +222,8 @@ void SingleAtt2DArray::set_alloc_inc(int N) if ( N < 0 ) { - mlog << Error << "SingleAtt2DArray::set_alloc_int(int) -> bad value ... " << N << "\n\n"; + mlog << Error << "\nSingleAtt2DArray::set_alloc_int(int) -> " + << "bad value ... " << N << "\n\n"; exit ( 1 ); @@ -299,7 +284,8 @@ SingleAtt2D & SingleAtt2DArray::operator[](int N) const if ( (N < 0) || (N >= Nelements) ) { - mlog << Error << "\n\n SingleAtt2DArray::operator[](int) -> range check error ... " << N << "\n\n"; + mlog << Error << "\nSingleAtt2DArray::operator[](int) -> " + << "range check error ... " << N << "\n\n"; exit ( 1 ); } @@ -344,8 +330,8 @@ unixtime SingleAtt2DArray::valid_time(int index) const if ( (index < 0) || (index >= Nelements) ) { - mlog << Error - << "SingleAtt2DArray::valid_time(int) const -> range check error\n\n"; + mlog << Error << "\nSingleAtt2DArray::valid_time(int) const -> " + << "range check error\n\n"; exit ( 1 ); @@ -365,8 +351,8 @@ int SingleAtt2DArray::lead_time(int index) const if ( (index < 0) || (index >= Nelements) ) { - mlog << Error - << "SingleAtt2DArray::lead_time(int) const -> range check error\n\n"; + mlog << Error << "\nSingleAtt2DArray::lead_time(int) const -> " + << "range check error\n\n"; exit ( 1 ); @@ -386,8 +372,8 @@ int SingleAtt2DArray::time_index(int index) const if ( (index < 0) || (index >= Nelements) ) { - mlog << Error - << "SingleAtt2DArray::time_index(int) const -> range check error\n\n"; + mlog << Error << "\nSingleAtt2DArray::time_index(int) const -> " + << "range check error\n\n"; exit ( 1 ); @@ -401,5 +387,3 @@ return e[index].time_index(); //////////////////////////////////////////////////////////////////////// - - diff --git a/src/tools/other/mode_time_domain/2d_moments.cc b/src/tools/other/mode_time_domain/2d_moments.cc index ed1053d819..fc3cad6289 100644 --- a/src/tools/other/mode_time_domain/2d_moments.cc +++ b/src/tools/other/mode_time_domain/2d_moments.cc @@ -7,7 +7,6 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - //////////////////////////////////////////////////////////////////////// @@ -25,12 +24,10 @@ using namespace std; //////////////////////////////////////////////////////////////////////// - // // Code for class Mtd_2D_Moments // - //////////////////////////////////////////////////////////////////////// @@ -177,7 +174,8 @@ void Mtd_2D_Moments::centralize() if ( N == 0 ) { - mlog << Error << "\n\n Mtd_2D_Moments::centralize() -> no data!\n\n"; + mlog << Error << "\nMtd_2D_Moments::centralize() -> " + << "no data!\n\n"; exit ( 1 ); @@ -220,7 +218,8 @@ double Mtd_2D_Moments::calc_2D_axis_plane_angle() const if ( ! IsCentralized ) { - mlog << Error << "\n\n Mtd_2D_Moments::calc_2D_axis_plane_angle() const -> moments must be centralized first!\n\n"; + mlog << Error << "\nMtd_2D_Moments::calc_2D_axis_plane_angle() const -> " + << "moments must be centralized first!\n\n"; exit ( 1 ); @@ -242,6 +241,3 @@ return angle; //////////////////////////////////////////////////////////////////////// - - - diff --git a/src/tools/other/mode_time_domain/2d_moments.h b/src/tools/other/mode_time_domain/2d_moments.h index 2052561687..3dcf4c995c 100644 --- a/src/tools/other/mode_time_domain/2d_moments.h +++ b/src/tools/other/mode_time_domain/2d_moments.h @@ -57,7 +57,6 @@ class Mtd_2D_Moments { int area() const; - // // do stuff // @@ -66,11 +65,8 @@ class Mtd_2D_Moments { void centralize(); - double calc_2D_axis_plane_angle() const; - - }; diff --git a/src/tools/other/mode_time_domain/3d_att.cc b/src/tools/other/mode_time_domain/3d_att.cc index 3f30a12786..a347be824e 100644 --- a/src/tools/other/mode_time_domain/3d_att.cc +++ b/src/tools/other/mode_time_domain/3d_att.cc @@ -7,7 +7,6 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - //////////////////////////////////////////////////////////////////////// @@ -779,8 +778,6 @@ IntersectionVol = 0; IsSimple = true; -// UnionVol = 0; - TimeCentroidDelta = 0.0; SpaceCentroidDist = 0.0; @@ -830,9 +827,6 @@ ObsClusterNumber = a.ObsClusterNumber; IntersectionVol = a.IntersectionVol; -// UnionVol = a.UnionVol; - - TimeCentroidDelta = a.TimeCentroidDelta; SpaceCentroidDist = a.SpaceCentroidDist; @@ -954,20 +948,6 @@ return; } -//////////////////////////////////////////////////////////////////////// - -/* -void PairAtt3D::set_union_volume(int k) - -{ - -UnionVol = k; - -return; - -} -*/ - //////////////////////////////////////////////////////////////////////// @@ -1261,7 +1241,7 @@ moments = mask.calc_3d_moments(); if ( moments.N == 0 ) { - mlog << Error << "\n\ncalc_3d_single_atts() -> " + mlog << Error << "\ncalc_3d_single_atts() -> " << "empty object!\n\n"; exit ( 1 ); @@ -1354,7 +1334,7 @@ values = new float [Vol]; if ( !values ) { - mlog << Error << "\n\ncalc_3d_single_atts() -> " + mlog << Error << "\ncalc_3d_single_atts() -> " << "memory allocation error\n\n"; exit ( 1 ); @@ -1453,7 +1433,6 @@ for (x=0; x<(fcst_obj.nx()); ++x) { } p.set_intersection_volume (IV); -// p.set_union_volume (UV); // // centroid distances @@ -1546,188 +1525,6 @@ return p; } -//////////////////////////////////////////////////////////////////////// - -/* -double calc_total_interest(const PairAtt3D & p, const MtdConfigInfo & conf) - -{ - -double t = 0.0; -double num, den; // numerator and denominator in the expression for total interest -double I, w; -PiecewiseLinear * f = 0; - -num = 0.0; -den = 0.0; - - // - // We don't need to use "is_eq" to check whether each weight is - // nonzero, because the MtdConfigInfo::read_config() function has - // already done that. That same function has already tested that - // the weights are not all zero. - // - - // - // space centroid dist - // - -w = conf.space_centroid_dist_wt; - -if ( w != 0.0 ) { - - f = conf.space_centroid_dist_if; - - I = (*f)(p.space_centroid_dist()); - - num += w*I; - - den += w; - -} - - // - // time centroid delta - // - -w = conf.time_centroid_delta_wt; - -if ( w != 0.0 ) { - - f = conf.time_centroid_delta_if; - - I = (*f)(p.time_centroid_delta()); - - num += w*I; - - den += w; - -} - - // - // speed delta - // - -w = conf.speed_delta_wt; - -if ( w != 0.0 ) { - - f = conf.speed_delta_if; - - I = (*f)(p.speed_delta()); - - num += w*I; - - den += w; - -} - - // - // direction difference - // - -w = conf.direction_diff_wt; - -if ( w != 0.0 ) { - - f = conf.direction_diff_if; - - I = (*f)(p.direction_difference()); - - num += w*I; - - den += w; - -} - - // - // volume ratio - // - -w = conf.volume_ratio_wt; - -if ( w != 0.0 ) { - - f = conf.volume_ratio_if; - - I = (*f)(p.volume_ratio()); - - num += w*I; - - den += w; - -} - - // - // axis angle difference - // - -w = conf.axis_angle_diff_wt; - -if ( w != 0.0 ) { - - f = conf.axis_angle_diff_if; - - I = (*f)(p.axis_angle_diff()); - - num += w*I; - - den += w; - -} - - // - // start time delta - // - -w = conf.start_time_delta_wt; - -if ( w != 0.0 ) { - - f = conf.start_time_delta_if; - - I = (*f)(p.start_time_delta()); - - num += w*I; - - den += w; - -} - - // - // end time delta - // - -w = conf.end_time_delta_wt; - -if ( w != 0.0 ) { - - f = conf.end_time_delta_if; - - I = (*f)(p.end_time_delta()); - - num += w*I; - - den += w; - -} - - // - // The denominator is just the sum of the weights, - // which, as stated above, we already know is nonzero. - // - -t = num/den; - - // - // done - // - -return t; - -} -*/ - //////////////////////////////////////////////////////////////////////// @@ -1738,15 +1535,6 @@ double calc_2d_dist(const double x1_grid, const double y1_grid, double dist; - // - // distance in grid units - // - -// const double dx = x1_grid - x2_grid; -// const double dy = y1_grid - y2_grid; -// -// dist = sqrt ( dx*dx + dy*dy ); - // // great circle distance // @@ -1771,8 +1559,3 @@ return dist; //////////////////////////////////////////////////////////////////////// - - - - - diff --git a/src/tools/other/mode_time_domain/3d_att.h b/src/tools/other/mode_time_domain/3d_att.h index 91ad4901c3..d0b6084316 100644 --- a/src/tools/other/mode_time_domain/3d_att.h +++ b/src/tools/other/mode_time_domain/3d_att.h @@ -308,9 +308,6 @@ class PairAtt3D { void dump(std::ostream &, int depth = 0) const; - // SingleAtt3D Fcst; - // SingleAtt3D Obs; - // // set stuff // @@ -395,7 +392,6 @@ inline int PairAtt3D::fcst_cluster_number() const { return FcstClusterNumber; } inline int PairAtt3D::obs_cluster_number() const { return ObsClusterNumber; } inline int PairAtt3D::intersection_vol () const { return IntersectionVol; } -// inline int PairAtt3D::union_vol () const { return UnionVol; } inline double PairAtt3D::time_centroid_delta () const { return TimeCentroidDelta; } inline double PairAtt3D::space_centroid_dist () const { return SpaceCentroidDist; } @@ -430,8 +426,6 @@ extern PairAtt3D calc_3d_pair_atts(const Object & _fcst_obj, const SingleAtt3D & _fa, const SingleAtt3D & _oa); -// extern double calc_total_interest(const PairAtt3D &, const MtdConfigInfo &); - //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/mode_time_domain/3d_att_pair_array.cc b/src/tools/other/mode_time_domain/3d_att_pair_array.cc index cd5bcd1ad6..8ff840be1c 100644 --- a/src/tools/other/mode_time_domain/3d_att_pair_array.cc +++ b/src/tools/other/mode_time_domain/3d_att_pair_array.cc @@ -7,7 +7,6 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - //////////////////////////////////////////////////////////////////////// @@ -113,15 +112,10 @@ void PairAtt3DArray::clear() if ( e ) { delete [] e; e = (PairAtt3D *) nullptr; } - - Nelements = 0; Nalloc = 0; -// AllocInc = 100; // don't reset AllocInc - - return; } @@ -161,7 +155,8 @@ PairAtt3D * u = new PairAtt3D [N]; if ( !u ) { - mlog << Error << "PairAtt3DArray::extend(int) -> memory allocation error\n\n"; + mlog << Error << "\nPairAtt3DArray::extend(int) -> " + << "memory allocation error\n\n"; exit ( 1 ); @@ -225,7 +220,8 @@ void PairAtt3DArray::set_alloc_inc(int N) if ( N < 0 ) { - mlog << Error << "PairAtt3DArray::set_alloc_int(int) -> bad value ... " << N << "\n\n"; + mlog << Error << "\nPairAtt3DArray::set_alloc_int(int) -> " + << "bad value ... " << N << "\n\n"; exit ( 1 ); @@ -286,7 +282,8 @@ PairAtt3D & PairAtt3DArray::operator[](int N) const if ( (N < 0) || (N >= Nelements) ) { - mlog << Error << "\n\n PairAtt3DArray::operator[](int) -> range check error ... " << N << "\n\n"; + mlog << Error << "\nPairAtt3DArray::operator[](int) -> " + << "range check error ... " << N << "\n\n"; exit ( 1 ); } @@ -305,7 +302,8 @@ int PairAtt3DArray::fcst_obj_number(int k) const if ( (k < 0) || (k >= Nelements) ) { - mlog << Error << "\n\n PairAtt3DArray::fcst_obj_number(int) -> range check error\n\n"; + mlog << Error << "\nPairAtt3DArray::fcst_obj_number(int) -> " + << "range check error\n\n"; exit ( 1 ); @@ -325,7 +323,8 @@ int PairAtt3DArray::obs_obj_number(int k) const if ( (k < 0) || (k >= Nelements) ) { - mlog << Error << "\n\n PairAtt3DArray::obs_obj_number(int) -> range check error\n\n"; + mlog << Error << "\nPairAtt3DArray::obs_obj_number(int) -> " + << "range check error\n\n"; exit ( 1 ); @@ -345,7 +344,8 @@ int PairAtt3DArray::fcst_cluster_number(int k) const if ( (k < 0) || (k >= Nelements) ) { - mlog << Error << "\n\n PairAtt3DArray::fcst_cluster_number(int) -> range check error\n\n"; + mlog << Error << "\nPairAtt3DArray::fcst_cluster_number(int) -> " + << "range check error\n\n"; exit ( 1 ); @@ -365,7 +365,8 @@ int PairAtt3DArray::obs_cluster_number(int k) const if ( (k < 0) || (k >= Nelements) ) { - mlog << Error << "\n\n PairAtt3DArray::obs_cluster_number(int) -> range check error\n\n"; + mlog << Error << "\nPairAtt3DArray::obs_cluster_number(int) -> " + << "range check error\n\n"; exit ( 1 ); @@ -385,7 +386,8 @@ double PairAtt3DArray::total_interest(int k) const if ( (k < 0) || (k >= Nelements) ) { - mlog << Error << "\n\n PairAtt3DArray::total_interest(int) -> range check error\n\n"; + mlog << Error << "\nPairAtt3DArray::total_interest(int) -> " + << "range check error\n\n"; exit ( 1 ); diff --git a/src/tools/other/mode_time_domain/3d_att_pair_array.h b/src/tools/other/mode_time_domain/3d_att_pair_array.h index f3cdf13674..470324e562 100644 --- a/src/tools/other/mode_time_domain/3d_att_pair_array.h +++ b/src/tools/other/mode_time_domain/3d_att_pair_array.h @@ -92,7 +92,6 @@ class PairAtt3DArray { void patch_cluster_numbers(const MM_Engine &); - }; diff --git a/src/tools/other/mode_time_domain/3d_att_single_array.cc b/src/tools/other/mode_time_domain/3d_att_single_array.cc index d8fdba1252..dabf30bdeb 100644 --- a/src/tools/other/mode_time_domain/3d_att_single_array.cc +++ b/src/tools/other/mode_time_domain/3d_att_single_array.cc @@ -7,7 +7,6 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - //////////////////////////////////////////////////////////////////////// @@ -113,14 +112,10 @@ void SingleAtt3DArray::clear() if ( e ) { delete [] e; e = (SingleAtt3D *) nullptr; } - - Nelements = 0; Nalloc = 0; -// AllocInc = 100; // don't reset AllocInc - return; @@ -161,7 +156,8 @@ SingleAtt3D * u = new SingleAtt3D [N]; if ( !u ) { - mlog << Error << "SingleAtt3DArray::extend(int) -> memory allocation error\n\n"; + mlog << Error << "\nSingleAtt3DArray::extend(int) -> " + << "memory allocation error\n\n"; exit ( 1 ); @@ -225,7 +221,8 @@ void SingleAtt3DArray::set_alloc_inc(int N) if ( N < 0 ) { - mlog << Error << "SingleAtt3DArray::set_alloc_int(int) -> bad value ... " << N << "\n\n"; + mlog << Error << "\nSingleAtt3DArray::set_alloc_int(int) -> " + << "bad value ... " << N << "\n\n"; exit ( 1 ); @@ -286,7 +283,8 @@ SingleAtt3D & SingleAtt3DArray::operator[](int N) const if ( (N < 0) || (N >= Nelements) ) { - mlog << Error << "\n\n SingleAtt3DArray::operator[](int) -> range check error ... " << N << "\n\n"; + mlog << Error << "\nSingleAtt3DArray::operator[](int) -> " + << "range check error ... " << N << "\n\n"; exit ( 1 ); } diff --git a/src/tools/other/mode_time_domain/3d_conv.cc b/src/tools/other/mode_time_domain/3d_conv.cc index 1ecbe0b68a..b095989391 100644 --- a/src/tools/other/mode_time_domain/3d_conv.cc +++ b/src/tools/other/mode_time_domain/3d_conv.cc @@ -244,12 +244,6 @@ file_id = 1; // This is declared static in the netCDF library header file ncG spatial_conv_radius = spatial_R; - -// mlog << Error << "\n\n" -// << " MtdFloatFile::convolve(const int) const -> still doesn't allow for bad data!\n\n" -// << "\n\n"; - - const int Nxy = Nx*Ny; const int Nxyz = Nx*Ny*Nt; @@ -263,7 +257,8 @@ for (int k=0; k memory allocation error\n\n"; + mlog << Error << "\nMtdFloatFile::convolve(const int, const int, const int) const: process() -> " + << "memory allocation error\n\n"; exit ( 1 ); @@ -278,8 +273,6 @@ max_conv_value = -1.0e100; unixtime time_start = time(nullptr); -// cout << "\n\n n = " << mtd_three_to_one(Nx, Ny, Nt, 88, 397, 0) << "\n\n"; - for (int t=0; t bad size\n\n"; + mlog << Error << "\nDataHandle::set_size() -> " + << "bad size\n\n"; exit ( 1 ); @@ -532,9 +517,6 @@ bool status = false; const int nx = mtd.nx(); const int ny = mtd.ny(); - -// mlog << Debug(5) << "In get_data_plane\n"; - for (y=0; y " + << "unable to write image file: " << filename << "\n\n"; exit ( 1 ); @@ -1038,11 +1009,10 @@ for (int x=0; x " + << "unable to write image file: " << filename << "\n\n"; exit ( 1 ); @@ -1056,7 +1026,3 @@ return; //////////////////////////////////////////////////////////////////////// - - - - diff --git a/src/tools/other/mode_time_domain/3d_moments.cc b/src/tools/other/mode_time_domain/3d_moments.cc index 7c2b4362d4..53e1b8b547 100644 --- a/src/tools/other/mode_time_domain/3d_moments.cc +++ b/src/tools/other/mode_time_domain/3d_moments.cc @@ -7,7 +7,6 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - //////////////////////////////////////////////////////////////////////// @@ -187,7 +186,8 @@ void Mtd_3D_Moments::centralize() if ( N == 0 ) { - mlog << Error << "\n\n Mtd_3D_Moments::centralize() -> no data!\n\n"; + mlog << Error << "\nMtd_3D_Moments::centralize() -> " + << "no data!\n\n"; exit ( 1 ); @@ -242,7 +242,8 @@ void Mtd_3D_Moments::calc_3d_velocity(double & vx, double & vy) const if ( ! IsCentralized ) { - mlog << Error << "\n\n Mtd_3D_Moments::calc_3d_velocity(double &, double &) const -> moments must be centralized first!\n\n"; + mlog << Error << "\nMtd_3D_Moments::calc_3d_velocity(double &, double &) const -> " + << "moments must be centralized first!\n\n"; exit ( 1 ); @@ -266,7 +267,8 @@ double Mtd_3D_Moments::calc_3d_axis_plane_angle() const if ( ! IsCentralized ) { - mlog << Error << "\n\n Mtd_3D_Moments::calc_3d_axis_plane_angle() const -> moments must be centralized first!\n\n"; + mlog << Error << "\nMtd_3D_Moments::calc_3d_axis_plane_angle() const -> " + << "moments must be centralized first!\n\n"; exit ( 1 ); @@ -288,6 +290,3 @@ return angle; //////////////////////////////////////////////////////////////////////// - - - diff --git a/src/tools/other/mode_time_domain/3d_moments.h b/src/tools/other/mode_time_domain/3d_moments.h index 933fa4e7ad..7f5f8bb02f 100644 --- a/src/tools/other/mode_time_domain/3d_moments.h +++ b/src/tools/other/mode_time_domain/3d_moments.h @@ -70,13 +70,10 @@ class Mtd_3D_Moments { void centralize(); - void calc_3d_velocity(double & vx, double & vy) const; double calc_3d_axis_plane_angle() const; - - }; diff --git a/src/tools/other/mode_time_domain/Makefile.am b/src/tools/other/mode_time_domain/Makefile.am index 34ad4461ee..b75702d973 100644 --- a/src/tools/other/mode_time_domain/Makefile.am +++ b/src/tools/other/mode_time_domain/Makefile.am @@ -12,8 +12,6 @@ include ${top_srcdir}/Make-include bin_PROGRAMS = mtd mtd_SOURCES = mtd.cc \ mtdfiletype_to_string.cc mtdfiletype_to_string.h \ - nc_utils_local.cc nc_utils_local.h \ - nc_grid.cc nc_grid.h \ 3d_moments.cc 3d_moments.h \ 2d_moments.cc 2d_moments.h \ fo_node.cc fo_node.h \ diff --git a/src/tools/other/mode_time_domain/Makefile.in b/src/tools/other/mode_time_domain/Makefile.in index a0f69996a1..532000c57e 100644 --- a/src/tools/other/mode_time_domain/Makefile.in +++ b/src/tools/other/mode_time_domain/Makefile.in @@ -102,7 +102,6 @@ CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(bindir)" PROGRAMS = $(bin_PROGRAMS) am_mtd_OBJECTS = mtd-mtd.$(OBJEXT) mtd-mtdfiletype_to_string.$(OBJEXT) \ - mtd-nc_utils_local.$(OBJEXT) mtd-nc_grid.$(OBJEXT) \ mtd-3d_moments.$(OBJEXT) mtd-2d_moments.$(OBJEXT) \ mtd-fo_node.$(OBJEXT) mtd-fo_node_array.$(OBJEXT) \ mtd-fo_graph.$(OBJEXT) mtd-mtd_config_info.$(OBJEXT) \ @@ -152,8 +151,7 @@ am__depfiles_remade = ./$(DEPDIR)/mtd-2d_att.Po \ ./$(DEPDIR)/mtd-mtd_partition.Po \ ./$(DEPDIR)/mtd-mtd_read_data.Po \ ./$(DEPDIR)/mtd-mtd_txt_output.Po \ - ./$(DEPDIR)/mtd-mtdfiletype_to_string.Po \ - ./$(DEPDIR)/mtd-nc_grid.Po ./$(DEPDIR)/mtd-nc_utils_local.Po + ./$(DEPDIR)/mtd-mtdfiletype_to_string.Po am__mv = mv -f AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) @@ -372,8 +370,6 @@ top_srcdir = @top_srcdir@ MAINTAINERCLEANFILES = Makefile.in mtd_SOURCES = mtd.cc \ mtdfiletype_to_string.cc mtdfiletype_to_string.h \ - nc_utils_local.cc nc_utils_local.h \ - nc_grid.cc nc_grid.h \ 3d_moments.cc 3d_moments.h \ 2d_moments.cc 2d_moments.h \ fo_node.cc fo_node.h \ @@ -544,8 +540,6 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mtd-mtd_read_data.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mtd-mtd_txt_output.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mtd-mtdfiletype_to_string.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mtd-nc_grid.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mtd-nc_utils_local.Po@am__quote@ # am--include-marker $(am__depfiles_remade): @$(MKDIR_P) $(@D) @@ -595,34 +589,6 @@ mtd-mtdfiletype_to_string.obj: mtdfiletype_to_string.cc @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mtd_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o mtd-mtdfiletype_to_string.obj `if test -f 'mtdfiletype_to_string.cc'; then $(CYGPATH_W) 'mtdfiletype_to_string.cc'; else $(CYGPATH_W) '$(srcdir)/mtdfiletype_to_string.cc'; fi` -mtd-nc_utils_local.o: nc_utils_local.cc -@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mtd_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT mtd-nc_utils_local.o -MD -MP -MF $(DEPDIR)/mtd-nc_utils_local.Tpo -c -o mtd-nc_utils_local.o `test -f 'nc_utils_local.cc' || echo '$(srcdir)/'`nc_utils_local.cc -@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/mtd-nc_utils_local.Tpo $(DEPDIR)/mtd-nc_utils_local.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='nc_utils_local.cc' object='mtd-nc_utils_local.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mtd_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o mtd-nc_utils_local.o `test -f 'nc_utils_local.cc' || echo '$(srcdir)/'`nc_utils_local.cc - -mtd-nc_utils_local.obj: nc_utils_local.cc -@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mtd_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT mtd-nc_utils_local.obj -MD -MP -MF $(DEPDIR)/mtd-nc_utils_local.Tpo -c -o mtd-nc_utils_local.obj `if test -f 'nc_utils_local.cc'; then $(CYGPATH_W) 'nc_utils_local.cc'; else $(CYGPATH_W) '$(srcdir)/nc_utils_local.cc'; fi` -@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/mtd-nc_utils_local.Tpo $(DEPDIR)/mtd-nc_utils_local.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='nc_utils_local.cc' object='mtd-nc_utils_local.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mtd_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o mtd-nc_utils_local.obj `if test -f 'nc_utils_local.cc'; then $(CYGPATH_W) 'nc_utils_local.cc'; else $(CYGPATH_W) '$(srcdir)/nc_utils_local.cc'; fi` - -mtd-nc_grid.o: nc_grid.cc -@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mtd_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT mtd-nc_grid.o -MD -MP -MF $(DEPDIR)/mtd-nc_grid.Tpo -c -o mtd-nc_grid.o `test -f 'nc_grid.cc' || echo '$(srcdir)/'`nc_grid.cc -@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/mtd-nc_grid.Tpo $(DEPDIR)/mtd-nc_grid.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='nc_grid.cc' object='mtd-nc_grid.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mtd_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o mtd-nc_grid.o `test -f 'nc_grid.cc' || echo '$(srcdir)/'`nc_grid.cc - -mtd-nc_grid.obj: nc_grid.cc -@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mtd_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT mtd-nc_grid.obj -MD -MP -MF $(DEPDIR)/mtd-nc_grid.Tpo -c -o mtd-nc_grid.obj `if test -f 'nc_grid.cc'; then $(CYGPATH_W) 'nc_grid.cc'; else $(CYGPATH_W) '$(srcdir)/nc_grid.cc'; fi` -@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/mtd-nc_grid.Tpo $(DEPDIR)/mtd-nc_grid.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='nc_grid.cc' object='mtd-nc_grid.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mtd_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o mtd-nc_grid.obj `if test -f 'nc_grid.cc'; then $(CYGPATH_W) 'nc_grid.cc'; else $(CYGPATH_W) '$(srcdir)/nc_grid.cc'; fi` - mtd-3d_moments.o: 3d_moments.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(mtd_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT mtd-3d_moments.o -MD -MP -MF $(DEPDIR)/mtd-3d_moments.Tpo -c -o mtd-3d_moments.o `test -f '3d_moments.cc' || echo '$(srcdir)/'`3d_moments.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/mtd-3d_moments.Tpo $(DEPDIR)/mtd-3d_moments.Po @@ -1067,8 +1033,6 @@ distclean: distclean-am -rm -f ./$(DEPDIR)/mtd-mtd_read_data.Po -rm -f ./$(DEPDIR)/mtd-mtd_txt_output.Po -rm -f ./$(DEPDIR)/mtd-mtdfiletype_to_string.Po - -rm -f ./$(DEPDIR)/mtd-nc_grid.Po - -rm -f ./$(DEPDIR)/mtd-nc_utils_local.Po -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags @@ -1137,8 +1101,6 @@ maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/mtd-mtd_read_data.Po -rm -f ./$(DEPDIR)/mtd-mtd_txt_output.Po -rm -f ./$(DEPDIR)/mtd-mtdfiletype_to_string.Po - -rm -f ./$(DEPDIR)/mtd-nc_grid.Po - -rm -f ./$(DEPDIR)/mtd-nc_utils_local.Po -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic diff --git a/src/tools/other/mode_time_domain/fo_graph.cc b/src/tools/other/mode_time_domain/fo_graph.cc index 48b031813a..2ecdf62c25 100644 --- a/src/tools/other/mode_time_domain/fo_graph.cc +++ b/src/tools/other/mode_time_domain/fo_graph.cc @@ -7,7 +7,6 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - //////////////////////////////////////////////////////////////////////// @@ -168,7 +167,8 @@ int FO_Graph::f_index(int f_num) const if ( (f_num < 0) || (f_num >= N_fcst) ) { - mlog << Error << "\n\n FO_Graph::f_index(int f_num) const -> range check error!\n\n"; + mlog << Error << "\nFO_Graph::f_index(int f_num) const -> " + << "range check error!\n\n"; exit ( 1 ); @@ -188,7 +188,8 @@ int FO_Graph::o_index(int o_num) const if ( (o_num < 0) || (o_num >= N_obs) ) { - mlog << Error << "\n\n FO_Graph::o_index(int o_num) const -> range check error!\n\n"; + mlog << Error << "\nFO_Graph::o_index(int o_num) const -> " + << "range check error!\n\n"; exit ( 1 ); @@ -214,7 +215,8 @@ if ( (n_f == 0) && (n_o == 0) ) trouble = true; if ( trouble ) { - mlog << Error << "\n\n FO_Graph::set_size(int n_f, int n_o) -> bad n_f or n_o value(s)\n\n"; + mlog << Error << "\nFO_Graph::set_size(int n_f, int n_o) -> " + << "bad n_f or n_o value(s)\n\n"; exit ( 1 ); @@ -229,9 +231,6 @@ N_total = N_fcst + N_obs; TheGraph = new FO_Node [N_total*N_total]; - - - // // done // @@ -365,7 +364,8 @@ void FO_Graph::erase_edges() if ( ! TheGraph ) { - mlog << Error << "\n\n FO_Graph::erase_edges() -> empty graph!\n\n"; + mlog << Error << "\nFO_Graph::erase_edges() -> " + << "empty graph!\n\n"; exit ( 1 ); @@ -394,7 +394,8 @@ void FO_Graph::do_dump_table(AsciiTable & table) const if ( ! TheGraph ) { - mlog << Error << "\n\n FO_Graph::dump_as_table() -> empty graph!\n\n"; + mlog << Error << "\nO_Graph::dump_as_table() -> " + << "empty graph!\n\n"; exit ( 1 ); @@ -410,16 +411,6 @@ const int obs_stop = obs_start + N_obs - 1; table.set_size(N_total + 2, N_total + 2); -// for (r=0; r<(table.nrows()); ++r) { -// -// for (c=0; c<(table.ncols()); ++c) { -// -// table.set_entry(r, c, '.'); -// -// } -// -// } - c = fcst_stop + 1; for (r=1; r<(table.nrows()); ++r) { @@ -499,7 +490,6 @@ for (j=0; j memory allocation error\n\n"; + mlog << Error << "\nFO_Node_Array::extend(int) -> " + << "memory allocation error\n\n"; exit ( 1 ); @@ -225,7 +222,8 @@ void FO_Node_Array::set_alloc_inc(int N) if ( N < 0 ) { - mlog << Error << "FO_Node_Array::set_alloc_int(int) -> bad value ... " << N << "\n\n"; + mlog << Error << "\nFO_Node_Array::set_alloc_int(int) -> " + << "bad value ... " << N << "\n\n"; exit ( 1 ); @@ -286,7 +284,8 @@ FO_Node & FO_Node_Array::operator[](int N) const if ( (N < 0) || (N >= Nelements) ) { - mlog << Error << "\n\n FO_Node_Array::operator[](int) -> range check error ... " << N << "\n\n"; + mlog << Error << "\nFO_Node_Array::operator[](int) -> " + << "range check error ... " << N << "\n\n"; exit ( 1 ); } diff --git a/src/tools/other/mode_time_domain/interest_calc.cc b/src/tools/other/mode_time_domain/interest_calc.cc index f3e98e21c6..630fb92855 100644 --- a/src/tools/other/mode_time_domain/interest_calc.cc +++ b/src/tools/other/mode_time_domain/interest_calc.cc @@ -7,7 +7,6 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - //////////////////////////////////////////////////////////////////////// @@ -361,6 +360,3 @@ return sum; //////////////////////////////////////////////////////////////////////// - - - diff --git a/src/tools/other/mode_time_domain/interest_calc.h b/src/tools/other/mode_time_domain/interest_calc.h index 120a53137b..7cf4d1362d 100644 --- a/src/tools/other/mode_time_domain/interest_calc.h +++ b/src/tools/other/mode_time_domain/interest_calc.h @@ -84,7 +84,6 @@ class InterestCalculator { double operator()(const PairAtt3D &); - }; diff --git a/src/tools/other/mode_time_domain/mm_engine.cc b/src/tools/other/mode_time_domain/mm_engine.cc index a170f64b64..1928c97594 100644 --- a/src/tools/other/mode_time_domain/mm_engine.cc +++ b/src/tools/other/mode_time_domain/mm_engine.cc @@ -7,7 +7,6 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - //////////////////////////////////////////////////////////////////////// @@ -208,12 +207,8 @@ for (j=0; j<(graph.n_fcst()); ++j) { if ( ! graph.has_fo_edge(j, k) ) continue; - // mlog << Debug(5) << "\n Merging fcst " << j << ", obs " << k << '\n' << flush; - part.merge_values(f_i, o_i); - // specialzed_dump(graph.n_fcst(), graph.n_obs(), p); - } // for k } // for j diff --git a/src/tools/other/mode_time_domain/mtd.cc b/src/tools/other/mode_time_domain/mtd.cc index 14cd5a18bb..aaad44203d 100644 --- a/src/tools/other/mode_time_domain/mtd.cc +++ b/src/tools/other/mode_time_domain/mtd.cc @@ -151,7 +151,6 @@ default_config_filename = replace_path(default_config_path); config.read_config(default_config_filename.c_str(), local_config_filename.c_str()); - // // determine the input file types // - check the config file for the file_type @@ -263,8 +262,6 @@ fcst_raw.regrid(to_grid, config.fcst_info->regrid()); // ConcatString prefix; -// int year, month, day, hour, minute, second; -// char junk[256]; prefix = make_output_prefix(config, obs_raw.start_valid_time()); @@ -394,10 +391,6 @@ MtdIntFile fo, oo; if ( have_pairs ) { - // mlog << Debug(5) << "\n Calculating pair attributes ... (Nf = " - // << (fcst_obj.n_objects()) << ", No = " - // << (obs_obj.n_objects()) << ")\n\n"; - for (j=0; j<(fcst_obj.n_objects()); ++j) { fo = fcst_obj.select(j + 1); @@ -412,9 +405,6 @@ if ( have_pairs ) { p.set_simple(); - // mlog << Debug(5) << " (F_" << j << ", O_" << k << ") " - // << p.total_interest() << '\n'; - pa_simple.add(p); } @@ -424,7 +414,6 @@ if ( have_pairs ) { } // if have_pairs - // // calculate 2d simple attributes // @@ -520,9 +509,6 @@ for (j=0; j<(obs_obj.n_objects()); ++j) { } // for j - - - // // create graph // @@ -554,26 +540,14 @@ if ( have_pairs ) { for (j=0; j 5 ) fcst_cluster_att.dump(cout); - mlog << Debug(2) << "Calculating 3D obs cluster attributes\n"; @@ -622,8 +594,6 @@ if ( have_pairs ) { att_3 = calc_3d_single_atts(mask, obs_raw, config.model.c_str(), config.inten_perc_value); - // if ( att.Xvelocity > 20.0 ) mask.write("w.nc"); - att_3.set_object_number(j + 1); // 1-based att_3.set_obs(); @@ -634,8 +604,6 @@ if ( have_pairs ) { } - // obs_cluster_att.dump(cout); - } // if have_pairs // @@ -670,12 +638,8 @@ if ( have_pairs ) { p.set_cluster(); - // p.set_total_interest(e.calc(p)); p.set_total_interest(-1.0); - // mlog << Debug(5) << " (F_" << j << ", O_" << k << ") " - // << p.total_interest() << '\n'; - pa_cluster.add(p); } @@ -787,9 +751,6 @@ if ( have_pairs ) { } // for j - - - } // if have pairs // diff --git a/src/tools/other/mode_time_domain/mtd_config_info.cc b/src/tools/other/mode_time_domain/mtd_config_info.cc index 97b9d90e29..c23af5a638 100644 --- a/src/tools/other/mode_time_domain/mtd_config_info.cc +++ b/src/tools/other/mode_time_domain/mtd_config_info.cc @@ -191,51 +191,6 @@ conf.read(default_file_name); if ( user_file_name ) conf.read(user_file_name); - // check the fuzzy-engine weights - // calculation of total interest assumes these tests - - // - // Update: these tests are not really needed since the InterestCalculator - // class checks this - // - -/* -bool all_zero = true; - -if ( is_eq(space_centroid_dist_wt, 0.0) ) space_centroid_dist_wt = 0.0; -else all_zero = false; - -if ( is_eq(time_centroid_delta_wt, 0.0) ) time_centroid_delta_wt = 0.0; -else all_zero = false; - -if ( is_eq(speed_delta_wt, 0.0) ) speed_delta_wt = 0.0; -else all_zero = false; - -if ( is_eq(direction_diff_wt, 0.0) ) direction_diff_wt = 0.0; -else all_zero = false; - -if ( is_eq(volume_ratio_wt, 0.0) ) volume_ratio_wt = 0.0; -else all_zero = false; - -if ( is_eq(axis_angle_diff_wt, 0.0) ) axis_angle_diff_wt = 0.0; -else all_zero = false; - -if ( is_eq(start_time_delta_wt, 0.0) ) start_time_delta_wt = 0.0; -else all_zero = false; - -if ( is_eq(end_time_delta_wt, 0.0) ) end_time_delta_wt = 0.0; -else all_zero = false; - - -if ( all_zero ) { - - mlog << Error << "\n\n MtdConfigInfo::read_config() -> all the fuzzy engine weights are zero!\n\n"; - - exit ( 1 ); - -} -*/ - // // done // @@ -259,10 +214,6 @@ void MtdConfigInfo::process_config(GrdFileType ftype, GrdFileType otype) bool status = false; double sum; - // Dump the contents of the config file - - // if(mlog.verbosity_level() >= 5) conf.dump(cout); - // Initialize clear(); @@ -298,19 +249,6 @@ void MtdConfigInfo::process_config(GrdFileType ftype, GrdFileType otype) fcst_info->set_dict(*(fcst_dict->lookup_dictionary(conf_key_field))); obs_info->set_dict(*(obs_dict->lookup_dictionary(conf_key_field))); - // Dump the contents of the VarInfo objects -// -// if(mlog.verbosity_level() >= 5) { -// mlog << Debug(5) -// << "Parsed forecast field:\n"; -// fcst_info->dump(cout); -// mlog << Debug(5) -// << "Parsed observation field:\n"; -// obs_info->dump(cout); -// } -// - - // No support for wind direction if(fcst_info->is_wind_direction() || obs_info->is_wind_direction()) { @@ -350,68 +288,6 @@ void MtdConfigInfo::process_config(GrdFileType ftype, GrdFileType otype) fcst_conv_thresh = fcst_dict->lookup_thresh(conf_key_conv_thresh); obs_conv_thresh = obs_dict->lookup_thresh(conf_key_conv_thresh); - // Conf: fcst.vld_thresh and obs.vld_thresh - - // fcst_vld_thresh = fcst_dict->lookup_double(conf_key_vld_thresh); - // obs_vld_thresh = obs_dict->lookup_double(conf_key_vld_thresh); - - // Conf: fcst.merge_thresh and obs.merge_thresh - - // fcst_merge_thresh = fcst_dict->lookup_thresh(conf_key_merge_thresh); - // obs_merge_thresh = obs_dict->lookup_thresh(conf_key_merge_thresh); - - // Conf: fcst.merge_flag and obs.merge_flag - - // fcst_merge_flag = int_to_mergetype(fcst_dict->lookup_int(conf_key_merge_flag)); - // obs_merge_flag = int_to_mergetype(obs_dict->lookup_int(conf_key_merge_flag)); - - // Conf: mask_missing_flag - - // mask_missing_flag = int_to_fieldtype(conf.lookup_int(conf_key_mask_missing_flag)); - - // Conf: match_flag - - // match_flag = int_to_matchtype(conf.lookup_int(conf_key_match_flag)); - - // Check that match_flag is set between 0 and 3 -/* - if(match_flag == MatchType::None && - (fcst_merge_flag != MergeType::None || obs_merge_flag != MergeType::None) ) { - mlog << Warning << "\nMtdConfigInfo::process_config() -> " - << "When matching is disabled (match_flag = " - << matchtype_to_string(match_flag) - << ") but merging is requested (fcst_merge_flag = " - << mergetype_to_string(fcst_merge_flag) - << ", obs_merge_flag = " - << mergetype_to_string(obs_merge_flag) - << ") any merging information will be discarded.\n\n"; - } -*/ - // Conf: max_centroid_dist - - // max_centroid_dist = conf.lookup_double(conf_key_max_centroid_dist); - - // Check that max_centroid_dist is > 0 -/* - if(max_centroid_dist <= 0) { - mlog << Warning << "\nMtdConfigInfo::process_config() -> " - << "max_centroid_dist (" << max_centroid_dist - << ") should be set > 0\n\n"; - } - -*/ - // Conf: mask.grid - -/* - mask_grid_name = conf.lookup_string(conf_key_mask_grid); - mask_grid_flag = int_to_fieldtype(conf.lookup_int(conf_key_mask_grid_flag)); - - // Conf: mask.poly - - mask_poly_name = conf.lookup_string(conf_key_mask_poly); - mask_poly_flag = int_to_fieldtype(conf.lookup_int(conf_key_mask_poly_flag)); -*/ - // Conf: weight dict = conf.lookup_dictionary(conf_key_weight); @@ -494,20 +370,6 @@ void MtdConfigInfo::process_config(GrdFileType ftype, GrdFileType otype) exit(1); } - // Conf: print_interest_thresh - - // print_interest_thresh = conf.lookup_double(conf_key_print_interest_thresh); - - // Check that print_interest_thresh is between 0 and 1. -/* - if(print_interest_thresh < 0 || print_interest_thresh > 1) { - mlog << Error << "\nMtdConfigInfo::process_config() -> " - << "print_interest_thresh (" << print_interest_thresh - << ") must be set between 0 and 1.\n\n"; - exit(1); - } -*/ - // Conf: nc_pairs_flag parse_nc_info(); @@ -516,10 +378,6 @@ void MtdConfigInfo::process_config(GrdFileType ftype, GrdFileType otype) parse_txt_info(); - // Conf: ct_stats_flag - - // ct_stats_flag = conf.lookup_bool(conf_key_ct_stats_flag); - // Conf: output_prefix output_prefix = conf.lookup_string(conf_key_output_prefix); @@ -564,8 +422,8 @@ e = conf.lookup(conf_key_nc_output); if ( !e ) { - mlog << Error - << "\n\n MtdConfigInfo::parse_nc_info() -> lookup failed for key \"" + mlog << Error << "\nMtdConfigInfo::parse_nc_info() -> " + << "lookup failed for key \"" << conf_key_nc_output << "\"\n\n"; exit ( 1 ); @@ -590,11 +448,9 @@ if ( type == BooleanType ) { if ( type != DictionaryType ) { - mlog << Error - << "\n\n MtdConfigInfo::parse_nc_info() -> bad type (" - << configobjecttype_to_string(type) - << ") for key \"" - << conf_key_nc_pairs_flag << "\"\n\n"; + mlog << Error << "\nMtdConfigInfo::parse_nc_info() -> " + << "bad type (" << configobjecttype_to_string(type) + << ") for key \"" << conf_key_nc_pairs_flag << "\"\n\n"; exit ( 1 ); @@ -608,10 +464,8 @@ Dictionary * d = e->dict_value(); nc_info.do_latlon = d->lookup_bool(conf_key_latlon_flag); nc_info.do_raw = d->lookup_bool(conf_key_raw_flag); -// nc_info.do_object_raw = d->lookup_bool(conf_key_object_raw_flag); nc_info.do_object_id = d->lookup_bool(conf_key_object_id_flag); nc_info.do_cluster_id = d->lookup_bool(conf_key_cluster_id_flag); -// nc_info.do_polylines = d->lookup_bool(conf_key_do_polylines_flag); // // done @@ -638,9 +492,8 @@ e = conf.lookup(key); if ( !e ) { - mlog << Error - << "\n\n MtdConfigInfo::parse_txt_info() -> lookup failed for key \"" - << key << "\"\n\n"; + mlog << Error << "\nMtdConfigInfo::parse_txt_info() -> " + << "lookup failed for key \"" << key << "\"\n\n"; exit ( 1 ); @@ -654,11 +507,9 @@ const ConfigObjectType type = e->type(); if ( type != DictionaryType ) { - mlog << Error - << "\n\n MtdConfigInfo::parse_txt_info() -> bad type (" - << configobjecttype_to_string(type) - << ") for key \"" - << key << "\"\n\n"; + mlog << Error << "\nMtdConfigInfo::parse_txt_info() -> " + << "bad type (" << configobjecttype_to_string(type) + << ") for key \"" << key << "\"\n\n"; exit ( 1 ); @@ -851,7 +702,6 @@ bool MtdNcOutInfo::all_false() const { -// bool status = do_latlon || do_raw || do_object_raw || do_object_id || do_cluster_id || do_polylines; bool status = do_latlon || do_raw || do_object_id || do_cluster_id; return !status; @@ -868,10 +718,8 @@ void MtdNcOutInfo::set_all_false() do_latlon = false; do_raw = false; -// do_object_raw = false; do_object_id = false; do_cluster_id = false; -// do_polylines = false; return; @@ -887,10 +735,8 @@ void MtdNcOutInfo::set_all_true() do_latlon = true; do_raw = true; -// do_object_raw = true; do_object_id = true; do_cluster_id = true; -// do_polylines = true; return; diff --git a/src/tools/other/mode_time_domain/mtd_file_base.cc b/src/tools/other/mode_time_domain/mtd_file_base.cc index 8bb5abd972..f46a43392b 100644 --- a/src/tools/other/mode_time_domain/mtd_file_base.cc +++ b/src/tools/other/mode_time_domain/mtd_file_base.cc @@ -7,7 +7,6 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - //////////////////////////////////////////////////////////////////////// @@ -23,11 +22,11 @@ #include "mtd_file.h" #include "mtd_partition.h" #include "mtd_nc_defs.h" -#include "nc_grid.h" -#include "nc_utils_local.h" #include "mtdfiletype_to_string.h" +#include "get_met_grid.h" #include "vx_math.h" +#include "vx_nc_util.h" using namespace std; using namespace netCDF; @@ -179,8 +178,6 @@ if ( G ) { G->dump(out, depth + 1); - // out << prefix << (G->xml_serialize()) << '\n'; - } else { out << prefix << "Grid = 0\n"; @@ -238,7 +235,8 @@ Grid MtdFileBase::grid() const if ( !G ) { - mlog << Error << "\n\n MtdFileBase::grid() const -> no grid!\n\n"; + mlog << Error << "\nMtdFileBase::grid() const -> " + << "no grid!\n\n"; exit ( 1 ); @@ -271,7 +269,8 @@ void MtdFileBase::latlon_to_xy(double lat, double lon, double & x, double & y) c if ( !G ) { - mlog << Error << "\n\n MtdFileBase::latlon_to_xy() -> no grid!\n\n"; + mlog << Error << "\nMtdFileBase::latlon_to_xy() -> " + << "no grid!\n\n"; exit ( 1 ); @@ -333,7 +332,8 @@ void MtdFileBase::xy_to_latlon(double x, double y, double & lat, double & lon) c if ( !G ) { - mlog << Error << "\n\n MtdFileBase::xy_to_latlon() -> no grid!\n\n"; + mlog << Error << "\nMtdFileBase::xy_to_latlon() -> " + << "no grid!\n\n"; exit ( 1 ); @@ -355,7 +355,8 @@ unixtime MtdFileBase::valid_time(int t) const if ( (t < 0) || ( t >= Nt) ) { - mlog << Error << "\n\n MtdFileBase::valid_time(int t) -> range check error\n\n"; + mlog << Error << "\nMtdFileBase::valid_time(int t) -> " + << "range check error\n\n"; exit ( 1 ); @@ -375,7 +376,8 @@ unixtime MtdFileBase::actual_valid_time(int t) const if ( (t < 0) || ( t >= (int)ActualValidTimes.size()) ) { - mlog << Error << "\n\n MtdFileBase::valid_time(int t) -> range check error\n\n"; + mlog << Error << "\nMtdFileBase::valid_time(int t) -> " + << "range check error\n\n"; exit ( 1 ); @@ -395,7 +397,8 @@ int MtdFileBase::lead_time(int index) const if ( (index < 0) || ( index >= Nt) ) { - mlog << Error << "\n\n MtdFileBase::lead_time(int t) -> range check error\n\n"; + mlog << Error << "\nMtdFileBase::lead_time(int t) -> " + << "range check error\n\n"; exit ( 1 ); @@ -413,7 +416,6 @@ void MtdFileBase::read(NcFile & f) { -//NcDim * dim = 0; NcDim dim; // Nx, Ny, Nt @@ -427,40 +429,40 @@ Ny = GET_NC_SIZE(dim); dim = get_nc_dim(&f, nt_dim_name); Nt = GET_NC_SIZE(dim); -//dim = 0; - // Grid G = new Grid; -read_nc_grid(f, *G); +read_netcdf_grid(&f, *G); // timestamp info -StartValidTime = parse_start_time(string_att(f, start_time_att_name)); +ConcatString s; + +get_att_value_string(&f, start_time_att_name, s); + +StartValidTime = timestring_to_unix(s.text()); -DeltaT = string_att_as_int (f, delta_t_att_name); +DeltaT = get_att_value_int(&f, delta_t_att_name); // FileType -// ConcatString s = (string)string_att(f, filetype_att_name); -ConcatString s; bool status = false; -s.add(string_att(f, filetype_att_name)); +get_att_value_string(&f, filetype_att_name, s); status = string_to_mtdfiletype(s.text(), FileType); if ( ! status ) { - mlog << Error << "\n\n MtdFileBase::read(NcFile &) -> unable to parse filetype string \"" + mlog << Error << "\nMtdFileBase::read(NcFile &) -> " + << "unable to parse filetype string \"" << s << "\"\n\n"; exit ( 1 ); } - // // done // @@ -480,19 +482,20 @@ void MtdFileBase::write(NcFile & f) const char junk[256]; ConcatString s; - // Nx, Ny, Nt + // Add the time dimension -add_dim(&f, nx_dim_name, Nx); -add_dim(&f, ny_dim_name, Ny); add_dim(&f, nt_dim_name, Nt); // Grid -write_nc_grid(f, *G); +NcDim ny_dim; +NcDim nx_dim; + +write_netcdf_proj(&f, *G, ny_dim, nx_dim); // timestamp info -s = start_time_string(StartValidTime); +s = unix_to_yyyymmdd_hhmmss(StartValidTime); add_att(&f, start_time_att_name, s.text()); @@ -508,7 +511,6 @@ s = mtdfiletype_to_string(FileType); add_att(&f, filetype_att_name, s.text()); - // // done // @@ -527,8 +529,8 @@ void MtdFileBase::set_lead_time(int index, int value) if ( (index < 0) || (index >= Nt) ) { - mlog << Error - << "MtdFileBase::set_lead_time(int index, int value) -> range check error on index ... " + mlog << Error << "MtdFileBase::set_lead_time(int index, int value) -> " + << "range check error on index ... " << index << "\n\n"; exit ( 1 ); @@ -553,7 +555,3 @@ return; //////////////////////////////////////////////////////////////////////// - - - - diff --git a/src/tools/other/mode_time_domain/mtd_file_float.cc b/src/tools/other/mode_time_domain/mtd_file_float.cc index f76f349aa0..bdfacb4e46 100644 --- a/src/tools/other/mode_time_domain/mtd_file_float.cc +++ b/src/tools/other/mode_time_domain/mtd_file_float.cc @@ -24,9 +24,9 @@ #include "mtd_file.h" #include "mtd_partition.h" #include "mtd_nc_defs.h" -#include "nc_utils_local.h" #include "vx_math.h" +#include "vx_nc_util.h" using namespace std; using namespace netCDF; @@ -168,7 +168,6 @@ if ( f.Data ) { } - // // done // @@ -255,7 +254,8 @@ void MtdFloatFile::set_spatial_radius(int spatial_r) if ( spatial_r < 0 ) { - mlog << Error << "\n\n MtdFloatFile::set_spatial_radius(int) -> bad value ... " << spatial_r << "\n\n"; + mlog << Error << "\nMtdFloatFile::set_spatial_radius(int) -> " + << "bad value ... " << spatial_r << "\n\n"; exit ( 1 ); @@ -277,7 +277,8 @@ void MtdFloatFile::set_time_window(int beg, int end) if ( end < beg ) { - mlog << Error << "\n\n MtdFloatFile::set_time_window(int) -> bad values ... " << beg << " and " << end << "\n\n"; + mlog << Error << "\nMtdFloatFile::set_time_window(int) -> " + << "bad values ... " << beg << " and " << end << "\n\n"; exit ( 1 ); @@ -317,7 +318,8 @@ void MtdFloatFile::put(const DataPlane & plane, const int t) if ( (plane.nx() != Nx) || (plane.ny() != Ny) ) { - mlog << Error << "\n\n MtdFloatFile::put(const DataPlane &, const int) -> plane wrong size!\n\n"; + mlog << Error << "\nMtdFloatFile::put(const DataPlane &, const int) -> " + << "plane wrong size!\n\n"; exit ( 1 ); @@ -325,7 +327,8 @@ if ( (plane.nx() != Nx) || (plane.ny() != Ny) ) { if ( (t < 0) || (t >= Nt) ) { - mlog << Error << "\n\n MtdFloatFile::put(const DataPlane &, const int) -> bad time\n\n"; + mlog << Error << "\nMtdFloatFile::put(const DataPlane &, const int) -> " + << "bad time\n\n"; exit ( 1 ); @@ -359,8 +362,6 @@ for (x=0; x no data!\n\n"; + mlog << Error << "\nMtdFloatFile::threshold(double, MtdIntFile &) const -> " + << "no data!\n\n"; exit ( 1 ); @@ -542,7 +544,8 @@ void MtdFloatFile::threshold(const SingleThresh & t, MtdIntFile & out) const if ( !Data ) { - mlog << Error << "\n\n MtdFloatFile::threshold(double, MtdIntFile &) const -> no data!\n\n"; + mlog << Error << "\nMtdFloatFile::threshold(double, MtdIntFile &) const -> " + << "no data!\n\n"; exit ( 1 ); @@ -592,7 +595,6 @@ out.set_threshold(-9999.0); out.set_filetype(mtd_file_mask); - // // done // @@ -629,11 +631,9 @@ void MtdFloatFile::read(NcFile & f) { -//NcVar * var = 0; NcVar var; - // // read the base class stuff // @@ -642,8 +642,8 @@ MtdFileBase::read(f); // DataMin, DataMax -DataMin = string_att_as_double (f, min_value_att_name); -DataMax = string_att_as_double (f, max_value_att_name); +DataMin = (float) get_att_value_double(&f, min_value_att_name); +DataMax = (float) get_att_value_double(&f, max_value_att_name); // Data @@ -651,24 +651,6 @@ set_size(Nx, Ny, Nt); var = get_nc_var(&f, data_field_name); -//if ( !(var->set_cur(0, 0, 0)) ) { -// -// mlog << Error << "\n\n MtdFloatFile::read() -> trouble setting corner\n\n"; -// -// exit ( 1 ); -// -//} -// -//// const time_t t_start = time(0); // for timing the data read operation -// -//if ( ! (var->get(Data, Nt, Ny, Nx)) ) { -// -// mlog << Error << "\n\n MtdFloatFile::read(const char *) -> trouble getting data\n\n"; -// -// exit ( 1 ); -// -//} - LongArray offsets; // {0,0,0}; LongArray lengths; // {Nt, Ny, Nx}; @@ -679,19 +661,15 @@ lengths.add(Nt); lengths.add(Ny); lengths.add(Nx); -//if ( ! get_nc_data(&var, Data, (long *){Nt, Ny, Nx}, (long *){0,0,0}) ) { if ( ! get_nc_data(&var, Data, lengths, offsets) ) { - mlog << Error << "\n\n MtdFloatFile::read(const char *) -> trouble getting data\n\n"; + mlog << Error << "\nMtdFloatFile::read(const char *) -> " + << "trouble getting data\n\n"; exit ( 1 ); } -// const time_t t_stop = time(0); // for timing the data read operation - -// mlog << Debug(5) << "\n\n MtdFloatFile::read(): Time to read data = " << (t_stop - t_start) << " seconds\n\n" << flush; - // // done // @@ -708,13 +686,9 @@ void MtdFloatFile::write(NcFile & f) const { -//NcDim * nx_dim = 0; -//NcDim * ny_dim = 0; -//NcDim * nt_dim = 0; NcDim nx_dim; NcDim ny_dim; NcDim nt_dim; -//NcVar * data_var = 0; NcVar data_var ; const char format [] = "%.3f"; char junk[256]; @@ -764,24 +738,6 @@ add_var(&f, data_field_name, ncFloat, nt_dim, ny_dim, nx_dim); data_var = get_nc_var(&f, data_field_name); -//if ( !(data_var->set_cur(0, 0, 0)) ) { -// -// mlog << Error << "\n\n MtdFloatFile::write() -> trouble setting corner on data field\n\n"; -// -// exit ( 1 ); -// -//} -// -//// const time_t t_start = time(0); // for timing the data write operation -// -//if ( !(data_var->put(Data, Nt, Ny, Nx)) ) { -// -// mlog << Error << "\n\n MtdFloatFile::write() -> trouble with put in data field\n\n"; -// -// exit ( 1 ); -// -//} - LongArray offsets; // {0,0,0}; LongArray lengths; // {Nt, Ny, Nx}; @@ -792,19 +748,15 @@ lengths.add(Nt); lengths.add(Ny); lengths.add(Nx); -//if ( ! get_nc_data(&data_var, Data, (long *){Nt, Ny, Nx}, (long *){0,0,0}) ) { if ( ! get_nc_data(&data_var, Data, lengths, offsets) ) { - mlog << Error << "\n\n MtdFloatFile::read(const char *) -> trouble getting data\n\n"; + mlog << Error << "\nMtdFloatFile::read(const char *) -> " + << "trouble getting data\n\n"; exit ( 1 ); } -// const time_t t_stop = time(0); // for timing the data write operation - -// mlog << Debug(5) << "\n\n MtdFloatFile::write(): Time to write data = " << (t_stop - t_start) << " seconds\n\n" << flush; - // // done // @@ -825,11 +777,10 @@ NcFile f(_filename, NcFile::replace); if ( IS_INVALID_NC(f) ) { - mlog << Error << "\n\n MtdFloatFile::write(const char *) -> unable to open netcdf output file \"" << _filename << "\"\n\n"; + mlog << Error << "\nMtdFloatFile::write(const char *) -> " + << "unable to open netcdf output file: " << _filename << "\n\n"; - // exit ( 1 ); - - return; + exit ( 1 ); } @@ -853,7 +804,8 @@ MtdFloatFile MtdFloatFile::const_t_slice(int t) const if ( (t < 0) || (t >= Nt) ) { - mlog << Error << "\n\n MtdFloatFile MtdFloatFile::const_t_slice(int) const -> range check error\n\n"; + mlog << Error << "\nMtdFloatFile MtdFloatFile::const_t_slice(int) const -> " + << "range check error\n\n"; exit ( 1 ); @@ -921,7 +873,8 @@ void MtdFloatFile::get_data_plane(const int t, DataPlane & out) if ( (t < 0) || (t >= Nt) ) { - mlog << Error << "\n\n MtdFloatFile::get_data_plane() -> range check error on t\n\n"; + mlog << Error << "\nMtdFloatFile::get_data_plane() -> " + << "range check error on t\n\n"; exit ( 1 ); @@ -956,9 +909,6 @@ for (x=0; x= Nt) ) { - mlog << Error << "\n\n " << method_name << "range check error on t\n\n"; + mlog << Error << "\n" << method_name + << "range check error on t\n\n"; exit ( 1 ); @@ -985,7 +937,8 @@ if ( (t < 0) || (t >= Nt) ) { if ( (d.nx() != Nx) || (d.ny() != Ny) ) { - mlog << Error << "\n\n " << method_name << "data plane is wrong size!\n\n"; + mlog << Error << "\n" << method_name + << "data plane is wrong size!\n\n"; exit ( 1 ); @@ -1002,8 +955,9 @@ for (x=0; x=data_cnt) { - mlog << Debug(4) << method_name << "offset " << n - << " is out of range (" << " from " << x << ", " << y <<", " << t <<")\n"; + mlog << Debug(4) << method_name + << "offset " << n << " is out of range (from " + << x << ", " << y <<", " << t <<")\n"; continue; } @@ -1085,7 +1039,3 @@ return; //////////////////////////////////////////////////////////////////////// - - - - diff --git a/src/tools/other/mode_time_domain/mtd_file_int.cc b/src/tools/other/mode_time_domain/mtd_file_int.cc index 92f6e214a6..2cbe00e400 100644 --- a/src/tools/other/mode_time_domain/mtd_file_int.cc +++ b/src/tools/other/mode_time_domain/mtd_file_int.cc @@ -24,9 +24,9 @@ #include "mtd_file.h" #include "mtd_partition.h" #include "mtd_nc_defs.h" -#include "nc_utils_local.h" #include "vx_math.h" +#include "vx_nc_util.h" using namespace std; using namespace netCDF; @@ -302,7 +302,8 @@ void MtdIntFile::set_radius(int r) if ( r < 0 ) { - mlog << Error << "\n MtdIntFile::set_radius(int) -> bad value ... " << r << "\n\n"; + mlog << Error << "\nMtdIntFile::set_radius(int) -> " + << "bad value ... " << r << "\n\n"; exit ( 1 ); @@ -325,7 +326,8 @@ void MtdIntFile::set_time_window(int beg, int end) if ( end < beg ) { - mlog << Error << "\n MtdIntFile::set_time_window(int) -> bad values ... " << beg << " and " << end << "\n\n"; + mlog << Error << "\nMtdIntFile::set_time_window(int) -> " + << "bad values ... " << beg << " and " << end << "\n\n"; exit ( 1 ); @@ -347,14 +349,6 @@ void MtdIntFile::set_threshold(double t) { -// if ( t < 0.0 ) { -// -// mlog << Error << "\n MtdIntFile::set_threshold(double) -> bad value ... " << t << "\n\n"; -// -// exit ( 1 ); -// -// } - Threshold = t; return; @@ -421,11 +415,8 @@ void MtdIntFile::read(NcFile & f) { -//NcVar * var = 0; NcVar var ; - - // // read the base class stuff // @@ -434,8 +425,8 @@ MtdFileBase::read(f); // DataMin, DataMax -DataMin = string_att_as_double (f, min_value_att_name); -DataMax = string_att_as_double (f, max_value_att_name); +DataMin = get_att_value_int(&f, min_value_att_name); +DataMax = get_att_value_int(&f, max_value_att_name); // Data @@ -443,24 +434,6 @@ set_size(Nx, Ny, Nt); var = get_nc_var(&f, data_field_name); -//if ( !(var->set_cur(0, 0, 0)) ) { -// -// mlog << Error << "\n MtdIntFile::read() -> trouble setting corner\n\n"; -// -// exit ( 1 ); -// -//} -// -//// const time_t t_start = time(0); // for timing the data read operation -// -//if ( ! (var->get(Data, Nt, Ny, Nx)) ) { -// -// mlog << Error << "\n MtdIntFile::read(const char *) -> trouble getting data\n\n"; -// -// exit ( 1 ); -// -//} - LongArray offsets; // {0,0,0}; LongArray lengths; // {Nt, Ny, Nx}; @@ -471,19 +444,15 @@ lengths.add(Nt); lengths.add(Ny); lengths.add(Nx); -//if ( ! get_nc_data(&var, Data, (long *){Nt, Ny, Nx}, (long *){0,0,0}) ) { if ( ! get_nc_data(&var, Data, lengths, offsets) ) { - mlog << Error << "\n MtdIntFile::read(const char *) -> trouble getting data\n\n"; + mlog << Error << "\nMtdIntFile::read(const char *) -> " + << "trouble getting data\n\n"; exit ( 1 ); } -// const time_t t_stop = time(0); // for timing the data read operation - -// mlog << Debug(5) << "\n MtdIntFile::read(): Time to read data = " << (t_stop - t_start) << " seconds\n\n" << flush; - // // done // @@ -500,23 +469,16 @@ void MtdIntFile::write(NcFile & f) const { -//NcDim * nx_dim = 0; -//NcDim * ny_dim = 0; -//NcDim * nt_dim = 0; -//NcDim * n_obj_dim = 0; -NcDim nx_dim ; -NcDim ny_dim ; -NcDim nt_dim ; +NcDim nx_dim; +NcDim ny_dim; +NcDim nt_dim; NcDim n_obj_dim; -//NcVar * data_var = 0; -//NcVar * volumes_var = 0; -NcVar data_var ; -NcVar volumes_var ; +NcVar data_var; +NcVar volumes_var; const char format [] = "%d"; char junk[256]; const bool is_split = (ObjVolume != 0); - // // write stuff from parent class // @@ -571,8 +533,6 @@ add_att(&f, threshold_att_name, Threshold); data_var = add_var(&f, data_field_name, ncInt, nt_dim, ny_dim, nx_dim); -//data_var = get_nc_var(&f, data_field_name); - LongArray offsets; // {0,0,0}; LongArray lengths; // {Nt, Ny, Nx}; @@ -585,30 +545,13 @@ lengths.add(Nx); if ( ! put_nc_data(&data_var, Data, lengths, offsets) ) { - mlog << Error << "\n MtdIntFile::write(const char *) -> trouble getting data\n\n"; + mlog << Error << "\nMtdIntFile::write(const char *) -> " + << "trouble getting data\n\n"; exit ( 1 ); } -//if ( !(data_var->set_cur(0, 0, 0)) ) { -// -// mlog << Error << "\n MtdIntFile::write() -> trouble setting corner on data field\n\n"; -// -// exit ( 1 ); -// -//} -// -//// const time_t t_start = time(0); // for timing the data write operation -// -//if ( !(data_var->put(Data, Nt, Ny, Nx)) ) { -// -// mlog << Error << "\n MtdIntFile::write() -> trouble writing data field\n\n"; -// -// exit ( 1 ); -// -//} - // // volumes, if needed // @@ -617,11 +560,10 @@ if ( is_split ) { volumes_var = add_var(&f, volumes_name, ncInt, n_obj_dim); - //volumes_var = get_nc_var(&f, volumes_name); - if ( !(put_nc_data(&volumes_var, ObjVolume, Nobjects, 0)) ) { - mlog << Error << "\n MtdIntFile::write() -> trouble writing object volumes\n\n"; + mlog << Error << "\nMtdIntFile::write() -> " + << "trouble writing object volumes\n\n"; exit ( 1 ); @@ -629,10 +571,6 @@ if ( is_split ) { } // if is_split -// const time_t t_stop = time(0); // for timing the data write operation - -// mlog << Debug(5) << "\n MtdIntFile::write(): Time to write data = " << (t_stop - t_start) << " seconds\n\n" << flush; - // // done // @@ -653,7 +591,8 @@ NcFile f(_filename, NcFile::replace); if ( IS_INVALID_NC(f) ) { - mlog << Error << "\n MtdIntFile::write(const char *) -> unable to open netcdf output file \"" << _filename << "\"\n\n"; + mlog << Error << "\nMtdIntFile::write(const char *) -> " + << "unable to open netcdf output file: " << _filename << "\n\n"; // exit ( 1 ); @@ -681,7 +620,8 @@ MtdIntFile MtdIntFile::const_t_slice(const int t) const if ( (t < 0) || (t >= Nt) ) { - mlog << Error << "\n MtdIntFile MtdIntFile::const_t_slice(int) const -> range check error\n\n"; + mlog << Error << "\nMtdIntFile MtdIntFile::const_t_slice(int) const -> " + << "range check error\n\n"; exit ( 1 ); @@ -750,7 +690,8 @@ MtdIntFile MtdIntFile::const_t_mask(const int t, const int obj_num) const // if ( (t < 0) || (t >= Nt) ) { - mlog << Error << "\n MtdIntFile MtdIntFile::const_t_mask(int) const -> range check error\n\n"; + mlog << Error << "\nMtdIntFile MtdIntFile::const_t_mask(int) const -> " + << "range check error\n\n"; exit ( 1 ); @@ -938,7 +879,8 @@ void MtdIntFile::zero_border(int n) if ( !Data ) { - mlog << Error << "\n MtdIntFile::zero_border(int) -> no data field!\n\n"; + mlog << Error << "\nMtdIntFile::zero_border(int) -> " + << "no data field!\n\n"; exit ( 1 ); @@ -946,7 +888,8 @@ if ( !Data ) { if ( 2*n >= min(Nx, Ny) ) { - mlog << Error << "\n MtdIntFile::zero_border(int) -> border size too large!\n\n"; + mlog << Error << "\nMtdIntFile::zero_border(int) -> " + << "border size too large!\n\n"; exit ( 1 ); @@ -999,7 +942,8 @@ void MtdIntFile::set_to_zeroes() if ( !Data ) { - mlog << Error << "\n MtdIntFile::set_to_zeroes() -> no data!\n\n"; + mlog << Error << "\nMtdIntFile::set_to_zeroes() -> " + << "no data!\n\n"; exit ( 1 ); @@ -1025,7 +969,8 @@ MtdIntFile MtdIntFile::split_const_t(int & n_shapes) const if ( Nt != 1 ) { - mlog << Error << "\n split_const_t(int &) -> not const-time slice!\n\n"; + mlog << Error << "\nsplit_const_t(int &) -> " + << "not const-time slice!\n\n"; exit ( 1 ); @@ -1041,7 +986,6 @@ Mtd_Partition p; const MtdIntFile & id = *this; - d.set_size(Nx, Ny, 1); d.set_grid(*G); @@ -1261,7 +1205,8 @@ int MtdIntFile::volume(int k) const if ( !ObjVolume ) { - mlog << Error << "\n MtdIntFile::volume(int) -> field not split!\n\n"; + mlog << Error << "\nMtdIntFile::volume(int) -> " + << "field not split!\n\n"; exit ( 1 ); @@ -1269,7 +1214,8 @@ if ( !ObjVolume ) { if ( (k < 0) || (k >= Nobjects) ) { - mlog << Error << "\n MtdIntFile::volume(int) -> range check error!\n\n"; + mlog << Error << "\nMtdIntFile::volume(int) -> " + << "range check error!\n\n"; exit ( 1 ); @@ -1290,7 +1236,8 @@ int MtdIntFile::total_volume() const if ( !ObjVolume ) { - mlog << Error << "\n MtdIntFile::total_volume() -> field not split!\n\n"; + mlog << Error << "\nMtdIntFile::total_volume() -> " + << "field not split!\n\n"; exit ( 1 ); @@ -1354,21 +1301,8 @@ int j, k; const int n3 = Nx*Ny*Nt; int * old_to_new = (int *) nullptr; int * new_volumes = (int *) nullptr; -// double * new_intensities = (double *) nullptr; int * d = Data; - -// if ( n_new == 0 ) { -// -// mlog << Error << "\n MtdIntFile::sift_objects() -> no objects left!\n\n"; -// -// exit ( 1 ); -// -// } - - - - if ( n_new > 0 ) { old_to_new = new int [Nobjects]; @@ -1381,17 +1315,12 @@ if ( n_new > 0 ) { new_volumes[j] = ObjVolume[new_to_old[j]]; - // new_intensities[j] = MaxConvIntensity[new_to_old[j]]; - } for (j=0; j 0 ) { } -// mlog << Debug(5) << "replace count = " << replace_count << '\n' << flush; -// mlog << Debug(5) << "zero count = " << zero_count << '\n' << flush; - // // rewire // @@ -1539,7 +1465,8 @@ for (x=0; x empty object!\n\n"; + mlog << Error << "\nMtdIntFile::calc_3d_centroid() const -> " + << "empty object!\n\n"; exit ( 1 ); @@ -1587,15 +1514,7 @@ for (x=0; x empty object!\n\n"; - - // exit ( 1 ); - - return; - -} +if ( count == 0 ) return; xbar /= count; ybar /= count; @@ -1641,7 +1560,8 @@ MtdIntFile MtdIntFile::select(int n) const // 1-based if ( (n < 1) || (n > Nobjects) ) { - mlog << Error << "\n MtdIntFile::select(int) -> range check error on n ... " + mlog << Error << "\nMtdIntFile::select(int) -> " + << "range check error on n ... " << "NObjects = " << Nobjects << " ... " << "n = " << n << "\n\n"; @@ -1693,7 +1613,8 @@ MtdIntFile MtdIntFile::select_cluster(const IntArray & a) const // 1-based if ( (a.min() < 0) || (a.max() > Nobjects) ) { - mlog << Error << "\n MtdIntFile::select_cluster(const IntArray &) -> range check error\n\n"; + mlog << Error << "\nMtdIntFile::select_cluster(const IntArray &) -> " + << "range check error\n\n"; exit ( 1 ); @@ -1757,7 +1678,8 @@ int MtdIntFile::x_left(const int y) const if ( (y < 0) || (y >= Ny) ) { - mlog << Error << "\n MtdIntFile::x_left(int) -> range check error\n\n"; + mlog << Error << "\nMtdIntFile::x_left(int) -> " + << "range check error\n\n"; exit ( 1 ); @@ -1786,7 +1708,8 @@ int MtdIntFile::x_right(const int y) const if ( (y < 0) || (y >= Ny) ) { - mlog << Error << "\n MtdIntFile::x_right(int) -> range check error\n\n"; + mlog << Error << "\nMtdIntFile::x_right(int) -> " + << "range check error\n\n"; exit ( 1 ); @@ -1875,7 +1798,8 @@ Mtd_2D_Moments MtdIntFile::calc_2d_moments() const if ( Nt != 1 ) { - mlog << Error << "\n MtdIntFile::calc_2d_moments() const -> not a 2D object!\n\n"; + mlog << Error << "\nMtdIntFile::calc_2d_moments() const -> " + << "not a 2D object!\n\n"; exit ( 1 ); @@ -1936,9 +1860,6 @@ MtdIntFile after; MtdIntFile rv; Mtd_Partition p; const int zero_border_size = 2; -// int imin, imax; - - // // find the partition @@ -1979,8 +1900,6 @@ for (j=1; j<(mask.nt()); ++j) { } -// p.dump(cout); - n_shapes = p.n_elements(); // @@ -2017,7 +1936,8 @@ for (t=0; t<(mask.nt()); ++t) { if ( nc < 0 ) { - mlog << Error << "\n split(const MtdIntFile &, int &) -> can't find cell!\n\n"; + mlog << Error << "\nsplit(const MtdIntFile &, int &) -> " + << "can't find cell!\n\n"; exit ( 1 ); @@ -2051,7 +1971,8 @@ void adjust_obj_numbers(MtdIntFile & s, int delta) if ( s.nt() != 1 ) { - mlog << Error << "\n adjust_obj_numbers() -> not const-time slice!\n\n"; + mlog << Error << "\nadjust_obj_numbers() -> " + << "not const-time slice!\n\n"; exit ( 1 ); @@ -2106,8 +2027,6 @@ for (x=0; x trouble opening output file \"" - << output_filename << "\"\n\n"; + mlog << Error << "\ndo_mtd_nc_output() -> " + << "trouble opening output file: " + << output_filename << "\n\n"; exit ( 1 ); @@ -68,11 +69,9 @@ const bool have_pairs = (fcst_obj.n_objects() != 0) && ( obs_obj.n_objects() != 0); // - // dimensions + // add time dimension // -nx_dim = add_dim(&out, nx_dim_name, fcst_raw.nx()); -ny_dim = add_dim(&out, ny_dim_name, fcst_raw.ny()); nt_dim = add_dim(&out, nt_dim_name, fcst_raw.nt()); // @@ -82,7 +81,7 @@ nt_dim = add_dim(&out, nt_dim_name, fcst_raw.nt()); write_netcdf_global(&out, output_filename, "MTD", config.model.c_str(), config.obtype.c_str(), config.desc.c_str()); -write_nc_grid(out, fcst_raw.grid()); +write_netcdf_proj(&out, fcst_raw.grid(), ny_dim, nx_dim); // // variables @@ -142,19 +141,18 @@ NcFile out(output_filename, NcFile::replace); if ( IS_INVALID_NC(out) ) { - mlog << Error << "\n\n do_mtd_nc_output[single]() -> trouble opening output file \"" - << output_filename << "\"\n\n"; + mlog << Error << "\ndo_mtd_nc_output[single]() -> " + << "trouble opening output file: " + << output_filename << "\n\n"; exit ( 1 ); } // - // dimensions + // add time dimension // -nx_dim = add_dim(&out, nx_dim_name, raw.nx()); -ny_dim = add_dim(&out, ny_dim_name, raw.ny()); nt_dim = add_dim(&out, nt_dim_name, raw.nt()); // @@ -164,7 +162,7 @@ nt_dim = add_dim(&out, nt_dim_name, raw.nt()); write_netcdf_global(&out, output_filename, "MTD", config.model.c_str(), config.obtype.c_str(), config.desc.c_str()); -write_nc_grid(out, raw.grid()); +write_netcdf_proj(&out, raw.grid(), ny_dim, nx_dim); // // variables @@ -220,7 +218,6 @@ add_att(&lon_var, "long_name", "Longitude"); float * lat_data = new float [nx*ny]; float * lon_data = new float [nx*ny]; - Lat = lat_data; Lon = lon_data; @@ -268,7 +265,7 @@ const int ny = raw.ny(); const int nt = raw.nt(); ConcatString s; -const char * const name = ( is_fcst ? fcst_raw_name : obs_raw_name ); +const string name = ( is_fcst ? fcst_raw_name : obs_raw_name ); NcVar var = add_var(&out, name, ncFloat, nt_dim, ny_dim, nx_dim); @@ -304,7 +301,7 @@ const int ny = id.ny(); const int nt = id.nt(); ConcatString s; -const char * const name = ( is_fcst ? fcst_obj_id_name : obs_obj_id_name ); +const string name = ( is_fcst ? fcst_obj_id_name : obs_obj_id_name ); NcVar var = add_var(&out, name, ncInt, nt_dim, ny_dim, nx_dim); @@ -319,7 +316,6 @@ long offsets[3] = {0,0,0}; long lengths[3] = {nt,ny, nx}; put_nc_data(&var, id.data(), lengths, offsets); - // // done // @@ -350,7 +346,7 @@ const int n3 = nx*ny*nt; out_data = new int [n3]; -const char * const name = ( is_fcst ? fcst_clus_id_name : obs_clus_id_name ); +const string name = ( is_fcst ? fcst_clus_id_name : obs_clus_id_name ); NcVar var = add_var(&out, name, ncInt, nt_dim, ny_dim, nx_dim); diff --git a/src/tools/other/mode_time_domain/mtd_nc_output.h b/src/tools/other/mode_time_domain/mtd_nc_output.h index c0aa4a5aa0..c0d8471b4f 100644 --- a/src/tools/other/mode_time_domain/mtd_nc_output.h +++ b/src/tools/other/mode_time_domain/mtd_nc_output.h @@ -19,8 +19,6 @@ #include "mtd_nc_defs.h" -#include "nc_grid.h" -#include "nc_utils_local.h" #include "mtd_file_float.h" #include "mtd_file_int.h" diff --git a/src/tools/other/mode_time_domain/mtd_partition.cc b/src/tools/other/mode_time_domain/mtd_partition.cc index 22bf007ef7..192ed95de9 100644 --- a/src/tools/other/mode_time_domain/mtd_partition.cc +++ b/src/tools/other/mode_time_domain/mtd_partition.cc @@ -7,7 +7,6 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - //////////////////////////////////////////////////////////////////////// @@ -199,28 +198,6 @@ return; } -//////////////////////////////////////////////////////////////////////// - -/* -bool EquivalenceClass::has(int k) const - -{ - -int j; -int * e = E; - -for (j=0; j= Nelements) ) { - mlog << Error << "\n\n EquivalenceClass::element(int) const -> range check error\n\n"; + mlog << Error << "\nEquivalenceClass::element(int) const -> " + << "range check error\n\n"; exit ( 1 ); @@ -529,28 +507,6 @@ return; } -//////////////////////////////////////////////////////////////////////// - -/* -bool Mtd_Partition::has(int k) const - -{ - -int j; -EquivalenceClass ** c = C; - -for (j=0; jhas(k) ) return true; - -} - - -return false; - -} -*/ - //////////////////////////////////////////////////////////////////////// @@ -560,7 +516,8 @@ bool Mtd_Partition::has(int index, int k) const if ( (index < 0) || (index >= Nelements) ) { - mlog << Error << "\n\n Mtd_Partition::has(int index, int k) const -> range check error on index\n\n"; + mlog << Error << "\nMtd_Partition::has(int index, int k) const -> " + << "range check error on index\n\n"; exit ( 1 ); @@ -602,7 +559,8 @@ void Mtd_Partition::merge_classes(int nclass_1, int nclass_2) if ( (nclass_1 < 0) || (nclass_1 >= Nelements) || (nclass_2 < 0) || (nclass_2 >= Nelements) ) { - mlog << Error << "\n\n Mtd_Partition::merge_classes() -> range check error\n\n"; + mlog << Error << "\nMtd_Partition::merge_classes() -> " + << "range check error\n\n"; exit ( 1 ); @@ -662,7 +620,8 @@ nclass_2 = which_class(value_2); if ( (nclass_1 < 0) || (nclass_2 < 0) ) { - mlog << Error << "\n\n Mtd_Partition::merge_values() -> bad values ... " + mlog << Error << "\nMtd_Partition::merge_values() -> " + << "bad values ... " << "(value_1, value_2) = " << value_1 << ", " << value_2 << " ... " << "(nclass_1, nclass_2) = " << nclass_1 << ", " << nclass_2 << "\n\n"; @@ -711,7 +670,8 @@ const EquivalenceClass * Mtd_Partition::operator()(int k) const if ( (k < 0) || (k >= Nelements) ) { - mlog << Error << "\n\n Mtd_Partition::operator()(int) const -> range check error\n\n"; + mlog << Error << "\nMtd_Partition::operator()(int) const -> " + << "range check error\n\n"; exit ( 1 ); @@ -778,8 +738,6 @@ for (j=0; j mtd_read_data(MtdConfigInfo & config, VarInfo & varinfo, { +static const char *method_name = "mtd_read_data() -> "; + if ( filenames.n() < 2 ) { - mlog << Error << "\n\n mtd_read_data() -> need at least 2 data files!\n\n"; + mlog << Error << "\n" << method_name + << "need at least 2 data files!\n\n"; exit ( 1 ); @@ -52,14 +55,15 @@ vector valid_times; for (j=0; j<(filenames.n()); ++j) { - mlog << Debug(2) - << "mtd_read_data() -> processing file \"" << filenames[j] << "\"\n"; + mlog << Debug(2) << method_name + << "processing file: " << filenames[j] << "\n"; data_2d_file = factory.new_met_2d_data_file(filenames[j].c_str(), varinfo.file_type()); if ( ! data_2d_file->data_plane(varinfo, plane) ) { - mlog << Error << "\n\n mtd_read_data() -> unable to get data plane at time " << j << "\n\n"; + mlog << Error << "\n" << method_name + << "unable to get data plane at time " << j << "\n\n"; exit ( 1 ); @@ -67,7 +71,8 @@ for (j=0; j<(filenames.n()); ++j) { if ( ! data_2d_file->data_plane(varinfo, plane) ) { - mlog << Error << "\n\n mtd_read_data() -> unable to get data plane at time " << j << "\n\n"; + mlog << Error << "\n" << method_name + << "unable to get data plane at time " << j << "\n\n"; exit ( 1 ); @@ -157,9 +162,13 @@ if (variableTimeIncs) { unixtime umean = (unixtime)mean; unixtime uvar = (unixtime)var; unixtime suvar = (unixtime)svar; - mlog << Warning << "\n\n mtd_read_data() -> File time increments are not constant, could be problematic\n"; - mlog << Warning << " mtd_read_data() -> Using MODE of the increments, mode=" << dt_start << "\n"; - mlog << Warning << " mtd_read_data() -> Time increment properties: mean=" << umean << " variance=" << uvar << " sqrt(var)=" << suvar << "\n\n"; + mlog << Warning << "\n" << method_name + << "file time increments are not constant, could be problematic\n\n"; + mlog << Warning << "\n" << method_name + << "using MODE of the increments, mode=" << dt_start << "\n\n"; + mlog << Warning << "\n" << method_name + << "Time increment properties: mean=" << umean << " variance=" << uvar + << " sqrt(var)=" << suvar << "\n\n"; } } diff --git a/src/tools/other/mode_time_domain/mtd_txt_output.cc b/src/tools/other/mode_time_domain/mtd_txt_output.cc index f1ee61aa5d..b3f9ea14b4 100644 --- a/src/tools/other/mode_time_domain/mtd_txt_output.cc +++ b/src/tools/other/mode_time_domain/mtd_txt_output.cc @@ -7,7 +7,6 @@ // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - //////////////////////////////////////////////////////////////////////// @@ -56,13 +55,13 @@ ofstream out; AsciiTable table; const int Nobj = fcst_att.n() + obs_att.n(); - out.open(output_filename); if ( ! out ) { - mlog << Error << "\n\n do_3d_single_txt_output() -> unable to open output filename \"" - << output_filename << "\'\n\n"; + mlog << Error << "\ndo_3d_single_txt_output() -> " + << "unable to open output filename: " + << output_filename << "\n\n"; exit ( 1 ); @@ -172,13 +171,13 @@ ofstream out; AsciiTable table; const int Nobj = att.n(); - out.open(output_filename); if ( ! out ) { - mlog << Error << "\n\n do_3d_single_txt_output[single]() -> unable to open output filename \"" - << output_filename << "\'\n\n"; + mlog << Error << "\ndo_3d_single_txt_output[single]() -> " + << "unable to open output filename: " + << output_filename << "\n\n"; exit ( 1 ); @@ -322,8 +321,9 @@ out.open(output_filename); if ( ! out ) { - mlog << Error << "\n\n do_3d_pair_txt_output() -> unable to open output filename \"" - << output_filename << "\'\n\n"; + mlog << Error << "\ndo_3d_pair_txt_output() -> " + << "unable to open output filename: " + << output_filename << "\n\n"; exit ( 1 ); @@ -415,13 +415,13 @@ ofstream out; AsciiTable table; const int n_total = fcst_simple_att.n() + obs_simple_att.n() + fcst_cluster_att.n() + obs_cluster_att.n(); - out.open(output_filename); if ( ! out ) { - mlog << Error << "\n\n do_2d_txt_output() -> unable to open output filename \"" - << output_filename << "\'\n\n"; + mlog << Error << "\ndo_2d_txt_output() -> " + << "unable to open output filename: " + << output_filename << "\n\n"; exit ( 1 ); @@ -613,13 +613,13 @@ ofstream out; AsciiTable table; const int n_total = att.n(); - out.open(output_filename); if ( ! out ) { - mlog << Error << "\n\n do_2d_txt_output[single]() -> unable to open output filename \"" - << output_filename << "\'\n\n"; + mlog << Error << "\ndo_2d_txt_output[single]() -> " + << "unable to open output filename: " + << output_filename << "\n\n"; exit ( 1 ); diff --git a/src/tools/other/mode_time_domain/mtdfiletype_to_string.cc b/src/tools/other/mode_time_domain/mtdfiletype_to_string.cc index e7a2ff1a4e..0208bf537e 100644 --- a/src/tools/other/mode_time_domain/mtdfiletype_to_string.cc +++ b/src/tools/other/mode_time_domain/mtdfiletype_to_string.cc @@ -73,6 +73,7 @@ else if ( strcmp(text, "mtd_file_conv" ) == 0 ) { t = mtd_file_conv; re else if ( strcmp(text, "mtd_file_mask" ) == 0 ) { t = mtd_file_mask; return true; } else if ( strcmp(text, "mtd_file_object" ) == 0 ) { t = mtd_file_object; return true; } else if ( strcmp(text, "no_mtd_file_type") == 0 ) { t = no_mtd_file_type; return true; } + // // nope // diff --git a/src/tools/other/mode_time_domain/nc_grid.cc b/src/tools/other/mode_time_domain/nc_grid.cc deleted file mode 100644 index e5865a1c4a..0000000000 --- a/src/tools/other/mode_time_domain/nc_grid.cc +++ /dev/null @@ -1,665 +0,0 @@ -// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* -// ** Copyright UCAR (c) 1992 - 2024 -// ** University Corporation for Atmospheric Research (UCAR) -// ** National Center for Atmospheric Research (NCAR) -// ** Research Applications Lab (RAL) -// ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA -// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - - - -//////////////////////////////////////////////////////////////////////// - - -#include -#include -#include -#include -#include -#include - -#include - -#include "nc_utils_local.h" -#include "nc_grid.h" - -using namespace std; -using namespace netCDF; - - -//////////////////////////////////////////////////////////////////////// - - -static bool read_nc_st_grid (NcFile &, Grid &); -static bool read_nc_lc_grid (NcFile &, Grid &); -static bool read_nc_latlon_grid (NcFile &, Grid &); - -static void write_nc_st_grid (NcFile &, const StereographicData &); -static void write_nc_lc_grid (NcFile &, const LambertData &); -static void write_nc_latlon_grid (NcFile &, const LatLonData &); - - -//////////////////////////////////////////////////////////////////////// - - -bool read_nc_grid(NcFile & f, Grid & g) - -{ - - bool status = false; - ConcatString proj; - //const ConcatString proj = string_att(f, "Projection"); - get_att_value_string(&f, (string)"Projection", proj); - - - g.clear(); - - - if ( proj == "Polar Stereographic" ) { - - status = read_nc_st_grid(f, g); - - } else if ( proj == "Lambert Conformal" ) { - - status = read_nc_lc_grid(f, g); - - } else if ( proj == "LatLon" ) { - - status = read_nc_latlon_grid(f, g); - - } else { - - mlog << Error << "\n\n read_nc_grid() -> haven't written code to parse \"" << proj << "\" grids yet!\n\n"; - - return false; - - } - - - // - // done - // - -return status; - -} - - -//////////////////////////////////////////////////////////////////////// - - -bool write_nc_grid(NcFile & f, const Grid & g) - -{ - -GridInfo info = g.info(); - -if ( !(info.ok()) ) { - - mlog << Error << "\n\n write_nc_grid(NcFile &, const Grid &) -> can't get information from grid!\n\n"; - - exit ( 1 ); - -} - - if ( info.st ) write_nc_st_grid (f, *(info.st)); -else if ( info.lc ) write_nc_lc_grid (f, *(info.lc)); -else if ( info.ll ) write_nc_latlon_grid (f, *(info.ll)); -else { - - mlog << Error << "\n\n bool write_nc_grid(NcFile &, const Grid &) -> unsupported projection type\n\n"; - - exit ( 1 ); - -} - - // - // done - // - -return false; - -} - - -//////////////////////////////////////////////////////////////////////// - - -bool read_nc_st_grid(NcFile & f, Grid & g) - -{ - - StereographicData data; - ConcatString c; - - // - // name - // - - data.name = "Unknown stereographic"; - - // - // hemisphere - // - - //c = string_att(f, "hemisphere"); - get_att_value_string(&f, (string)"hemisphere", c); - -data.hemisphere = c[0]; - - // - // scale latitude - // - -data.scale_lat = string_att_as_double(f, "scale_lat"); - - // - // lat/lon pin - // - -data.lat_pin = string_att_as_double(f, "lat_pin"); -data.lon_pin = string_att_as_double(f, "lon_pin"); - -data.lon_pin *= -1.0; - - // - // x/y pin - // - -data.x_pin = string_att_as_double(f, "x_pin"); -data.y_pin = string_att_as_double(f, "y_pin"); - - // - // orientation longitude - // - -data.lon_orient = string_att_as_double(f, "lon_orient"); - -data.lon_orient *= -1.0; - - // - // D, R - // - -data.d_km = string_att_as_double(f, "d_km"); -data.r_km = string_att_as_double(f, "r_km"); - - // - // Nx, Ny - // - -data.nx = string_att_as_int(f, "nx"); -data.ny = string_att_as_int(f, "ny"); - -data.eccentricity = 0.; -data.false_east = 0.; -data.false_north = 0.; -data.scale_factor = 1.0; -data.dy_km = data.d_km; - - // - // done - // - -g.set(data); - -return true; - -} - - -//////////////////////////////////////////////////////////////////////// - - -bool read_nc_lc_grid(NcFile & f, Grid & g) - -{ - -LambertData data; -g.clear(); - - // - // name - // - -data.name = "Unknown lambert"; - - // - // scale latitudes - // - -data.scale_lat_1 = string_att_as_double(f, "scale_lat_1"); -data.scale_lat_2 = string_att_as_double(f, "scale_lat_2"); - - // - // lat/lon pin - // - -data.lat_pin = string_att_as_double(f, "lat_pin"); -data.lon_pin = string_att_as_double(f, "lon_pin"); - -data.lon_pin *= -1.0; - - // - // x/y pin - // - -data.x_pin = string_att_as_double(f, "x_pin"); -data.y_pin = string_att_as_double(f, "y_pin"); - - // - // orientation longitude - // - -data.lon_orient = string_att_as_double(f, "lon_orient"); - -data.lon_orient *= -1.0; - - // - // D, R - // - -data.d_km = string_att_as_double(f, "d_km"); -data.r_km = string_att_as_double(f, "r_km"); - - // - // Nx, Ny - // - -data.nx = string_att_as_int(f, "nx"); -data.ny = string_att_as_int(f, "ny"); - - // - // Rotation angle - // - -data.so2_angle = 0.0; - - // - // done - // - -g.set(data); - -return true; - -} - - -//////////////////////////////////////////////////////////////////////// - - -bool read_nc_latlon_grid(NcFile & f, Grid & g) - -{ - -LatLonData data; - -g.clear(); - - // - // name - // - -data.name = "Unknown latlon"; - - // - // lower-left lat/lon - // - -data.lat_ll = string_att_as_double(f, "lat_ll"); -data.lon_ll = string_att_as_double(f, "lon_ll"); - -data.lon_ll = -(data.lon_ll); - - // - // lat/lon deltas - // - -data.delta_lat = string_att_as_double(f, "delta_lat"); -data.delta_lon = string_att_as_double(f, "delta_lon"); - - // - // grid size - // - -data.Nlat = string_att_as_int(f, "Nlat"); -data.Nlon = string_att_as_int(f, "Nlon"); - - - // - // done - // - -g.set(data); - -return true; - -} - - -//////////////////////////////////////////////////////////////////////// - - -void write_nc_st_grid(NcFile & f, const StereographicData & data) - -{ - -ConcatString junk; -ConcatString j2; - - // - // name - // - -add_att(&f, "Projection", "Polar Stereographic"); - - // - // hemisphere - // - -junk = data.hemisphere; - -add_att(&f, "hemisphere", junk); - - // - // scale latitude - // - - j2.format("%.5f", data.scale_lat); - -fix_float(j2); - - junk.format("%s degrees_north", j2.c_str()); - -add_att(&f, "scale_lat", junk); - - // - // lat/lon pin point - // - -junk.format("%.5f", data.lat_pin); - -fix_float(junk); - -add_att(&f, "lat_pin", junk); - - - junk.format("%.5f", -(data.lon_pin)); - -fix_float(junk); - -add_att(&f, "lon_pin", junk); - - // - // x/y pin point - // - - junk.format("%.5f", data.x_pin); - -fix_float(junk); - -add_att(&f, "x_pin", junk); - - - junk.format("%.5f", data.y_pin); - -fix_float(junk); - -add_att(&f, "y_pin", junk); - - // - // orientation longitude - // - - junk.format("%.5f", -(data.lon_orient)); - -fix_float(junk); - -add_att(&f, "lon_orient", junk); - - // - // D and R - // - - j2.format("%.5f", data.d_km); - -fix_float(j2); - - junk.format("%s km", j2.c_str()); - -add_att(&f, "d_km", junk); - - - j2.format("%.5f", data.r_km); - -fix_float(j2); - - junk.format("%s km", j2.c_str()); - -add_att(&f, "r_km", junk); - - // - // nx and ny - // - - junk.format("%d", data.nx); - -add_att(&f, "nx", junk); - - - junk.format("%d", data.ny); - -add_att(&f, "ny", junk); - - - // - // done - // - -return; - -} - - -//////////////////////////////////////////////////////////////////////// - - -void write_nc_lc_grid(NcFile & f, const LambertData & data) - -{ - -ConcatString junk; -ConcatString j2; - - // - // name - // - -add_att(&f, "Projection", "Lambert Conformal"); - - // - // scale latitudes - // - - junk.format("%.5f", data.scale_lat_1); - -fix_float(junk); - -add_att(&f, "scale_lat_1", junk); - - - junk.format("%.5f", data.scale_lat_2); - -fix_float(junk); - -add_att(&f, "scale_lat_2", junk); - - // - // lat/lon pin point - // - - junk.format("%.5f", data.lat_pin); - -fix_float(junk); - -add_att(&f, "lat_pin", junk); - - - junk.format("%.5f", -(data.lon_pin)); - -fix_float(junk); - -add_att(&f, "lon_pin", junk); - - // - // x/y pin point - // - - junk.format("%.5f", data.x_pin); - -fix_float(junk); - -add_att(&f, "x_pin", junk); - - - junk.format("%.5f", data.y_pin); - -fix_float(junk); - -add_att(&f, "y_pin", junk); - - // - // orientation longitude - // - - junk.format("%.5f", -(data.lon_orient)); - -fix_float(junk); - -add_att(&f, "lon_orient", junk); - - // - // D and R - // - - j2.format("%.5f", data.d_km); - -fix_float(j2); - - junk.format("%s km", j2.c_str()); - -add_att(&f, "d_km", junk); - - - j2.format("%.5f", data.r_km); - -fix_float(j2); - - junk.format("%s km", j2.c_str()); - -add_att(&f, "r_km", junk); - - // - // nx and ny - // - - junk.format("%d", data.nx); - -add_att(&f, "nx", junk); - - - junk.format("%d", data.ny); - -add_att(&f, "ny", junk); - - - // - // done - // - -return; - -} - - -//////////////////////////////////////////////////////////////////////// - - -void write_nc_latlon_grid (NcFile & f, const LatLonData & data) - -{ - -ConcatString junk; - - - // - // name - // - -add_att(&f, "Projection", "LatLon"); - - // - // lower left point - // - - junk.format("%.5f", data.lat_ll); - -fix_float(junk); - -add_att(&f, "lat_ll", junk); - - - junk.format("%.5f", -(data.lon_ll)); - -fix_float(junk); - -add_att(&f, "lon_ll", junk); - - // - // lat/lon deltas - // - - junk.format("%.5f", data.delta_lat); - -fix_float(junk); - -add_att(&f, "delta_lat", junk); - - - junk.format("%.5f", data.delta_lon); - -fix_float(junk); - -add_att(&f, "delta_lon", junk); - - // - // grid size - // - - junk.format("%d", data.Nlat); - -fix_float(junk); - -add_att(&f, "Nlat", junk); - - - junk.format("%d", data.Nlon); - -fix_float(junk); - -add_att(&f, "Nlon", junk); - - - // - // done - // - -return; - -} - - -//////////////////////////////////////////////////////////////////////// - - diff --git a/src/tools/other/mode_time_domain/nc_grid.h b/src/tools/other/mode_time_domain/nc_grid.h deleted file mode 100644 index c130990c8c..0000000000 --- a/src/tools/other/mode_time_domain/nc_grid.h +++ /dev/null @@ -1,41 +0,0 @@ -// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* -// ** Copyright UCAR (c) 1992 - 2024 -// ** University Corporation for Atmospheric Research (UCAR) -// ** National Center for Atmospheric Research (NCAR) -// ** Research Applications Lab (RAL) -// ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA -// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - - - -//////////////////////////////////////////////////////////////////////// - - -#ifndef __NETCDF_GRIDS_H__ -#define __NETCDF_GRIDS_H__ - - -//////////////////////////////////////////////////////////////////////// - - -#include "nc_utils.h" -#include "vx_grid.h" - - -//////////////////////////////////////////////////////////////////////// - - -extern bool read_nc_grid(netCDF::NcFile &, Grid &); - -extern bool write_nc_grid(netCDF::NcFile &, const Grid &); - - -//////////////////////////////////////////////////////////////////////// - - -#endif /* __NETCDF_GRIDS_H__ */ - - -//////////////////////////////////////////////////////////////////////// - - diff --git a/src/tools/other/mode_time_domain/nc_utils_local.cc b/src/tools/other/mode_time_domain/nc_utils_local.cc deleted file mode 100644 index 00761859cb..0000000000 --- a/src/tools/other/mode_time_domain/nc_utils_local.cc +++ /dev/null @@ -1,191 +0,0 @@ -// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* -// ** Copyright UCAR (c) 1992 - 2024 -// ** University Corporation for Atmospheric Research (UCAR) -// ** National Center for Atmospheric Research (NCAR) -// ** Research Applications Lab (RAL) -// ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA -// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - - - -//////////////////////////////////////////////////////////////////////// - - -#include -#include -#include -#include -#include -#include - -#include - -#include "nc_utils.h" -#include "nc_utils_local.h" -#include "vx_log.h" - -using namespace std; -using namespace netCDF; - - -//////////////////////////////////////////////////////////////////////// - - -static const int cbuf_size = 8096; - -static char cbuf [cbuf_size]; - - -//////////////////////////////////////////////////////////////////////// - - -const char * string_att(const NcFile & Nc, const char * name) - -{ - -const char *method_name = "string_att() -> "; -NcGroupAtt *att = get_nc_att(&Nc, (string)name); - -if ( GET_NC_TYPE_ID_P(att) != NcType::nc_CHAR ) { - - mlog << Error << "\n" << method_name << "attribute \"" << name - << "\" is not a character string!\n\n"; - - exit ( 1 ); - -} - -ConcatString value; -get_att_value_chars(att, value); -m_strncpy(cbuf, value.c_str(), cbuf_size - 1, method_name); - -cbuf[cbuf_size - 1] = (char) 0; - -if (att) { delete att; att = nullptr; } - - // - // done - // - -return cbuf; - -} - - -//////////////////////////////////////////////////////////////////////// - - -double string_att_as_double (const NcFile & Nc, const char * name) - -{ - -const char * c = string_att(Nc, name); - -double value = atof(c); - -return value; - -} - - -//////////////////////////////////////////////////////////////////////// - - -int string_att_as_int (const NcFile & Nc, const char * name) - -{ - -const char * c = string_att(Nc, name); - -int k = atoi(c); - -return k; - -} - - -//////////////////////////////////////////////////////////////////////// - - -long long string_att_as_ll (const NcFile & Nc, const char * name) - -{ - -const char * c = string_att(Nc, name); - -long long k = atoll(c); - -return k; - -} - - -//////////////////////////////////////////////////////////////////////// - - // - // example: 20100517_010000 - // - -unixtime parse_start_time(const char * text) - -{ - -int k; -int month, day, year, hour, minute, second; -unixtime t; -const int n = m_strlen(text); - -if ( n != 15 ) { - - mlog << Error << "\n\n parse_start_time() -> bad string ... \"" << text << "\"\n\n"; - - exit ( 1 ); - -} - -k = atoi(text); - -year = k/10000; -month = (k%10000)/100; -day = k%100; - -k = atoi(text + 9); - -hour = k/10000; -minute = (k%10000)/100; -second = k%100; - -t = mdyhms_to_unix(month, day, year, hour, minute, second); - - - // - // done - // - -return t; - -} - - -//////////////////////////////////////////////////////////////////////// - - -ConcatString start_time_string(const unixtime t) - -{ - -int month, day, year, hour, minute, second; -char junk[256]; - -unix_to_mdyhms(t, month, day, year, hour, minute, second); - -snprintf(junk, sizeof(junk), "%04d%02d%02d_%02d%02d%02d", year, month, day, hour, minute, second); - -return ConcatString(junk); - -} - - -//////////////////////////////////////////////////////////////////////// - - diff --git a/src/tools/other/mode_time_domain/nc_utils_local.h b/src/tools/other/mode_time_domain/nc_utils_local.h deleted file mode 100644 index 2f1f1df055..0000000000 --- a/src/tools/other/mode_time_domain/nc_utils_local.h +++ /dev/null @@ -1,50 +0,0 @@ -// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* -// ** Copyright UCAR (c) 1992 - 2024 -// ** University Corporation for Atmospheric Research (UCAR) -// ** National Center for Atmospheric Research (NCAR) -// ** Research Applications Lab (RAL) -// ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA -// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - - - -//////////////////////////////////////////////////////////////////////// - - -#ifndef __MTD_NETCDF_UTILS_H__ -#define __MTD_NETCDF_UTILS_H__ - - -//////////////////////////////////////////////////////////////////////// - - -#include "concat_string.h" -#include "vx_cal.h" -#include "nc_utils.h" - -//////////////////////////////////////////////////////////////////////// - - -extern const char * string_att (const netCDF::NcFile &, const char * name); -extern int string_att_as_int (const netCDF::NcFile &, const char * name); -extern long long string_att_as_ll (const netCDF::NcFile &, const char * name); -extern double string_att_as_double (const netCDF::NcFile &, const char * name); - - -//////////////////////////////////////////////////////////////////////// - - -extern unixtime parse_start_time(const char *); - -extern ConcatString start_time_string(const unixtime); - - -//////////////////////////////////////////////////////////////////////// - - -#endif /* __MTD_NETCDF_UTILS_H__ */ - - -//////////////////////////////////////////////////////////////////////// - -