Skip to content

Commit

Permalink
Bugfix #2979 develop MTD Grid (#2981)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
JohnHalleyGotway and MET Tools Test Account authored Sep 27, 2024
1 parent 6053404 commit a0ce82f
Show file tree
Hide file tree
Showing 42 changed files with 302 additions and 2,002 deletions.
2 changes: 1 addition & 1 deletion internal/test_unit/python/unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 0 additions & 2 deletions internal/test_util/tools/other/mode_time_domain/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
4 changes: 0 additions & 4 deletions internal/test_util/tools/other/mode_time_domain/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 \
Expand Down
8 changes: 8 additions & 0 deletions src/basic/vx_math/is_bad_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename T>
inline int is_eq(T a, T b) {
return (a == b);
Expand Down
2 changes: 1 addition & 1 deletion src/libcode/vx_statistics/compute_stats.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
17 changes: 3 additions & 14 deletions src/tools/other/mode_time_domain/2d_att.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*



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


Expand Down Expand Up @@ -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);
Expand All @@ -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 );

Expand Down Expand Up @@ -626,6 +618,3 @@ return;
////////////////////////////////////////////////////////////////////////





40 changes: 12 additions & 28 deletions src/tools/other/mode_time_domain/2d_att_array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
//


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


Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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 );

Expand Down Expand Up @@ -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 );

Expand Down Expand Up @@ -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 );
}
Expand Down Expand Up @@ -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 );

Expand All @@ -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 );

Expand All @@ -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 );

Expand All @@ -401,5 +387,3 @@ return e[index].time_index();
////////////////////////////////////////////////////////////////////////




12 changes: 4 additions & 8 deletions src/tools/other/mode_time_domain/2d_moments.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*



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


Expand All @@ -25,12 +24,10 @@ using namespace std;

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


//
// Code for class Mtd_2D_Moments
//


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


Expand Down Expand Up @@ -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 );

Expand Down Expand Up @@ -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 );

Expand All @@ -242,6 +241,3 @@ return angle;
////////////////////////////////////////////////////////////////////////





4 changes: 0 additions & 4 deletions src/tools/other/mode_time_domain/2d_moments.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ class Mtd_2D_Moments {

int area() const;


//
// do stuff
//
Expand All @@ -66,11 +65,8 @@ class Mtd_2D_Moments {

void centralize();


double calc_2D_axis_plane_angle() const;



};


Expand Down
Loading

0 comments on commit a0ce82f

Please sign in to comment.