From 697f362a4e26b620a07a804f2619b881cb6d86eb Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Mon, 8 Mar 2021 18:27:44 -0700 Subject: [PATCH 1/7] Per #1471, defined a parse_grid_string() function in the vx_statistics library and then updated vx_data2d_python to call that function. However, this creates a circular dependency because vx_data2d_python now depends on vx_statistics. --- .../dataplane_from_numpy_array.cc | 24 +++++++++- met/src/libcode/vx_statistics/apply_mask.cc | 45 +++++++++++++++++++ met/src/libcode/vx_statistics/apply_mask.h | 2 + 3 files changed, 69 insertions(+), 2 deletions(-) diff --git a/met/src/libcode/vx_data2d_python/dataplane_from_numpy_array.cc b/met/src/libcode/vx_data2d_python/dataplane_from_numpy_array.cc index 7462c20829..5efd29d3c6 100644 --- a/met/src/libcode/vx_data2d_python/dataplane_from_numpy_array.cc +++ b/met/src/libcode/vx_data2d_python/dataplane_from_numpy_array.cc @@ -12,6 +12,7 @@ #include "string.h" #include "vx_python3_utils.h" +#include "vx_statistics.h" #include "check_endian.h" #include "data_plane.h" @@ -219,9 +220,28 @@ dp_out.set_accum(t); //////////////////// -PyObject * py_grid = attrs.lookup_dict("grid"); + // + // attempt to parse "grid" as a string + // + +s = attrs.lookup_string("grid"); + +if ( s.nonempty() ) { + + grid_out = parse_grid_string(s.c_str()); + +} +else { -grid_from_python_dict(Python3_Dict(py_grid), grid_out); + // + // otherwise, parse "grid" as a dictionary + // + + PyObject * py_grid = attrs.lookup_dict("grid"); + + grid_from_python_dict(Python3_Dict(py_grid), grid_out); + +} //////////////////// diff --git a/met/src/libcode/vx_statistics/apply_mask.cc b/met/src/libcode/vx_statistics/apply_mask.cc index f5ea562630..b97e9272d3 100644 --- a/met/src/libcode/vx_statistics/apply_mask.cc +++ b/met/src/libcode/vx_statistics/apply_mask.cc @@ -84,6 +84,51 @@ Grid parse_vx_grid(const RegridInfo info, const Grid *fgrid, const Grid *ogrid) //////////////////////////////////////////////////////////////////////// +Grid parse_grid_string(const char *grid_str) { + Grid grid; + StringArray sa; + + // Parse as a white-space separated string + sa.parse_wsss(grid_str); + + // Search for a named grid + if(sa.n() == 1 && find_grid_by_name(sa[0].c_str(), grid)) { + mlog << Debug(3) << "Use the grid named \"" + << grid_str << "\".\n"; + } + // Parse grid definition + else if(sa.n() > 1 && parse_grid_def(sa, grid)) { + mlog << Debug(3) << "Use the grid defined by string \"" + << grid_str << "\".\n"; + } + // Extract the grid from a gridded data file + else { + mlog << Debug(3) << "Use the grid defined by file \"" + << grid_str << "\".\n"; + + Met2dDataFileFactory m_factory; + Met2dDataFile *met_ptr = (Met2dDataFile *) 0; + + // Open the data file + if(!(met_ptr = m_factory.new_met_2d_data_file(grid_str))) { + mlog << Error << "\nparse_grid_string() -> " + << "can't open file \"" << grid_str + << "\"\n\n"; + exit(1); + } + + // Store the grid + grid = met_ptr->grid(); + + // Cleanup + if(met_ptr) { delete met_ptr; met_ptr = 0; } + } + + return(grid); +} + +//////////////////////////////////////////////////////////////////////// + void parse_grid_weight(const Grid &grid, const GridWeightType t, DataPlane &wgt_dp) { int x, y; diff --git a/met/src/libcode/vx_statistics/apply_mask.h b/met/src/libcode/vx_statistics/apply_mask.h index 0ac9aac85e..5e62500d73 100644 --- a/met/src/libcode/vx_statistics/apply_mask.h +++ b/met/src/libcode/vx_statistics/apply_mask.h @@ -29,6 +29,8 @@ static const char poly_str_delim[] = "{}"; extern Grid parse_vx_grid(const RegridInfo, const Grid *, const Grid *); +extern Grid parse_grid_string(const char *); + extern void parse_grid_weight(const Grid &, const GridWeightType, DataPlane &); From a8f4b650055828cff6b6a478542d539f34646f7e Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Mon, 8 Mar 2021 18:29:06 -0700 Subject: [PATCH 2/7] Per #1471, because of the change in dependencies, I had to modify many, many Makefile.am files to link to the -lvx_statistics after -lvx_data2d_python. This is not great, but I didn't find a better solution. --- met/internal_tests/basic/vx_util/Makefile.am | 28 +++++--- .../libcode/vx_data2d_factory/Makefile.am | 12 +++- .../libcode/vx_nc_util/Makefile.am | 26 +++++--- .../libcode/vx_tc_util/Makefile.am | 64 ++++++++++++------- met/src/tools/core/ensemble_stat/Makefile.am | 1 + met/src/tools/core/grid_stat/Makefile.am | 1 + met/src/tools/core/mode/Makefile.am | 1 + met/src/tools/core/mode_analysis/Makefile.am | 8 +-- met/src/tools/core/pcp_combine/Makefile.am | 2 + met/src/tools/core/point_stat/Makefile.am | 1 + .../tools/core/series_analysis/Makefile.am | 1 + met/src/tools/core/stat_analysis/Makefile.am | 1 + met/src/tools/core/wavelet_stat/Makefile.am | 1 + met/src/tools/dev_utils/Makefile.am | 1 + met/src/tools/other/ascii2nc/Makefile.am | 1 + met/src/tools/other/gen_vx_mask/Makefile.am | 2 + met/src/tools/other/grid_diag/Makefile.am | 1 + met/src/tools/other/gsi_tools/Makefile.am | 1 + met/src/tools/other/ioda2nc/Makefile.am | 1 + met/src/tools/other/lidar2nc/Makefile.am | 1 + met/src/tools/other/madis2nc/Makefile.am | 1 + met/src/tools/other/mode_graphics/Makefile.am | 1 + .../tools/other/mode_time_domain/Makefile.am | 1 + met/src/tools/other/modis_regrid/Makefile.am | 1 + met/src/tools/other/pb2nc/Makefile.am | 1 + .../tools/other/plot_data_plane/Makefile.am | 2 + .../tools/other/plot_point_obs/Makefile.am | 1 + met/src/tools/other/point2grid/Makefile.am | 1 + .../tools/other/regrid_data_plane/Makefile.am | 1 + .../tools/other/shift_data_plane/Makefile.am | 1 + met/src/tools/other/wwmca_tool/Makefile.am | 1 + .../tools/tc_utils/rmw_analysis/Makefile.am | 1 + met/src/tools/tc_utils/tc_gen/Makefile.am | 1 + met/src/tools/tc_utils/tc_pairs/Makefile.am | 1 + met/src/tools/tc_utils/tc_rmw/Makefile.am | 1 + met/src/tools/tc_utils/tc_stat/Makefile.am | 1 + 36 files changed, 123 insertions(+), 49 deletions(-) diff --git a/met/internal_tests/basic/vx_util/Makefile.am b/met/internal_tests/basic/vx_util/Makefile.am index 364b846a0b..5501f38d86 100644 --- a/met/internal_tests/basic/vx_util/Makefile.am +++ b/met/internal_tests/basic/vx_util/Makefile.am @@ -82,18 +82,26 @@ endif test_ascii_header_SOURCES = test_ascii_header.cc test_ascii_header_CPPFLAGS = ${MET_CPPFLAGS} test_ascii_header_LDFLAGS = -L. ${MET_LDFLAGS} -test_ascii_header_LDADD = -lvx_util \ - -lvx_config \ +test_ascii_header_LDADD = -lvx_stat_out \ + -lvx_statistics \ + -lvx_shapedata \ -lvx_gsl_prob \ + -lvx_analysis_util \ + -lvx_data2d_factory \ + -lvx_data2d_nc_met \ + -lvx_data2d_grib $(GRIB2_LIBS) \ + -lvx_data2d_nc_pinterp \ + $(PYTHON_LIBS) \ + -lvx_data2d_nccf \ + -lvx_statistics \ + -lvx_data2d \ + -lvx_nc_util \ + -lvx_regrid \ + -lvx_grid \ + -lvx_config \ -lvx_cal \ -lvx_util \ -lvx_math \ + -lvx_color \ -lvx_log \ - -lgsl -lgslcblas - -if ENABLE_PYTHON -test_ascii_header_LDADD += $(MET_PYTHON_LD) -lvx_data2d_python -lvx_python3_utils -lvx_data2d_python -lvx_python3_utils -lvx_math -test_ascii_header_LDADD += -lvx_data2d_python -lvx_python3_utils -lvx_data2d_python -lvx_python3_utils -test_ascii_header_LDADD += -lvx_math -lvx_grid -lvx_util -lvx_data2d -lvx_config -lvx_gsl_prob -lvx_cal -lvx_math -lvx_util -endif - + -lm -lnetcdf_c++4 -lnetcdf -lgsl -lgslcblas diff --git a/met/internal_tests/libcode/vx_data2d_factory/Makefile.am b/met/internal_tests/libcode/vx_data2d_factory/Makefile.am index b1d31b3aa4..3800c9d02c 100644 --- a/met/internal_tests/libcode/vx_data2d_factory/Makefile.am +++ b/met/internal_tests/libcode/vx_data2d_factory/Makefile.am @@ -25,20 +25,26 @@ test_is_grib_LDADD = -lvx_data2d_factory \ test_factory_SOURCES = test_factory.cc test_factory_CPPFLAGS = ${MET_CPPFLAGS} test_factory_LDFLAGS = -L. ${MET_LDFLAGS} -test_factory_LDADD = -lvx_data2d_factory \ +test_factory_LDADD = -lvx_stat_out \ + -lvx_statistics \ + -lvx_shapedata \ + -lvx_gsl_prob \ + -lvx_analysis_util \ + -lvx_data2d_factory \ -lvx_data2d_nc_met \ -lvx_data2d_grib $(GRIB2_LIBS) \ -lvx_data2d_nc_pinterp \ $(PYTHON_LIBS) \ -lvx_data2d_nccf \ + -lvx_statistics \ -lvx_data2d \ -lvx_nc_util \ + -lvx_regrid \ -lvx_grid \ -lvx_config \ - -lvx_gsl_prob \ + -lvx_cal \ -lvx_util \ -lvx_math \ -lvx_color \ - -lvx_cal \ -lvx_log \ -lm -lnetcdf_c++4 -lnetcdf -lgsl -lgslcblas diff --git a/met/internal_tests/libcode/vx_nc_util/Makefile.am b/met/internal_tests/libcode/vx_nc_util/Makefile.am index 13bf6c2bc0..b39b62abcf 100644 --- a/met/internal_tests/libcode/vx_nc_util/Makefile.am +++ b/met/internal_tests/libcode/vx_nc_util/Makefile.am @@ -20,20 +20,26 @@ test_pressure_levels_SOURCES = test_pressure_levels.cc test_pressure_levels_CPPFLAGS = ${MET_CPPFLAGS} test_pressure_levels_LDFLAGS = -L. ${MET_LDFLAGS} test_pressure_levels_LDADD = -lvx_tc_util \ + -lvx_stat_out \ + -lvx_statistics \ + -lvx_shapedata \ + -lvx_gsl_prob \ + -lvx_analysis_util \ + -lvx_data2d_factory \ + -lvx_data2d_nc_met \ + -lvx_data2d_grib $(GRIB2_LIBS) \ + -lvx_data2d_nc_pinterp \ + $(PYTHON_LIBS) \ + -lvx_data2d_nccf \ + -lvx_statistics \ -lvx_data2d \ -lvx_nc_util \ + -lvx_regrid \ + -lvx_grid \ -lvx_config \ - -lvx_gsl_prob \ -lvx_cal \ -lvx_util \ -lvx_math \ + -lvx_color \ -lvx_log \ - -lnetcdf_c++4 -lnetcdf -lgsl -lgslcblas - -if ENABLE_PYTHON -test_pressure_levels_LDADD += $(MET_PYTHON_LD) -test_pressure_levels_LDADD += -lvx_data2d_python -lvx_python3_utils -test_pressure_levels_LDADD += -lvx_data2d_python -lvx_python3_utils -test_pressure_levels_LDADD += -lvx_grid -lvx_util -lvx_config -test_pressure_levels_LDADD += -lvx_data2d -lvx_gsl_prob -lvx_util -lvx_math -lvx_cal -lvx_config -endif + -lm -lnetcdf_c++4 -lnetcdf -lgsl -lgslcblas diff --git a/met/internal_tests/libcode/vx_tc_util/Makefile.am b/met/internal_tests/libcode/vx_tc_util/Makefile.am index 2b71de8a9f..9af1e702a3 100644 --- a/met/internal_tests/libcode/vx_tc_util/Makefile.am +++ b/met/internal_tests/libcode/vx_tc_util/Makefile.am @@ -20,39 +20,59 @@ noinst_PROGRAMS = test_read \ test_read_SOURCES = test_read.cc test_read_CPPFLAGS = ${MET_CPPFLAGS} test_read_LDFLAGS = -L. ${MET_LDFLAGS} -test_read_LDADD = -lvx_tc_util \ - -lvx_config \ +test_read_LDADD = -lvx_stat_out \ + -lvx_statistics \ + -lvx_shapedata \ -lvx_gsl_prob \ + -lvx_analysis_util \ + -lvx_tc_util \ + -lvx_data2d_factory \ + -lvx_data2d_nc_met \ + -lvx_data2d_grib $(GRIB2_LIBS) \ + -lvx_data2d_nc_pinterp \ + $(PYTHON_LIBS) \ + -lvx_data2d_nccf \ + -lvx_statistics \ + -lvx_data2d \ + -lvx_nc_util \ + -lvx_regrid \ + -lvx_grid \ + -lvx_config \ + -lvx_pb_util \ -lvx_cal \ + -lvx_nav \ -lvx_util \ -lvx_math \ + -lvx_color \ -lvx_log \ - -lgsl -lgslcblas - -if ENABLE_PYTHON -test_read_LDADD += $(MET_PYTHON_LD) -test_read_LDADD += -lvx_data2d_python -lvx_python3_utils -test_read_LDADD += -lvx_data2d_python -lvx_python3_utils -test_read_LDADD += -lvx_grid -lvx_util -lvx_config -test_read_LDADD += -lvx_data2d -lvx_gsl_prob -lvx_util -lvx_math -lvx_cal -lvx_config -endif + -lm -lnetcdf_c++4 -lnetcdf -lgsl -lgslcblas test_read_prob_SOURCES = test_read_prob.cc test_read_prob_CPPFLAGS = ${MET_CPPFLAGS} test_read_prob_LDFLAGS = -L. ${MET_LDFLAGS} -test_read_prob_LDADD = -lvx_tc_util \ - -lvx_config \ +test_read_prob_LDADD = -lvx_stat_out \ + -lvx_statistics \ + -lvx_shapedata \ -lvx_gsl_prob \ + -lvx_analysis_util \ + -lvx_tc_util \ + -lvx_data2d_factory \ + -lvx_data2d_nc_met \ + -lvx_data2d_grib $(GRIB2_LIBS) \ + -lvx_data2d_nc_pinterp \ + $(PYTHON_LIBS) \ + -lvx_data2d_nccf \ + -lvx_statistics \ + -lvx_data2d \ + -lvx_nc_util \ + -lvx_regrid \ + -lvx_grid \ + -lvx_config \ + -lvx_pb_util \ -lvx_cal \ + -lvx_nav \ -lvx_util \ -lvx_math \ + -lvx_color \ -lvx_log \ - -lgsl -lgslcblas - -if ENABLE_PYTHON -test_read_prob_LDADD += $(MET_PYTHON_LD) -test_read_prob_LDADD += -lvx_data2d_python -lvx_python3_utils -test_read_prob_LDADD += -lvx_data2d_python -lvx_python3_utils -test_read_prob_LDADD += -lvx_grid -lvx_util -lvx_config -test_read_prob_LDADD += -lvx_data2d -lvx_gsl_prob -lvx_util -lvx_math -lvx_cal -lvx_config -endif + -lm -lnetcdf_c++4 -lnetcdf -lgsl -lgslcblas \ No newline at end of file diff --git a/met/src/tools/core/ensemble_stat/Makefile.am b/met/src/tools/core/ensemble_stat/Makefile.am index d7cd14c178..172302f19a 100644 --- a/met/src/tools/core/ensemble_stat/Makefile.am +++ b/met/src/tools/core/ensemble_stat/Makefile.am @@ -26,6 +26,7 @@ ensemble_stat_LDADD = -lvx_stat_out \ -lvx_data2d_nc_pinterp \ $(PYTHON_LIBS) \ -lvx_data2d_nccf \ + -lvx_statistics \ -lvx_data2d \ -lvx_nc_obs \ -lvx_nc_util \ diff --git a/met/src/tools/core/grid_stat/Makefile.am b/met/src/tools/core/grid_stat/Makefile.am index 8db13c50bf..e1451258f0 100644 --- a/met/src/tools/core/grid_stat/Makefile.am +++ b/met/src/tools/core/grid_stat/Makefile.am @@ -26,6 +26,7 @@ grid_stat_LDADD = -lvx_stat_out \ -lvx_data2d_nc_pinterp \ $(PYTHON_LIBS) \ -lvx_data2d_nccf \ + -lvx_statistics \ -lvx_data2d \ -lvx_nc_util \ -lvx_regrid \ diff --git a/met/src/tools/core/mode/Makefile.am b/met/src/tools/core/mode/Makefile.am index b3260abef1..662dee58ef 100644 --- a/met/src/tools/core/mode/Makefile.am +++ b/met/src/tools/core/mode/Makefile.am @@ -39,6 +39,7 @@ mode_LDADD = -lvx_pxm \ -lvx_data2d_nc_pinterp \ $(PYTHON_LIBS) \ -lvx_data2d_nccf \ + -lvx_statistics \ -lvx_data2d \ -lvx_nc_util \ -lvx_regrid \ diff --git a/met/src/tools/core/mode_analysis/Makefile.am b/met/src/tools/core/mode_analysis/Makefile.am index 7305ea30a9..18de50a937 100644 --- a/met/src/tools/core/mode_analysis/Makefile.am +++ b/met/src/tools/core/mode_analysis/Makefile.am @@ -24,24 +24,24 @@ mode_analysis_LDADD = -lvx_stat_out \ -lvx_shapedata \ -lvx_gsl_prob \ -lvx_analysis_util \ - -lvx_shapedata \ -lvx_data2d_factory \ -lvx_data2d_nc_met \ + -lvx_data2d_grib $(GRIB2_LIBS) \ -lvx_data2d_nc_pinterp \ $(PYTHON_LIBS) \ -lvx_data2d_nccf \ - -lvx_data2d_grib $(GRIB2_LIBS) \ + -lvx_statistics \ -lvx_data2d \ -lvx_nc_util \ + -lvx_regrid \ -lvx_grid \ -lvx_config \ - -lvx_gsl_prob \ -lvx_cal \ -lvx_util \ -lvx_math \ -lvx_color \ -lvx_log \ - -lm -lnetcdf_c++4 -lnetcdf -lgsl -lgslcblas -lvx_util + -lm -lnetcdf_c++4 -lnetcdf -lgsl -lgslcblas -lz if ENABLE_PYTHON mode_analysis_LDADD += $(MET_PYTHON_LD) -lvx_data2d_python -lvx_python3_utils -lvx_data2d_python -lvx_python3_utils -lvx_util diff --git a/met/src/tools/core/pcp_combine/Makefile.am b/met/src/tools/core/pcp_combine/Makefile.am index 1a07c63b71..0fa6d2ecc4 100644 --- a/met/src/tools/core/pcp_combine/Makefile.am +++ b/met/src/tools/core/pcp_combine/Makefile.am @@ -20,8 +20,10 @@ pcp_combine_LDADD = -lvx_data2d_factory \ -lvx_data2d_nc_pinterp \ $(PYTHON_LIBS) \ -lvx_data2d_nccf \ + -lvx_statistics \ -lvx_data2d \ -lvx_nc_util \ + -lvx_regrid \ -lvx_grid \ -lvx_config \ -lvx_cal \ diff --git a/met/src/tools/core/point_stat/Makefile.am b/met/src/tools/core/point_stat/Makefile.am index ef64c96fc8..02dbac944a 100644 --- a/met/src/tools/core/point_stat/Makefile.am +++ b/met/src/tools/core/point_stat/Makefile.am @@ -26,6 +26,7 @@ point_stat_LDADD = -lvx_stat_out \ -lvx_data2d_nc_pinterp \ $(PYTHON_LIBS) \ -lvx_data2d_nccf \ + -lvx_statistics \ -lvx_data2d \ -lvx_nc_obs \ -lvx_nc_util \ diff --git a/met/src/tools/core/series_analysis/Makefile.am b/met/src/tools/core/series_analysis/Makefile.am index 79a33460f0..26352e71eb 100644 --- a/met/src/tools/core/series_analysis/Makefile.am +++ b/met/src/tools/core/series_analysis/Makefile.am @@ -26,6 +26,7 @@ series_analysis_LDADD = -lvx_stat_out \ -lvx_data2d_nc_pinterp \ $(PYTHON_LIBS) \ -lvx_data2d_nccf \ + -lvx_statistics \ -lvx_data2d \ -lvx_nc_util \ -lvx_regrid \ diff --git a/met/src/tools/core/stat_analysis/Makefile.am b/met/src/tools/core/stat_analysis/Makefile.am index 909143d9f3..ae6e9f9e89 100644 --- a/met/src/tools/core/stat_analysis/Makefile.am +++ b/met/src/tools/core/stat_analysis/Makefile.am @@ -34,6 +34,7 @@ stat_analysis_LDADD = -lvx_stat_out \ -lvx_data2d_nc_pinterp \ $(PYTHON_LIBS) \ -lvx_data2d_nccf \ + -lvx_statistics \ -lvx_data2d \ -lvx_nc_util \ -lvx_regrid \ diff --git a/met/src/tools/core/wavelet_stat/Makefile.am b/met/src/tools/core/wavelet_stat/Makefile.am index 4f6759db27..25150834a5 100644 --- a/met/src/tools/core/wavelet_stat/Makefile.am +++ b/met/src/tools/core/wavelet_stat/Makefile.am @@ -32,6 +32,7 @@ wavelet_stat_LDADD = -lvx_pxm \ -lvx_data2d_nc_pinterp \ $(PYTHON_LIBS) \ -lvx_data2d_nccf \ + -lvx_statistics \ -lvx_data2d \ -lvx_nc_util \ -lvx_regrid \ diff --git a/met/src/tools/dev_utils/Makefile.am b/met/src/tools/dev_utils/Makefile.am index 03a83fc690..9240cb48bd 100644 --- a/met/src/tools/dev_utils/Makefile.am +++ b/met/src/tools/dev_utils/Makefile.am @@ -127,6 +127,7 @@ gen_climo_bin_LDADD = -lvx_stat_out \ -lvx_data2d_nc_pinterp \ $(PYTHON_LIBS) \ -lvx_data2d_nccf \ + -lvx_statistics \ -lvx_data2d \ -lvx_nc_util \ -lvx_regrid \ diff --git a/met/src/tools/other/ascii2nc/Makefile.am b/met/src/tools/other/ascii2nc/Makefile.am index 3b4f21b46a..7fce7b81ba 100644 --- a/met/src/tools/other/ascii2nc/Makefile.am +++ b/met/src/tools/other/ascii2nc/Makefile.am @@ -39,6 +39,7 @@ ascii2nc_LDADD = -lvx_stat_out \ -lvx_data2d_nc_pinterp \ -lvx_data2d_nccf \ $(PYTHON_LIBS) \ + -lvx_statistics \ -lvx_data2d \ -lvx_nc_obs \ -lvx_nc_util \ diff --git a/met/src/tools/other/gen_vx_mask/Makefile.am b/met/src/tools/other/gen_vx_mask/Makefile.am index 2b52cb7cb6..f8b773183b 100644 --- a/met/src/tools/other/gen_vx_mask/Makefile.am +++ b/met/src/tools/other/gen_vx_mask/Makefile.am @@ -24,6 +24,7 @@ gen_vx_mask_LDADD = -lvx_shapedata \ -lvx_data2d_nc_met \ -lvx_data2d_nc_pinterp \ $(PYTHON_LIBS) \ + -lvx_statistics \ -lvx_gis \ -lvx_nc_util \ -lvx_data2d \ @@ -39,6 +40,7 @@ gen_vx_mask_LDADD = -lvx_shapedata \ -lvx_stat_out \ -lvx_statistics \ -lvx_gsl_prob \ + -lvx_regrid \ -lvx_grid \ -lvx_config \ -lvx_gsl_prob \ diff --git a/met/src/tools/other/grid_diag/Makefile.am b/met/src/tools/other/grid_diag/Makefile.am index 877772a982..1d30d1bce4 100644 --- a/met/src/tools/other/grid_diag/Makefile.am +++ b/met/src/tools/other/grid_diag/Makefile.am @@ -26,6 +26,7 @@ grid_diag_LDADD = -lvx_stat_out \ -lvx_data2d_nc_pinterp \ $(PYTHON_LIBS) \ -lvx_data2d_nccf \ + -lvx_statistics \ -lvx_data2d \ -lvx_nc_util \ -lvx_regrid \ diff --git a/met/src/tools/other/gsi_tools/Makefile.am b/met/src/tools/other/gsi_tools/Makefile.am index 40c550a1c1..cd609c22dd 100644 --- a/met/src/tools/other/gsi_tools/Makefile.am +++ b/met/src/tools/other/gsi_tools/Makefile.am @@ -43,6 +43,7 @@ gsid2mpr_LDADD = -lvx_stat_out \ -lvx_data2d_nc_pinterp \ $(PYTHON_LIBS) \ -lvx_data2d_nccf \ + -lvx_statistics \ -lvx_data2d \ -lvx_nc_util \ -lvx_regrid \ diff --git a/met/src/tools/other/ioda2nc/Makefile.am b/met/src/tools/other/ioda2nc/Makefile.am index e4067043df..83d74ba5d1 100644 --- a/met/src/tools/other/ioda2nc/Makefile.am +++ b/met/src/tools/other/ioda2nc/Makefile.am @@ -26,6 +26,7 @@ ioda2nc_LDADD = -lvx_stat_out \ -lvx_data2d_nc_pinterp \ -lvx_data2d_nccf \ $(PYTHON_LIBS) \ + -lvx_statistics \ -lvx_data2d \ -lvx_nc_obs \ -lvx_nc_util \ diff --git a/met/src/tools/other/lidar2nc/Makefile.am b/met/src/tools/other/lidar2nc/Makefile.am index 7bf377b10a..118ea7efd4 100644 --- a/met/src/tools/other/lidar2nc/Makefile.am +++ b/met/src/tools/other/lidar2nc/Makefile.am @@ -26,6 +26,7 @@ lidar2nc_LDADD = -lvx_shapedata \ -lvx_data2d_nc_met \ $(PYTHON_LIBS) \ -lvx_data2d_nccf \ + -lvx_statistics \ -lvx_nc_obs \ -lvx_nc_util \ -lvx_data2d \ diff --git a/met/src/tools/other/madis2nc/Makefile.am b/met/src/tools/other/madis2nc/Makefile.am index f83950661e..e85cf3c975 100644 --- a/met/src/tools/other/madis2nc/Makefile.am +++ b/met/src/tools/other/madis2nc/Makefile.am @@ -25,6 +25,7 @@ madis2nc_LDADD = -lvx_stat_out \ -lvx_data2d_nc_pinterp \ -lvx_data2d_nccf \ $(PYTHON_LIBS) \ + -lvx_statistics \ -lvx_data2d \ -lvx_nc_obs \ -lvx_nc_util \ diff --git a/met/src/tools/other/mode_graphics/Makefile.am b/met/src/tools/other/mode_graphics/Makefile.am index b360dbfb55..fc5e1f530b 100644 --- a/met/src/tools/other/mode_graphics/Makefile.am +++ b/met/src/tools/other/mode_graphics/Makefile.am @@ -27,6 +27,7 @@ plot_mode_field_LDADD = -lvx_config \ -lvx_plot_util \ -lvx_data2d_nc_met \ $(PYTHON_LIBS) \ + -lvx_statistics \ -lvx_grid \ -lvx_nc_util \ -lvx_ps \ diff --git a/met/src/tools/other/mode_time_domain/Makefile.am b/met/src/tools/other/mode_time_domain/Makefile.am index 9b5d9df97f..fde9fbe977 100644 --- a/met/src/tools/other/mode_time_domain/Makefile.am +++ b/met/src/tools/other/mode_time_domain/Makefile.am @@ -55,6 +55,7 @@ mtd_LDADD = -lvx_pxm \ -lvx_data2d_nc_pinterp \ $(PYTHON_LIBS) \ -lvx_data2d_nccf \ + -lvx_statistics \ -lvx_data2d \ -lvx_nc_util \ -lvx_regrid \ diff --git a/met/src/tools/other/modis_regrid/Makefile.am b/met/src/tools/other/modis_regrid/Makefile.am index 843d226bbc..fe3442d728 100644 --- a/met/src/tools/other/modis_regrid/Makefile.am +++ b/met/src/tools/other/modis_regrid/Makefile.am @@ -36,6 +36,7 @@ modis_regrid_LDADD = -lvx_pxm \ -lvx_data2d_grib $(GRIB2_LIBS) \ -lvx_data2d_nc_pinterp \ $(PYTHON_LIBS) \ + -lvx_statistics \ -lvx_data2d \ -lvx_nc_util \ -lvx_grid \ diff --git a/met/src/tools/other/pb2nc/Makefile.am b/met/src/tools/other/pb2nc/Makefile.am index 40ed36c2d2..6eb653a1d0 100644 --- a/met/src/tools/other/pb2nc/Makefile.am +++ b/met/src/tools/other/pb2nc/Makefile.am @@ -42,6 +42,7 @@ pb2nc_LDADD = -lvx_stat_out \ -lvx_data2d_nc_pinterp \ -lvx_data2d_nccf \ $(PYTHON_LIBS) \ + -lvx_statistics \ -lvx_data2d \ -lvx_nc_obs \ -lvx_nc_util \ diff --git a/met/src/tools/other/plot_data_plane/Makefile.am b/met/src/tools/other/plot_data_plane/Makefile.am index 5470661e67..3997aaf742 100644 --- a/met/src/tools/other/plot_data_plane/Makefile.am +++ b/met/src/tools/other/plot_data_plane/Makefile.am @@ -20,6 +20,7 @@ plot_data_plane_LDADD = -lvx_data2d_factory \ -lvx_data2d_nc_pinterp \ $(PYTHON_LIBS) \ -lvx_data2d_nccf \ + -lvx_statistics \ -lvx_nc_util \ -lvx_data2d \ -lvx_plot_util \ @@ -30,6 +31,7 @@ plot_data_plane_LDADD = -lvx_data2d_factory \ -lvx_afm \ -lvx_nav \ -lvx_gnomon \ + -lvx_regrid \ -lvx_grid \ -lvx_config \ -lvx_gsl_prob \ diff --git a/met/src/tools/other/plot_point_obs/Makefile.am b/met/src/tools/other/plot_point_obs/Makefile.am index 677a41a5b4..77e7c1711d 100644 --- a/met/src/tools/other/plot_point_obs/Makefile.am +++ b/met/src/tools/other/plot_point_obs/Makefile.am @@ -40,6 +40,7 @@ plot_point_obs_LDADD = -lvx_statistics \ -lvx_cal \ -lvx_util \ $(PYTHON_LIBS) \ + -lvx_statistics \ -lvx_math \ -lvx_color \ -lvx_log \ diff --git a/met/src/tools/other/point2grid/Makefile.am b/met/src/tools/other/point2grid/Makefile.am index 054a049df7..ccd38b1ac5 100644 --- a/met/src/tools/other/point2grid/Makefile.am +++ b/met/src/tools/other/point2grid/Makefile.am @@ -22,6 +22,7 @@ point2grid_LDADD = -lvx_statistics \ -lvx_data2d_nc_pinterp \ $(PYTHON_LIBS) \ -lvx_data2d_nccf \ + -lvx_statistics \ -lvx_nc_util \ -lvx_data2d \ -lvx_gnomon \ diff --git a/met/src/tools/other/regrid_data_plane/Makefile.am b/met/src/tools/other/regrid_data_plane/Makefile.am index 8c28e3f93f..32bbc91cea 100644 --- a/met/src/tools/other/regrid_data_plane/Makefile.am +++ b/met/src/tools/other/regrid_data_plane/Makefile.am @@ -21,6 +21,7 @@ regrid_data_plane_LDADD = -lvx_statistics \ -lvx_data2d_nc_pinterp \ $(PYTHON_LIBS) \ -lvx_data2d_nccf \ + -lvx_statistics \ -lvx_nc_util \ -lvx_data2d \ -lvx_gnomon \ diff --git a/met/src/tools/other/shift_data_plane/Makefile.am b/met/src/tools/other/shift_data_plane/Makefile.am index 67e02fcfea..af2d6875b8 100644 --- a/met/src/tools/other/shift_data_plane/Makefile.am +++ b/met/src/tools/other/shift_data_plane/Makefile.am @@ -21,6 +21,7 @@ shift_data_plane_LDADD = -lvx_statistics \ -lvx_data2d_nc_pinterp \ $(PYTHON_LIBS) \ -lvx_data2d_nccf \ + -lvx_statistics \ -lvx_nc_util \ -lvx_data2d \ -lvx_gnomon \ diff --git a/met/src/tools/other/wwmca_tool/Makefile.am b/met/src/tools/other/wwmca_tool/Makefile.am index 7972849bf4..ba4e6d5e69 100644 --- a/met/src/tools/other/wwmca_tool/Makefile.am +++ b/met/src/tools/other/wwmca_tool/Makefile.am @@ -44,6 +44,7 @@ wwmca_regrid_LDADD = -lvx_pxm \ -lvx_data2d_nc_pinterp \ $(PYTHON_LIBS) \ -lvx_data2d_nccf \ + -lvx_statistics \ -lvx_data2d \ -lvx_nc_util \ -lvx_regrid \ diff --git a/met/src/tools/tc_utils/rmw_analysis/Makefile.am b/met/src/tools/tc_utils/rmw_analysis/Makefile.am index eca92181cd..61223d7f69 100644 --- a/met/src/tools/tc_utils/rmw_analysis/Makefile.am +++ b/met/src/tools/tc_utils/rmw_analysis/Makefile.am @@ -26,6 +26,7 @@ rmw_analysis_LDADD = -lvx_stat_out \ -lvx_data2d_nc_pinterp \ $(PYTHON_LIBS) \ -lvx_data2d_nccf \ + -lvx_statistics \ -lvx_data2d \ -lvx_nc_util \ -lvx_regrid \ diff --git a/met/src/tools/tc_utils/tc_gen/Makefile.am b/met/src/tools/tc_utils/tc_gen/Makefile.am index 4865e6a517..281811cd88 100644 --- a/met/src/tools/tc_utils/tc_gen/Makefile.am +++ b/met/src/tools/tc_utils/tc_gen/Makefile.am @@ -27,6 +27,7 @@ tc_gen_LDADD = -lvx_stat_out \ -lvx_data2d_nc_pinterp \ $(PYTHON_LIBS) \ -lvx_data2d_nccf \ + -lvx_statistics \ -lvx_data2d \ -lvx_nc_util \ -lvx_regrid \ diff --git a/met/src/tools/tc_utils/tc_pairs/Makefile.am b/met/src/tools/tc_utils/tc_pairs/Makefile.am index 56d6239e2f..d5d4436698 100644 --- a/met/src/tools/tc_utils/tc_pairs/Makefile.am +++ b/met/src/tools/tc_utils/tc_pairs/Makefile.am @@ -29,6 +29,7 @@ tc_pairs_LDADD = -lvx_stat_out \ -lvx_data2d_nc_pinterp \ $(PYTHON_LIBS) \ -lvx_data2d_nccf \ + -lvx_statistics \ -lvx_data2d \ -lvx_nc_util \ -lvx_regrid \ diff --git a/met/src/tools/tc_utils/tc_rmw/Makefile.am b/met/src/tools/tc_utils/tc_rmw/Makefile.am index 5aed64e561..43d075577c 100644 --- a/met/src/tools/tc_utils/tc_rmw/Makefile.am +++ b/met/src/tools/tc_utils/tc_rmw/Makefile.am @@ -26,6 +26,7 @@ tc_rmw_LDADD = -lvx_stat_out \ -lvx_data2d_nc_pinterp \ $(PYTHON_LIBS) \ -lvx_data2d_nccf \ + -lvx_statistics \ -lvx_data2d \ -lvx_nc_util \ -lvx_regrid \ diff --git a/met/src/tools/tc_utils/tc_stat/Makefile.am b/met/src/tools/tc_utils/tc_stat/Makefile.am index 413d2a5141..06b56431ce 100644 --- a/met/src/tools/tc_utils/tc_stat/Makefile.am +++ b/met/src/tools/tc_utils/tc_stat/Makefile.am @@ -29,6 +29,7 @@ tc_stat_LDADD = -lvx_stat_out \ -lvx_data2d_nc_pinterp \ $(PYTHON_LIBS) \ -lvx_data2d_nccf \ + -lvx_statistics \ -lvx_data2d \ -lvx_nc_util \ -lvx_regrid \ From 652a6a78995fc46b667faf28581490c404b2a000 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Mon, 8 Mar 2021 18:50:08 -0700 Subject: [PATCH 3/7] Per #1471, add a sanity check to make sure the grid and data dimensions actually match. --- .../dataplane_from_numpy_array.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/met/src/libcode/vx_data2d_python/dataplane_from_numpy_array.cc b/met/src/libcode/vx_data2d_python/dataplane_from_numpy_array.cc index 5efd29d3c6..6dd44b3815 100644 --- a/met/src/libcode/vx_data2d_python/dataplane_from_numpy_array.cc +++ b/met/src/libcode/vx_data2d_python/dataplane_from_numpy_array.cc @@ -241,6 +241,21 @@ else { grid_from_python_dict(Python3_Dict(py_grid), grid_out); +} + + // + // make sure the grid and data dimensions match + // + +if ( grid_out.nx() != Nx || grid_out.ny() != Ny ) { + + mlog << Error << "\ndataplane_from_numpy_array() -> " + << "the grid dimensions (" << grid_out.nx() << ", " + << grid_out.ny() << ") and data dimensions (" << Nx + << ", " << Ny << ") do not match!\n\n"; + + exit ( 1 ); + } //////////////////// From d4c631cda2de9afffd4d9ad92fe945f82b5a8aa7 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Mon, 8 Mar 2021 20:36:01 -0700 Subject: [PATCH 4/7] Per #1471, add 3 new unit tests to demonstrate setting the python grid as a named grid, grid specification string, or a gridded data file. --- met/scripts/python/Makefile.am | 1 + met/scripts/python/read_ascii_numpy_grid.py | 53 ++++++++++++++++ .../dataplane_from_numpy_array.cc | 2 +- .../libcode/vx_python3_utils/python3_dict.cc | 19 ++++-- .../libcode/vx_python3_utils/python3_dict.h | 2 +- test/xml/unit_python.xml | 62 +++++++++++++++++++ 6 files changed, 132 insertions(+), 7 deletions(-) create mode 100755 met/scripts/python/read_ascii_numpy_grid.py diff --git a/met/scripts/python/Makefile.am b/met/scripts/python/Makefile.am index b980d2e4ab..78dc7d88bc 100644 --- a/met/scripts/python/Makefile.am +++ b/met/scripts/python/Makefile.am @@ -27,6 +27,7 @@ pythonscriptsdir = $(pkgdatadir)/python pythonscripts_DATA = \ read_ascii_numpy.py \ + read_ascii_numpy_grid.py \ read_ascii_xarray.py \ read_ascii_point.py \ read_ascii_mpr.py diff --git a/met/scripts/python/read_ascii_numpy_grid.py b/met/scripts/python/read_ascii_numpy_grid.py new file mode 100755 index 0000000000..88d868a2ad --- /dev/null +++ b/met/scripts/python/read_ascii_numpy_grid.py @@ -0,0 +1,53 @@ +from __future__ import print_function + +import numpy as np +import os +import sys + +########################################### + +print('Python Script:\t', sys.argv[0]) + + ## + ## input file specified on the command line + ## load the data into the numpy array + ## + +if len(sys.argv) == 3: + # Read the input file as the first argument + input_file = os.path.expandvars(sys.argv[1]) + data_name = sys.argv[2] + try: + # Print some output to verify that this script ran + print("Input File:\t" + repr(input_file)) + print("Data Name:\t" + repr(data_name)) + met_data = np.loadtxt(input_file) + print("Data Shape:\t" + repr(met_data.shape)) + print("Data Type:\t" + repr(met_data.dtype)) + except NameError: + print("Can't find the input file") +else: + print("ERROR: read_ascii_numpy.py -> Must specify exactly one input file and a name for the data.") + sys.exit(1) + +########################################### + + ## + ## create the metadata dictionary + ## + +attrs = { + + 'valid': '20050807_120000', + 'init': '20050807_000000', + 'lead': '120000', + 'accum': '120000', + + 'name': data_name, + 'long_name': data_name + '_word', + 'level': 'Surface', + 'units': 'None', + 'grid': os.path.expandvars(os.getenv('PYTHON_GRID')) +} + +print("Attributes:\t" + repr(attrs)) diff --git a/met/src/libcode/vx_data2d_python/dataplane_from_numpy_array.cc b/met/src/libcode/vx_data2d_python/dataplane_from_numpy_array.cc index 6dd44b3815..61f997a267 100644 --- a/met/src/libcode/vx_data2d_python/dataplane_from_numpy_array.cc +++ b/met/src/libcode/vx_data2d_python/dataplane_from_numpy_array.cc @@ -224,7 +224,7 @@ dp_out.set_accum(t); // attempt to parse "grid" as a string // -s = attrs.lookup_string("grid"); +s = attrs.lookup_string("grid", false); if ( s.nonempty() ) { diff --git a/met/src/libcode/vx_python3_utils/python3_dict.cc b/met/src/libcode/vx_python3_utils/python3_dict.cc index 9f6036f801..6d38599aa4 100644 --- a/met/src/libcode/vx_python3_utils/python3_dict.cc +++ b/met/src/libcode/vx_python3_utils/python3_dict.cc @@ -220,7 +220,7 @@ return ( t ); //////////////////////////////////////////////////////////////////////// -ConcatString Python3_Dict::lookup_string(const char * key) const +ConcatString Python3_Dict::lookup_string(const char * key, bool error_out) const { @@ -240,14 +240,23 @@ if ( ! a ) { if ( ! PyUnicode_Check(a) ) { - mlog << Error << "\nPython3_Dict::lookup_string(const char * key) -> " - << "value for key \"" << key << "\" not a character string\n\n"; + if ( error_out ) { - exit ( 1 ); + mlog << Error << "\nPython3_Dict::lookup_string(const char * key) -> " + << "value for key \"" << key << "\" not a character string\n\n"; + + exit ( 1 ); + + } + + s.clear(); } +else { -s = PyUnicode_AsUTF8(a); + s = PyUnicode_AsUTF8(a); + +} return ( s ); diff --git a/met/src/libcode/vx_python3_utils/python3_dict.h b/met/src/libcode/vx_python3_utils/python3_dict.h index 7ce77d7b05..34cfd803de 100644 --- a/met/src/libcode/vx_python3_utils/python3_dict.h +++ b/met/src/libcode/vx_python3_utils/python3_dict.h @@ -68,7 +68,7 @@ class Python3_Dict { int lookup_int (const char * key) const; double lookup_double (const char * key) const; - ConcatString lookup_string (const char * key) const; + ConcatString lookup_string (const char * key, bool error_out = true) const; PyObject * lookup_dict (const char * key) const; PyObject * lookup_list (const char * key) const; diff --git a/test/xml/unit_python.xml b/test/xml/unit_python.xml index 58936ecbad..c204534f05 100644 --- a/test/xml/unit_python.xml +++ b/test/xml/unit_python.xml @@ -19,6 +19,68 @@ &TEST_DIR; true + + + &MET_BIN;/plot_data_plane + + PYTHON_GRID G212 + + \ + PYTHON_NUMPY \ + &OUTPUT_DIR;/python/letter_numpy_grid_name.ps \ + 'name = "&MET_BASE;/python/read_ascii_numpy_grid.py &DATA_DIR_PYTHON;/letter.txt LETTER";' \ + -plot_range 0.0 255.0 \ + -title "Grid Name: 'G212'" \ + -v 1 + + + &OUTPUT_DIR;/python/letter_numpy_grid_name.ps + + + + + + &MET_BIN;/plot_data_plane + + + PYTHON_GRID + lambert 185 129 12.19 -133.459 -95 40.635 6371.2 25 25 N + + + \ + PYTHON_NUMPY \ + &OUTPUT_DIR;/python/letter_numpy_grid_string.ps \ + 'name = "&MET_BASE;/python/read_ascii_numpy_grid.py &DATA_DIR_PYTHON;/letter.txt LETTER";' \ + -plot_range 0.0 255.0 \ + -title "Grid String: '${PYTHON_GRID}'" \ + -v 1 + + + &OUTPUT_DIR;/python/letter_numpy_grid_string.ps + + + + + + &MET_BIN;/plot_data_plane + + + PYTHON_GRID + &MET_DATA;/sample_fcst/2005080700/wrfprs_ruc13_12.tm00_G212 + + \ + PYTHON_NUMPY \ + &OUTPUT_DIR;/python/letter_numpy_grid_data_file.ps \ + 'name = "&MET_BASE;/python/read_ascii_numpy_grid.py &DATA_DIR_PYTHON;/letter.txt LETTER";' \ + -plot_range 0.0 255.0 \ + -title "Gridded Data File: 'wrfprs_ruc13_12.tm00_G212'" \ + -v 1 + + + &OUTPUT_DIR;/python/letter_numpy_grid_data_file.ps + + + &MET_BIN;/plot_data_plane From 85f42919f4a0ce7f84fc7fb22cdca4655136a2f3 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Mon, 8 Mar 2021 22:12:34 -0700 Subject: [PATCH 5/7] Per #1471, document python grid changes in appendix F. --- met/docs/Users_Guide/appendixF.rst | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/met/docs/Users_Guide/appendixF.rst b/met/docs/Users_Guide/appendixF.rst index e122d6a560..a8df1374b7 100644 --- a/met/docs/Users_Guide/appendixF.rst +++ b/met/docs/Users_Guide/appendixF.rst @@ -65,7 +65,9 @@ The data must be loaded into a 2D NumPy array named **met_data**. In addition th 'long_name': 'FooBar', 'level': 'Surface', 'units': 'None', - + + # Define 'grid' as a string or dictionary + 'grid': { 'type': 'Lambert Conformal', 'hemisphere': 'N', @@ -86,9 +88,29 @@ The data must be loaded into a 2D NumPy array named **met_data**. In addition th } -In the dictionary, valid time, initialization time, lead time and accumulation time (if any) must be indicated by strings. Valid and initialization times must be given in YYYYMMDD[_HH[MMSS]] format, and lead and accumulation times must be given in HH[MMSS] format, where the square brackets indicate optional elements. The dictionary must also include strings for the name, long_name, level, and units to describe the data. The rest of the **attrs** dictionary gives the grid size and projection information in the same format that is used in the netCDF files written out by the MET tools. Those entries are also listed below. Note that the **grid** entry in the **attrs** dictionary is itself a dictionary. +In the dictionary, valid time, initialization time, lead time and accumulation time (if any) must be indicated by strings. Valid and initialization times must be given in YYYYMMDD[_HH[MMSS]] format, and lead and accumulation times must be given in HH[MMSS] format, where the square brackets indicate optional elements. The dictionary must also include strings for the name, long_name, level, and units to describe the data. The rest of the **attrs** dictionary gives the grid size and projection information in the same format that is used in the netCDF files written out by the MET tools. Those entries are also listed below. Note that the **grid** entry in the **attrs** dictionary can either be defined as a string or as a dictionary itself. + +If specified as a string, **grid** can be defined as follows: + +• As a named grid: + +.. code-block:: none + + 'grid': 'G212' + +• As a grid specification string, as described in :ref:`appendixB`: + +.. code-block:: none + + 'grid': 'lambert 185 129 12.19 -133.459 -95 40.635 6371.2 25 25 N' + +• As the path to an existing gridded data file: + +.. code-block:: none + + 'grid': '/path/to/sample_data.grib' -The supported grid **type** strings are described below: +When specified as a dictionary, the contents of the **grid** dictionary vary based on the grid **type** string. The entries for the supported grid types are described below: • **Lambert Conformal** grid dictionary entries: From a14ea346f082a49e42107579c2ca8b22d1c3f255 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Mon, 8 Mar 2021 22:15:18 -0700 Subject: [PATCH 6/7] Per #1471, just spacing. --- met/docs/Users_Guide/appendixF.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/met/docs/Users_Guide/appendixF.rst b/met/docs/Users_Guide/appendixF.rst index a8df1374b7..a5e34df338 100644 --- a/met/docs/Users_Guide/appendixF.rst +++ b/met/docs/Users_Guide/appendixF.rst @@ -66,7 +66,7 @@ The data must be loaded into a 2D NumPy array named **met_data**. In addition th 'level': 'Surface', 'units': 'None', - # Define 'grid' as a string or dictionary + # Define 'grid' as a string or a dictionary 'grid': { 'type': 'Lambert Conformal', @@ -85,7 +85,7 @@ The data must be loaded into a 2D NumPy array named **met_data**. In addition th 'ny': 129, } - } + } In the dictionary, valid time, initialization time, lead time and accumulation time (if any) must be indicated by strings. Valid and initialization times must be given in YYYYMMDD[_HH[MMSS]] format, and lead and accumulation times must be given in HH[MMSS] format, where the square brackets indicate optional elements. The dictionary must also include strings for the name, long_name, level, and units to describe the data. The rest of the **attrs** dictionary gives the grid size and projection information in the same format that is used in the netCDF files written out by the MET tools. Those entries are also listed below. Note that the **grid** entry in the **attrs** dictionary can either be defined as a string or as a dictionary itself. @@ -96,19 +96,19 @@ If specified as a string, **grid** can be defined as follows: .. code-block:: none - 'grid': 'G212' + 'grid': 'G212' • As a grid specification string, as described in :ref:`appendixB`: .. code-block:: none - 'grid': 'lambert 185 129 12.19 -133.459 -95 40.635 6371.2 25 25 N' + 'grid': 'lambert 185 129 12.19 -133.459 -95 40.635 6371.2 25 25 N' • As the path to an existing gridded data file: .. code-block:: none - 'grid': '/path/to/sample_data.grib' + 'grid': '/path/to/sample_data.grib' When specified as a dictionary, the contents of the **grid** dictionary vary based on the grid **type** string. The entries for the supported grid types are described below: From 884d841474c835b3353706e56907dbb3c8b55306 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Tue, 9 Mar 2021 22:52:55 -0700 Subject: [PATCH 7/7] Per #1471, lots of Makefile.am changes to get this code to compile on kiowa. Worringly, it compiled and linked fine on my Mac laptop but not on kiowa. Must be some large differences in the linker logic. --- met/internal_tests/basic/vx_util/Makefile.am | 10 ++++-- .../libcode/vx_data2d_factory/Makefile.am | 1 + .../libcode/vx_nc_util/Makefile.am | 15 +++++--- .../libcode/vx_tc_util/Makefile.am | 25 ++++++++------ .../tools/other/mode_time_domain/Makefile.am | 2 ++ met/src/tools/core/mode_analysis/Makefile.am | 19 ++++------- met/src/tools/core/stat_analysis/Makefile.am | 8 +---- met/src/tools/other/gsi_tools/Makefile.am | 34 ++++++++++--------- met/src/tools/other/modis_regrid/Makefile.am | 1 + 9 files changed, 62 insertions(+), 53 deletions(-) diff --git a/met/internal_tests/basic/vx_util/Makefile.am b/met/internal_tests/basic/vx_util/Makefile.am index 5501f38d86..96afff9e82 100644 --- a/met/internal_tests/basic/vx_util/Makefile.am +++ b/met/internal_tests/basic/vx_util/Makefile.am @@ -87,21 +87,25 @@ test_ascii_header_LDADD = -lvx_stat_out \ -lvx_shapedata \ -lvx_gsl_prob \ -lvx_analysis_util \ + -lvx_shapedata \ + -lvx_util \ + $(PYTHON_LIBS) \ + -lvx_statistics \ -lvx_data2d_factory \ -lvx_data2d_nc_met \ - -lvx_data2d_grib $(GRIB2_LIBS) \ -lvx_data2d_nc_pinterp \ $(PYTHON_LIBS) \ -lvx_data2d_nccf \ - -lvx_statistics \ + -lvx_data2d_grib $(GRIB2_LIBS) \ -lvx_data2d \ -lvx_nc_util \ -lvx_regrid \ -lvx_grid \ -lvx_config \ + -lvx_gsl_prob \ -lvx_cal \ -lvx_util \ -lvx_math \ -lvx_color \ -lvx_log \ - -lm -lnetcdf_c++4 -lnetcdf -lgsl -lgslcblas + -lm -lnetcdf_c++4 -lnetcdf -lgsl -lgslcblas -lvx_util diff --git a/met/internal_tests/libcode/vx_data2d_factory/Makefile.am b/met/internal_tests/libcode/vx_data2d_factory/Makefile.am index 3800c9d02c..04a31968c0 100644 --- a/met/internal_tests/libcode/vx_data2d_factory/Makefile.am +++ b/met/internal_tests/libcode/vx_data2d_factory/Makefile.am @@ -42,6 +42,7 @@ test_factory_LDADD = -lvx_stat_out \ -lvx_regrid \ -lvx_grid \ -lvx_config \ + -lvx_gsl_prob \ -lvx_cal \ -lvx_util \ -lvx_math \ diff --git a/met/internal_tests/libcode/vx_nc_util/Makefile.am b/met/internal_tests/libcode/vx_nc_util/Makefile.am index b39b62abcf..ff40235a5c 100644 --- a/met/internal_tests/libcode/vx_nc_util/Makefile.am +++ b/met/internal_tests/libcode/vx_nc_util/Makefile.am @@ -19,27 +19,32 @@ noinst_PROGRAMS = test_pressure_levels test_pressure_levels_SOURCES = test_pressure_levels.cc test_pressure_levels_CPPFLAGS = ${MET_CPPFLAGS} test_pressure_levels_LDFLAGS = -L. ${MET_LDFLAGS} -test_pressure_levels_LDADD = -lvx_tc_util \ - -lvx_stat_out \ +test_pressure_levels_LDADD = -lvx_stat_out \ -lvx_statistics \ -lvx_shapedata \ -lvx_gsl_prob \ -lvx_analysis_util \ + -lvx_tc_util \ + -lvx_shapedata \ + -lvx_util \ + $(PYTHON_LIBS) \ + -lvx_statistics \ -lvx_data2d_factory \ -lvx_data2d_nc_met \ - -lvx_data2d_grib $(GRIB2_LIBS) \ -lvx_data2d_nc_pinterp \ $(PYTHON_LIBS) \ -lvx_data2d_nccf \ - -lvx_statistics \ + -lvx_data2d_grib $(GRIB2_LIBS) \ -lvx_data2d \ -lvx_nc_util \ -lvx_regrid \ -lvx_grid \ -lvx_config \ + -lvx_gsl_prob \ -lvx_cal \ -lvx_util \ -lvx_math \ -lvx_color \ -lvx_log \ - -lm -lnetcdf_c++4 -lnetcdf -lgsl -lgslcblas + -lm -lnetcdf_c++4 -lnetcdf -lgsl -lgslcblas -lvx_util + diff --git a/met/internal_tests/libcode/vx_tc_util/Makefile.am b/met/internal_tests/libcode/vx_tc_util/Makefile.am index 9af1e702a3..a5fc96c5d0 100644 --- a/met/internal_tests/libcode/vx_tc_util/Makefile.am +++ b/met/internal_tests/libcode/vx_tc_util/Makefile.am @@ -26,26 +26,28 @@ test_read_LDADD = -lvx_stat_out \ -lvx_gsl_prob \ -lvx_analysis_util \ -lvx_tc_util \ + -lvx_shapedata \ + -lvx_util \ + $(PYTHON_LIBS) \ + -lvx_statistics \ -lvx_data2d_factory \ -lvx_data2d_nc_met \ - -lvx_data2d_grib $(GRIB2_LIBS) \ -lvx_data2d_nc_pinterp \ $(PYTHON_LIBS) \ -lvx_data2d_nccf \ - -lvx_statistics \ + -lvx_data2d_grib $(GRIB2_LIBS) \ -lvx_data2d \ -lvx_nc_util \ -lvx_regrid \ -lvx_grid \ -lvx_config \ - -lvx_pb_util \ + -lvx_gsl_prob \ -lvx_cal \ - -lvx_nav \ -lvx_util \ -lvx_math \ -lvx_color \ -lvx_log \ - -lm -lnetcdf_c++4 -lnetcdf -lgsl -lgslcblas + -lm -lnetcdf_c++4 -lnetcdf -lgsl -lgslcblas -lvx_util test_read_prob_SOURCES = test_read_prob.cc test_read_prob_CPPFLAGS = ${MET_CPPFLAGS} @@ -56,23 +58,26 @@ test_read_prob_LDADD = -lvx_stat_out \ -lvx_gsl_prob \ -lvx_analysis_util \ -lvx_tc_util \ + -lvx_shapedata \ + -lvx_util \ + $(PYTHON_LIBS) \ + -lvx_statistics \ -lvx_data2d_factory \ -lvx_data2d_nc_met \ - -lvx_data2d_grib $(GRIB2_LIBS) \ -lvx_data2d_nc_pinterp \ $(PYTHON_LIBS) \ -lvx_data2d_nccf \ - -lvx_statistics \ + -lvx_data2d_grib $(GRIB2_LIBS) \ -lvx_data2d \ -lvx_nc_util \ -lvx_regrid \ -lvx_grid \ -lvx_config \ - -lvx_pb_util \ + -lvx_gsl_prob \ -lvx_cal \ - -lvx_nav \ -lvx_util \ -lvx_math \ -lvx_color \ -lvx_log \ - -lm -lnetcdf_c++4 -lnetcdf -lgsl -lgslcblas \ No newline at end of file + -lm -lnetcdf_c++4 -lnetcdf -lgsl -lgslcblas -lvx_util + diff --git a/met/internal_tests/tools/other/mode_time_domain/Makefile.am b/met/internal_tests/tools/other/mode_time_domain/Makefile.am index 2b62114046..693d9de44c 100644 --- a/met/internal_tests/tools/other/mode_time_domain/Makefile.am +++ b/met/internal_tests/tools/other/mode_time_domain/Makefile.am @@ -56,6 +56,7 @@ test_velocity_LDADD = \ -lvx_data2d_grib $(GRIB2_LIBS) \ -lvx_data2d_nc_pinterp \ $(PYTHON_LIBS) \ + -lvx_statistics \ -lvx_data2d_nccf \ -lvx_data2d \ -lvx_nc_util \ @@ -69,3 +70,4 @@ test_velocity_LDADD = \ -lvx_color \ -lvx_log \ -lm -lnetcdf_c++4 -lnetcdf -lgsl -lgslcblas -lz + diff --git a/met/src/tools/core/mode_analysis/Makefile.am b/met/src/tools/core/mode_analysis/Makefile.am index 18de50a937..182faf29d1 100644 --- a/met/src/tools/core/mode_analysis/Makefile.am +++ b/met/src/tools/core/mode_analysis/Makefile.am @@ -8,10 +8,6 @@ MAINTAINERCLEANFILES = Makefile.in include ${top_srcdir}/Make-include -if ENABLE_PYTHON -LDFLAGS += -lvx_python3_utils -endif - # The program bin_PROGRAMS = mode_analysis @@ -24,28 +20,27 @@ mode_analysis_LDADD = -lvx_stat_out \ -lvx_shapedata \ -lvx_gsl_prob \ -lvx_analysis_util \ + -lvx_shapedata \ + -lvx_util \ + $(PYTHON_LIBS) \ + -lvx_statistics \ -lvx_data2d_factory \ -lvx_data2d_nc_met \ - -lvx_data2d_grib $(GRIB2_LIBS) \ -lvx_data2d_nc_pinterp \ $(PYTHON_LIBS) \ -lvx_data2d_nccf \ - -lvx_statistics \ + -lvx_data2d_grib $(GRIB2_LIBS) \ -lvx_data2d \ -lvx_nc_util \ -lvx_regrid \ -lvx_grid \ -lvx_config \ + -lvx_gsl_prob \ -lvx_cal \ -lvx_util \ -lvx_math \ -lvx_color \ -lvx_log \ - -lm -lnetcdf_c++4 -lnetcdf -lgsl -lgslcblas -lz - -if ENABLE_PYTHON -mode_analysis_LDADD += $(MET_PYTHON_LD) -lvx_data2d_python -lvx_python3_utils -lvx_data2d_python -lvx_python3_utils -lvx_util -endif - + -lm -lnetcdf_c++4 -lnetcdf -lgsl -lgslcblas -lvx_util EXTRA_DIST = config_to_att.h diff --git a/met/src/tools/core/stat_analysis/Makefile.am b/met/src/tools/core/stat_analysis/Makefile.am index ae6e9f9e89..60ca332858 100644 --- a/met/src/tools/core/stat_analysis/Makefile.am +++ b/met/src/tools/core/stat_analysis/Makefile.am @@ -8,19 +8,13 @@ MAINTAINERCLEANFILES = Makefile.in include ${top_srcdir}/Make-include -OPT_PYTHON_SOURCES = - -if ENABLE_PYTHON -LDFLAGS += -lvx_python3_utils -endif - # The program bin_PROGRAMS = stat_analysis stat_analysis_SOURCES = stat_analysis.cc \ aggr_stat_line.cc \ parse_stat_line.cc \ - stat_analysis_job.cc $(OPT_PYTHON_SOURCES) + stat_analysis_job.cc stat_analysis_CPPFLAGS = ${MET_CPPFLAGS} stat_analysis_LDFLAGS = ${MET_LDFLAGS} stat_analysis_LDADD = -lvx_stat_out \ diff --git a/met/src/tools/other/gsi_tools/Makefile.am b/met/src/tools/other/gsi_tools/Makefile.am index cd609c22dd..1c94d4be2b 100644 --- a/met/src/tools/other/gsi_tools/Makefile.am +++ b/met/src/tools/other/gsi_tools/Makefile.am @@ -8,10 +8,6 @@ MAINTAINERCLEANFILES = Makefile.in include ${top_srcdir}/Make-include -if ENABLE_PYTHON -LDFLAGS += -lvx_data2d_python -lvx_python3_utils -endif - # The programs bin_PROGRAMS = gsid2mpr \ @@ -36,29 +32,31 @@ gsid2mpr_CPPFLAGS = ${MET_CPPFLAGS} gsid2mpr_LDFLAGS = ${MET_LDFLAGS} gsid2mpr_LDADD = -lvx_stat_out \ -lvx_statistics \ + -lvx_shapedata \ -lvx_gsl_prob \ + -lvx_analysis_util \ + -lvx_shapedata \ + -lvx_util \ + $(PYTHON_LIBS) \ + -lvx_statistics \ -lvx_data2d_factory \ -lvx_data2d_nc_met \ - -lvx_data2d_grib $(GRIB2_LIBS) \ -lvx_data2d_nc_pinterp \ $(PYTHON_LIBS) \ -lvx_data2d_nccf \ - -lvx_statistics \ + -lvx_data2d_grib $(GRIB2_LIBS) \ -lvx_data2d \ -lvx_nc_util \ -lvx_regrid \ -lvx_grid \ -lvx_config \ + -lvx_gsl_prob \ -lvx_cal \ -lvx_util \ -lvx_math \ -lvx_color \ -lvx_log \ - -lm -lnetcdf_c++4 -lnetcdf -lgsl -lgslcblas - -if ENABLE_PYTHON -gsid2mpr_LDADD += $(MET_PYTHON_LD) -lvx_data2d_python -lvx_python3_utils -lvx_data2d_python -lvx_python3_utils -endif + -lm -lnetcdf_c++4 -lnetcdf -lgsl -lgslcblas -lvx_util gsidens2orank_SOURCES = gsidens2orank.h \ gsi_record.h \ @@ -79,25 +77,29 @@ gsidens2orank_CPPFLAGS = ${MET_CPPFLAGS} gsidens2orank_LDFLAGS = ${MET_LDFLAGS} gsidens2orank_LDADD = -lvx_stat_out \ -lvx_statistics \ + -lvx_shapedata \ -lvx_gsl_prob \ + -lvx_analysis_util \ + -lvx_shapedata \ + -lvx_util \ + $(PYTHON_LIBS) \ + -lvx_statistics \ -lvx_data2d_factory \ -lvx_data2d_nc_met \ - -lvx_data2d_grib $(GRIB2_LIBS) \ -lvx_data2d_nc_pinterp \ $(PYTHON_LIBS) \ -lvx_data2d_nccf \ + -lvx_data2d_grib $(GRIB2_LIBS) \ -lvx_data2d \ -lvx_nc_util \ -lvx_regrid \ -lvx_grid \ -lvx_config \ + -lvx_gsl_prob \ -lvx_cal \ -lvx_util \ -lvx_math \ -lvx_color \ -lvx_log \ - -lm -lnetcdf_c++4 -lnetcdf -lgsl -lgslcblas + -lm -lnetcdf_c++4 -lnetcdf -lgsl -lgslcblas -lvx_util -if ENABLE_PYTHON -gsidens2orank_LDADD += $(MET_PYTHON_LD) -lvx_data2d_python -lvx_python3_utils -lvx_data2d_python -lvx_python3_utils -endif diff --git a/met/src/tools/other/modis_regrid/Makefile.am b/met/src/tools/other/modis_regrid/Makefile.am index fe3442d728..e63afad3f0 100644 --- a/met/src/tools/other/modis_regrid/Makefile.am +++ b/met/src/tools/other/modis_regrid/Makefile.am @@ -39,6 +39,7 @@ modis_regrid_LDADD = -lvx_pxm \ -lvx_statistics \ -lvx_data2d \ -lvx_nc_util \ + -lvx_regrid \ -lvx_grid \ -lvx_config \ -lvx_gsl_prob \