From d2989579b0a500ffea13f5afb5c601e807907244 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Wed, 25 Sep 2024 17:41:04 +0000 Subject: [PATCH 1/4] 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. --- src/tools/other/mode_time_domain/Makefile.am | 1 - src/tools/other/mode_time_domain/Makefile.in | 34 +- .../other/mode_time_domain/mtd_file_base.cc | 10 +- .../other/mode_time_domain/mtd_nc_output.cc | 4 +- .../other/mode_time_domain/mtd_nc_output.h | 1 - src/tools/other/mode_time_domain/nc_grid.cc | 665 ------------------ src/tools/other/mode_time_domain/nc_grid.h | 41 -- 7 files changed, 17 insertions(+), 739 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 diff --git a/src/tools/other/mode_time_domain/Makefile.am b/src/tools/other/mode_time_domain/Makefile.am index 44cdb1d48c..f365943e88 100644 --- a/src/tools/other/mode_time_domain/Makefile.am +++ b/src/tools/other/mode_time_domain/Makefile.am @@ -13,7 +13,6 @@ 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 150fee1f33..309eaf9162 100644 --- a/src/tools/other/mode_time_domain/Makefile.in +++ b/src/tools/other/mode_time_domain/Makefile.in @@ -102,13 +102,13 @@ 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) \ - mtd-mtd_file_base.$(OBJEXT) mtd-mtd_file_float.$(OBJEXT) \ - mtd-mtd_file_int.$(OBJEXT) mtd-mtd_read_data.$(OBJEXT) \ - mtd-3d_att.$(OBJEXT) mtd-3d_att_single_array.$(OBJEXT) \ + mtd-nc_utils_local.$(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) mtd-mtd_file_base.$(OBJEXT) \ + mtd-mtd_file_float.$(OBJEXT) mtd-mtd_file_int.$(OBJEXT) \ + mtd-mtd_read_data.$(OBJEXT) mtd-3d_att.$(OBJEXT) \ + mtd-3d_att_single_array.$(OBJEXT) \ mtd-3d_att_pair_array.$(OBJEXT) mtd-2d_att.$(OBJEXT) \ mtd-2d_att_array.$(OBJEXT) mtd-3d_conv.$(OBJEXT) \ mtd-mtd_txt_output.$(OBJEXT) mtd-mtd_nc_output.$(OBJEXT) \ @@ -151,7 +151,7 @@ am__depfiles_remade = ./$(DEPDIR)/mtd-2d_att.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-nc_utils_local.Po am__mv = mv -f AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) @@ -357,7 +357,6 @@ 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 \ @@ -525,7 +524,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): @@ -590,20 +588,6 @@ mtd-nc_utils_local.obj: nc_utils_local.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-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 @@ -1048,7 +1032,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 \ @@ -1118,7 +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/mtd_file_base.cc b/src/tools/other/mode_time_domain/mtd_file_base.cc index 3f2ae5a5ce..44dee81604 100644 --- a/src/tools/other/mode_time_domain/mtd_file_base.cc +++ b/src/tools/other/mode_time_domain/mtd_file_base.cc @@ -26,9 +26,10 @@ using namespace netCDF; #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 "write_netcdf.h" #include "vx_math.h" @@ -433,7 +434,7 @@ Nt = GET_NC_SIZE(dim); G = new Grid; -read_nc_grid(f, *G); +read_netcdf_grid(&f, *G); // timestamp info @@ -488,7 +489,10 @@ add_dim(&f, nt_dim_name, Nt); // Grid -write_nc_grid(f, *G); +NcDim lat_dim = get_nc_dim(&f, ny_dim_name); +NcDim lon_dim = get_nc_dim(&f, nx_dim_name); + +write_netcdf_proj(&f, *G, lat_dim, lon_dim); // timestamp info diff --git a/src/tools/other/mode_time_domain/mtd_nc_output.cc b/src/tools/other/mode_time_domain/mtd_nc_output.cc index 7d831c3909..b1fa9eb302 100644 --- a/src/tools/other/mode_time_domain/mtd_nc_output.cc +++ b/src/tools/other/mode_time_domain/mtd_nc_output.cc @@ -82,7 +82,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 @@ -164,7 +164,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 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 4ed161ee84..f0677e95ae 100644 --- a/src/tools/other/mode_time_domain/mtd_nc_output.h +++ b/src/tools/other/mode_time_domain/mtd_nc_output.h @@ -19,7 +19,6 @@ #include "mtd_nc_defs.h" -#include "nc_grid.h" #include "nc_utils_local.h" #include "mtd_file_float.h" 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 00fab4f150..0000000000 --- a/src/tools/other/mode_time_domain/nc_grid.cc +++ /dev/null @@ -1,665 +0,0 @@ -// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* -// ** Copyright UCAR (c) 1992 - 2023 -// ** 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 -// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* - - - -//////////////////////////////////////////////////////////////////////// - - -using namespace std; - -#include -#include -#include -#include -#include -#include - -#include -using namespace netCDF; - -#include "nc_utils_local.h" -#include "nc_grid.h" - - -//////////////////////////////////////////////////////////////////////// - - -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 f3e111039c..0000000000 --- a/src/tools/other/mode_time_domain/nc_grid.h +++ /dev/null @@ -1,41 +0,0 @@ -// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* -// ** Copyright UCAR (c) 1992 - 2023 -// ** 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__ */ - - -//////////////////////////////////////////////////////////////////////// - - From 1e14cb197e129dec3e6e2ddfa3f87b7d9d1ab7bd Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Wed, 25 Sep 2024 17:52:27 +0000 Subject: [PATCH 2/4] Per #2979, remove references to nc_grid.o from the MTD test code. --- internal/test_util/tools/other/mode_time_domain/Makefile.am | 1 - internal/test_util/tools/other/mode_time_domain/Makefile.in | 2 -- 2 files changed, 3 deletions(-) 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 3dc14e906c..c1204dcfc4 100644 --- a/internal/test_util/tools/other/mode_time_domain/Makefile.am +++ b/internal/test_util/tools/other/mode_time_domain/Makefile.am @@ -38,7 +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 \ 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 334d885de7..01d9419636 100644 --- a/internal/test_util/tools/other/mode_time_domain/Makefile.in +++ b/internal/test_util/tools/other/mode_time_domain/Makefile.in @@ -125,7 +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) test_velocity_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \ @@ -362,7 +361,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 \ From d315ea860a109df725e2cc3e14fcfc0ffc9c5c25 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Wed, 25 Sep 2024 19:17:09 +0000 Subject: [PATCH 3/4] 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(...). --- src/tools/other/mode_time_domain/mtd_file_base.cc | 10 ++++------ src/tools/other/mode_time_domain/mtd_nc_output.cc | 8 ++------ 2 files changed, 6 insertions(+), 12 deletions(-) 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 44dee81604..e79decba08 100644 --- a/src/tools/other/mode_time_domain/mtd_file_base.cc +++ b/src/tools/other/mode_time_domain/mtd_file_base.cc @@ -481,18 +481,16 @@ 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 -NcDim lat_dim = get_nc_dim(&f, ny_dim_name); -NcDim lon_dim = get_nc_dim(&f, nx_dim_name); +NcDim ny_dim; +NcDim nx_dim; -write_netcdf_proj(&f, *G, lat_dim, lon_dim); +write_netcdf_proj(&f, *G, ny_dim, nx_dim); // timestamp info diff --git a/src/tools/other/mode_time_domain/mtd_nc_output.cc b/src/tools/other/mode_time_domain/mtd_nc_output.cc index b1fa9eb302..1b3cda7655 100644 --- a/src/tools/other/mode_time_domain/mtd_nc_output.cc +++ b/src/tools/other/mode_time_domain/mtd_nc_output.cc @@ -68,11 +68,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()); // @@ -150,11 +148,9 @@ if ( IS_INVALID_NC(out) ) { } // - // 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()); // From a0fee429ee27457dc7566739077c82f1356e44d2 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Wed, 25 Sep 2024 19:57:47 +0000 Subject: [PATCH 4/4] Per #2979, add this issue to the revision history. --- src/tools/other/mode_time_domain/mtd.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tools/other/mode_time_domain/mtd.cc b/src/tools/other/mode_time_domain/mtd.cc index 6c73beca85..227f8e0842 100644 --- a/src/tools/other/mode_time_domain/mtd.cc +++ b/src/tools/other/mode_time_domain/mtd.cc @@ -22,6 +22,7 @@ // 004 07-06-22 Howard Soh METplus-Internal #19 Rename main to met_main // 005 08-01-22 Albo MET #1971 Differing time steps // 006 10-03-22 Prestopnik MET #2227 Remove using namespace std from header files +// 007 09-25-24 Halley Gotway MET #2979 Fix for all supported projections // ////////////////////////////////////////////////////////////////////////