From 00cfdc5d41858effdc7a282513a04415ce64eed9 Mon Sep 17 00:00:00 2001 From: CoryMartin-NOAA Date: Mon, 7 Aug 2023 14:28:55 +0000 Subject: [PATCH 01/15] Move soca utils to subdirectory --- utils/CMakeLists.txt | 12 +----------- utils/soca/CMakeLists.txt | 11 +++++++++++ utils/{ => soca}/gdas_socahybridweights.cc | 0 utils/{ => soca}/gdas_socahybridweights.h | 0 utils/{ => soca}/gdas_socaincr2mom6.cc | 0 utils/{ => soca}/gdas_socaincr2mom6.h | 0 6 files changed, 12 insertions(+), 11 deletions(-) create mode 100644 utils/soca/CMakeLists.txt rename utils/{ => soca}/gdas_socahybridweights.cc (100%) rename utils/{ => soca}/gdas_socahybridweights.h (100%) rename utils/{ => soca}/gdas_socaincr2mom6.cc (100%) rename utils/{ => soca}/gdas_socaincr2mom6.h (100%) diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index fa229981b..4fc9a64a5 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -5,14 +5,4 @@ find_package(oops REQUIRED) find_package(atlas REQUIRED) find_package(soca REQUIRED) -ecbuild_add_executable( TARGET gdas_socaincr2mom6.x - SOURCES gdas_socaincr2mom6.cc ) - -target_compile_features( gdas_socaincr2mom6.x PUBLIC cxx_std_17) -target_link_libraries( gdas_socaincr2mom6.x PUBLIC NetCDF::NetCDF_CXX oops atlas soca) - -ecbuild_add_executable( TARGET gdas_socahybridweights.x - SOURCES gdas_socahybridweights.cc ) - -target_compile_features( gdas_socahybridweights.x PUBLIC cxx_std_17) -target_link_libraries( gdas_socahybridweights.x PUBLIC NetCDF::NetCDF_CXX oops atlas soca) +add_subdirectory(soca) diff --git a/utils/soca/CMakeLists.txt b/utils/soca/CMakeLists.txt new file mode 100644 index 000000000..4069f52a3 --- /dev/null +++ b/utils/soca/CMakeLists.txt @@ -0,0 +1,11 @@ +ecbuild_add_executable( TARGET gdas_socaincr2mom6.x + SOURCES gdas_socaincr2mom6.cc ) + +target_compile_features( gdas_socaincr2mom6.x PUBLIC cxx_std_17) +target_link_libraries( gdas_socaincr2mom6.x PUBLIC NetCDF::NetCDF_CXX oops atlas soca) + +ecbuild_add_executable( TARGET gdas_socahybridweights.x + SOURCES gdas_socahybridweights.cc ) + +target_compile_features( gdas_socahybridweights.x PUBLIC cxx_std_17) +target_link_libraries( gdas_socahybridweights.x PUBLIC NetCDF::NetCDF_CXX oops atlas soca) diff --git a/utils/gdas_socahybridweights.cc b/utils/soca/gdas_socahybridweights.cc similarity index 100% rename from utils/gdas_socahybridweights.cc rename to utils/soca/gdas_socahybridweights.cc diff --git a/utils/gdas_socahybridweights.h b/utils/soca/gdas_socahybridweights.h similarity index 100% rename from utils/gdas_socahybridweights.h rename to utils/soca/gdas_socahybridweights.h diff --git a/utils/gdas_socaincr2mom6.cc b/utils/soca/gdas_socaincr2mom6.cc similarity index 100% rename from utils/gdas_socaincr2mom6.cc rename to utils/soca/gdas_socaincr2mom6.cc diff --git a/utils/gdas_socaincr2mom6.h b/utils/soca/gdas_socaincr2mom6.h similarity index 100% rename from utils/gdas_socaincr2mom6.h rename to utils/soca/gdas_socaincr2mom6.h From 072b63dead7a2de7c65e2e963637058717ea541e Mon Sep 17 00:00:00 2001 From: CoryMartin-NOAA Date: Mon, 7 Aug 2023 12:57:50 -0400 Subject: [PATCH 02/15] print out nlocs --- utils/CMakeLists.txt | 1 + utils/ioda_example/CMakeLists.txt | 6 ++++ utils/ioda_example/gdas_dumpioda.cc | 12 ++++++++ utils/ioda_example/gdas_dumpioda.h | 48 +++++++++++++++++++++++++++++ 4 files changed, 67 insertions(+) create mode 100644 utils/ioda_example/CMakeLists.txt create mode 100644 utils/ioda_example/gdas_dumpioda.cc create mode 100644 utils/ioda_example/gdas_dumpioda.h diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index 4fc9a64a5..ed7e56e94 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -6,3 +6,4 @@ find_package(atlas REQUIRED) find_package(soca REQUIRED) add_subdirectory(soca) +add_subdirectory(ioda_example) diff --git a/utils/ioda_example/CMakeLists.txt b/utils/ioda_example/CMakeLists.txt new file mode 100644 index 000000000..5e957569f --- /dev/null +++ b/utils/ioda_example/CMakeLists.txt @@ -0,0 +1,6 @@ +ecbuild_add_executable( TARGET gdas_dumpioda.x + SOURCES gdas_dumpioda.cc ) + +target_compile_features( gdas_dumpioda.x PUBLIC cxx_std_17) +target_link_libraries( gdas_dumpioda.x PUBLIC oops ioda) + diff --git a/utils/ioda_example/gdas_dumpioda.cc b/utils/ioda_example/gdas_dumpioda.cc new file mode 100644 index 000000000..a505eeee9 --- /dev/null +++ b/utils/ioda_example/gdas_dumpioda.cc @@ -0,0 +1,12 @@ +#include "gdas_dumpioda.h" +#include "oops/runs/Run.h" + +// this is an example application that +// will use IODA to read a file and print something +// it is intended to be very bare bones + +int main(int argc, char ** argv) { + oops::Run run(argc, argv); + gdasapp::IodaExample iodaexample; + return run.execute(iodaexample); +} diff --git a/utils/ioda_example/gdas_dumpioda.h b/utils/ioda_example/gdas_dumpioda.h new file mode 100644 index 000000000..d5ff8b680 --- /dev/null +++ b/utils/ioda_example/gdas_dumpioda.h @@ -0,0 +1,48 @@ +#include +#include "eckit/config/LocalConfiguration.h" +#include "ioda/Group.h" +#include "ioda/ObsSpace.h" +#include "ioda/ObsVector.h" +#include "oops/base/PostProcessor.h" +#include "oops/mpi/mpi.h" +#include "oops/runs/Application.h" +#include "oops/util/DateTime.h" +#include "oops/util/Duration.h" +#include "oops/util/Logger.h" + +namespace gdasapp { + + class IodaExample : public oops::Application { + public: + explicit IodaExample(const eckit::mpi::Comm & comm = oops::mpi::world()) + : Application(comm) {} + static const std::string classname() {return "gdasapp::IodaExample";} + + int execute(const eckit::Configuration & fullConfig, bool /*validate*/) const { + + // get the obs space configuration + const eckit::LocalConfiguration obsConfig(fullConfig, "obs space"); + ioda::ObsTopLevelParameters obsparams; + obsparams.validateAndDeserialize(obsConfig); + oops::Log::info() << "obs space: " << std::endl << obsConfig << std::endl; + + // read the obs space + std::string winbegin; + std::string winend; + fullConfig.get("window begin", winbegin); + fullConfig.get("window end", winend); + ioda::ObsSpace ospace(obsparams, oops::mpi::world(), util::DateTime(winbegin), util::DateTime(winend), oops::mpi::myself()); + const size_t nlocs = ospace.nlocs(); + oops::Log::info() << "nlocs =" << nlocs << std::endl; + + return 0; + } + // ----------------------------------------------------------------------------- + private: + std::string appname() const { + return "gdasapp::IodaExample"; + } + // ----------------------------------------------------------------------------- + }; + +} // namespace gdasapp From 0741a92c9c6ad7ecd5523caaaf63db42d3393e49 Mon Sep 17 00:00:00 2001 From: CoryMartin-NOAA Date: Mon, 7 Aug 2023 14:40:42 -0400 Subject: [PATCH 03/15] Working example; need test now --- utils/ioda_example/gdas_dumpioda.h | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/utils/ioda_example/gdas_dumpioda.h b/utils/ioda_example/gdas_dumpioda.h index d5ff8b680..df80f9bab 100644 --- a/utils/ioda_example/gdas_dumpioda.h +++ b/utils/ioda_example/gdas_dumpioda.h @@ -25,15 +25,34 @@ namespace gdasapp { ioda::ObsTopLevelParameters obsparams; obsparams.validateAndDeserialize(obsConfig); oops::Log::info() << "obs space: " << std::endl << obsConfig << std::endl; - - // read the obs space + // time window stuff std::string winbegin; std::string winend; fullConfig.get("window begin", winbegin); fullConfig.get("window end", winend); + // what variable to get the mean of + std::string group; + std::string variable; + fullConfig.get("group", group); + fullConfig.get("variable", variable); + int chan = 0; + if (fullConfig.has("channel")) { + fullConfig.get("channel", chan); + } + // read the obs space ioda::ObsSpace ospace(obsparams, oops::mpi::world(), util::DateTime(winbegin), util::DateTime(winend), oops::mpi::myself()); const size_t nlocs = ospace.nlocs(); oops::Log::info() << "nlocs =" << nlocs << std::endl; + std::vector buffer(nlocs); + if (chan == 0) { + // no channel is selected + ospace.get_db(group, variable, buffer); + } else { + // give it the channel as a single item list + ospace.get_db(group, variable, buffer, {chan}); + } + const float mean = std::reduce(buffer.begin(), buffer.end()) / float(nlocs); + oops::Log::info() << "mean value for " << group << "/" << variable << "=" << mean << std::endl; return 0; } From ca3d01fdde60f21abef233fb062280bc72206dc2 Mon Sep 17 00:00:00 2001 From: Cory Martin Date: Mon, 7 Aug 2023 16:20:39 -0400 Subject: [PATCH 04/15] Some placeholders before debugging --- utils/CMakeLists.txt | 1 + utils/ioda_example/CMakeLists.txt | 8 ++++---- .../{gdas_dumpioda.cc => gdas_meanioda.cc} | 2 +- .../ioda_example/{gdas_dumpioda.h => gdas_meanioda.h} | 0 utils/test/CMakeLists.txt | 5 +++++ utils/test/testinput/gdas_meanioda.yaml | 11 +++++++++++ 6 files changed, 22 insertions(+), 5 deletions(-) rename utils/ioda_example/{gdas_dumpioda.cc => gdas_meanioda.cc} (91%) rename utils/ioda_example/{gdas_dumpioda.h => gdas_meanioda.h} (100%) create mode 100644 utils/test/CMakeLists.txt create mode 100644 utils/test/testinput/gdas_meanioda.yaml diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index ed7e56e94..8523a1845 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -7,3 +7,4 @@ find_package(soca REQUIRED) add_subdirectory(soca) add_subdirectory(ioda_example) +add_subdirectory(test) diff --git a/utils/ioda_example/CMakeLists.txt b/utils/ioda_example/CMakeLists.txt index 5e957569f..4ae18115f 100644 --- a/utils/ioda_example/CMakeLists.txt +++ b/utils/ioda_example/CMakeLists.txt @@ -1,6 +1,6 @@ -ecbuild_add_executable( TARGET gdas_dumpioda.x - SOURCES gdas_dumpioda.cc ) +ecbuild_add_executable( TARGET gdas_meanioda.x + SOURCES gdas_meanioda.cc ) -target_compile_features( gdas_dumpioda.x PUBLIC cxx_std_17) -target_link_libraries( gdas_dumpioda.x PUBLIC oops ioda) +target_compile_features( gdas_meanioda.x PUBLIC cxx_std_17) +target_link_libraries( gdas_meanioda.x PUBLIC oops ioda) diff --git a/utils/ioda_example/gdas_dumpioda.cc b/utils/ioda_example/gdas_meanioda.cc similarity index 91% rename from utils/ioda_example/gdas_dumpioda.cc rename to utils/ioda_example/gdas_meanioda.cc index a505eeee9..6fac6d2fb 100644 --- a/utils/ioda_example/gdas_dumpioda.cc +++ b/utils/ioda_example/gdas_meanioda.cc @@ -1,4 +1,4 @@ -#include "gdas_dumpioda.h" +#include "gdas_meanioda.h" #include "oops/runs/Run.h" // this is an example application that diff --git a/utils/ioda_example/gdas_dumpioda.h b/utils/ioda_example/gdas_meanioda.h similarity index 100% rename from utils/ioda_example/gdas_dumpioda.h rename to utils/ioda_example/gdas_meanioda.h diff --git a/utils/test/CMakeLists.txt b/utils/test/CMakeLists.txt new file mode 100644 index 000000000..6808b86fe --- /dev/null +++ b/utils/test/CMakeLists.txt @@ -0,0 +1,5 @@ +# Test example IODA utility that computes the mean of a variable +ecbuild_add_test( TARGET test_gdasapp_util_ioda_example + COMMAND ${CMAKE_BINARY_DIR}/bin/gdas_meanioda.x + ARGS "testinput/gdas_meanioda.yaml" + LIBS gdas-utils) \ No newline at end of file diff --git a/utils/test/testinput/gdas_meanioda.yaml b/utils/test/testinput/gdas_meanioda.yaml new file mode 100644 index 000000000..e7ece91bf --- /dev/null +++ b/utils/test/testinput/gdas_meanioda.yaml @@ -0,0 +1,11 @@ +window begin: 2020-11-01T09:00:00Z +window end: 2020-11-01T15:00:00Z +obs space: + name: amsua_n19 + obsdatain: + engine: + type: H5File + obsfile: Data/ufo/testinput_tier_1/instruments/radiance/amsua_n19_obs_2020110112_m.nc4 + simulated variables: [brightnessTemperature] + observed variables: [brightnessTemperature] + channel: 6 From dc9325970c2cbba82ac987d56dd98afe9bd92469 Mon Sep 17 00:00:00 2001 From: Cory Martin Date: Mon, 7 Aug 2023 16:23:33 -0400 Subject: [PATCH 05/15] Update gdas_meanioda.yaml --- utils/test/testinput/gdas_meanioda.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/utils/test/testinput/gdas_meanioda.yaml b/utils/test/testinput/gdas_meanioda.yaml index e7ece91bf..a904f2a86 100644 --- a/utils/test/testinput/gdas_meanioda.yaml +++ b/utils/test/testinput/gdas_meanioda.yaml @@ -8,4 +8,6 @@ obs space: obsfile: Data/ufo/testinput_tier_1/instruments/radiance/amsua_n19_obs_2020110112_m.nc4 simulated variables: [brightnessTemperature] observed variables: [brightnessTemperature] - channel: 6 +group: ObsValue +variable: brightnessTemperature +channel: 6 From e51dfad97131f01773212937a2f6ddc6912b07c0 Mon Sep 17 00:00:00 2001 From: Cory Martin Date: Mon, 7 Aug 2023 16:26:43 -0400 Subject: [PATCH 06/15] Hopefully will symlink the test YAML --- utils/test/CMakeLists.txt | 8 ++++++++ utils/test/testinput/gdas_meanioda.yaml | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/utils/test/CMakeLists.txt b/utils/test/CMakeLists.txt index 6808b86fe..9eb9d310e 100644 --- a/utils/test/CMakeLists.txt +++ b/utils/test/CMakeLists.txt @@ -1,3 +1,11 @@ +# Create Data directory for test input config and symlink all files +list( APPEND utils_test_input + testinput/gdas_meanioda.yaml +) + +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/testinput) +CREATE_SYMLINK( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${utils_test_input} ) + # Test example IODA utility that computes the mean of a variable ecbuild_add_test( TARGET test_gdasapp_util_ioda_example COMMAND ${CMAKE_BINARY_DIR}/bin/gdas_meanioda.x diff --git a/utils/test/testinput/gdas_meanioda.yaml b/utils/test/testinput/gdas_meanioda.yaml index a904f2a86..fc390d829 100644 --- a/utils/test/testinput/gdas_meanioda.yaml +++ b/utils/test/testinput/gdas_meanioda.yaml @@ -5,7 +5,7 @@ obs space: obsdatain: engine: type: H5File - obsfile: Data/ufo/testinput_tier_1/instruments/radiance/amsua_n19_obs_2020110112_m.nc4 + obsfile: ../../ufo-data/testinput_tier_1/instruments/radiance/amsua_n19_obs_2020110112_m.nc4 simulated variables: [brightnessTemperature] observed variables: [brightnessTemperature] group: ObsValue From 233fb7ae20b7a4bbcfec8fc9a6eefa1a14146f66 Mon Sep 17 00:00:00 2001 From: Cory Martin Date: Mon, 7 Aug 2023 16:44:03 -0400 Subject: [PATCH 07/15] Add some comments --- utils/ioda_example/gdas_meanioda.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/utils/ioda_example/gdas_meanioda.h b/utils/ioda_example/gdas_meanioda.h index df80f9bab..470113b8c 100644 --- a/utils/ioda_example/gdas_meanioda.h +++ b/utils/ioda_example/gdas_meanioda.h @@ -11,6 +11,12 @@ #include "oops/util/Logger.h" namespace gdasapp { + // this is an example of how one can use OOPS and IODA to do something + // in this code, we will read in configuration from YAML + // and then use that configuration to read in a IODA formatted file, + // read one group/variable (with optional channel) + // and compute and print out the mean of the variable. + // Nothing fancy, but you can see how this could be expanded! class IodaExample : public oops::Application { public: @@ -23,7 +29,7 @@ namespace gdasapp { // get the obs space configuration const eckit::LocalConfiguration obsConfig(fullConfig, "obs space"); ioda::ObsTopLevelParameters obsparams; - obsparams.validateAndDeserialize(obsConfig); + obsparams.validateAndDeserialize(obsConfig); // TODO CRM, can I remove this and then the simulated vars junk?? oops::Log::info() << "obs space: " << std::endl << obsConfig << std::endl; // time window stuff std::string winbegin; @@ -40,10 +46,13 @@ namespace gdasapp { fullConfig.get("channel", chan); } // read the obs space + // Note, the below line does a lot of heavy lifting + // we can probably go to a lower level function (and more of them) to accomplish the same thing ioda::ObsSpace ospace(obsparams, oops::mpi::world(), util::DateTime(winbegin), util::DateTime(winend), oops::mpi::myself()); const size_t nlocs = ospace.nlocs(); oops::Log::info() << "nlocs =" << nlocs << std::endl; std::vector buffer(nlocs); + // below is grabbing from the IODA obs space the specified group/variable and putting it into the buffer if (chan == 0) { // no channel is selected ospace.get_db(group, variable, buffer); @@ -51,9 +60,11 @@ namespace gdasapp { // give it the channel as a single item list ospace.get_db(group, variable, buffer, {chan}); } + // the below line computes the mean, aka sum divided by count const float mean = std::reduce(buffer.begin(), buffer.end()) / float(nlocs); + // write the mean out to the stdout oops::Log::info() << "mean value for " << group << "/" << variable << "=" << mean << std::endl; - + // a better program should return a real exit code depending on result, but this is just an example! return 0; } // ----------------------------------------------------------------------------- From 73a661b8b9095d4e2eb9d1df99f246d6b4c36da8 Mon Sep 17 00:00:00 2001 From: Cory Martin Date: Mon, 7 Aug 2023 17:05:36 -0400 Subject: [PATCH 08/15] A few more hopefully helpful comments --- utils/ioda_example/gdas_meanioda.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/utils/ioda_example/gdas_meanioda.cc b/utils/ioda_example/gdas_meanioda.cc index 6fac6d2fb..6e18ff5fa 100644 --- a/utils/ioda_example/gdas_meanioda.cc +++ b/utils/ioda_example/gdas_meanioda.cc @@ -4,6 +4,8 @@ // this is an example application that // will use IODA to read a file and print something // it is intended to be very bare bones +// you will note the .cc file is very empty +// the .h file is where the action is! int main(int argc, char ** argv) { oops::Run run(argc, argv); From 78a1aeb4bfe5115fe8ae3c76c2a89abe872d5c21 Mon Sep 17 00:00:00 2001 From: CoryMartin-NOAA Date: Tue, 8 Aug 2023 14:23:32 +0000 Subject: [PATCH 09/15] add working ctest --- utils/test/testinput/gdas_meanioda.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/test/testinput/gdas_meanioda.yaml b/utils/test/testinput/gdas_meanioda.yaml index fc390d829..46f3c1c30 100644 --- a/utils/test/testinput/gdas_meanioda.yaml +++ b/utils/test/testinput/gdas_meanioda.yaml @@ -5,7 +5,7 @@ obs space: obsdatain: engine: type: H5File - obsfile: ../../ufo-data/testinput_tier_1/instruments/radiance/amsua_n19_obs_2020110112_m.nc4 + obsfile: ../../../ufo-data/testinput_tier_1/instruments/radiance/amsua_n19_obs_2020110112_m.nc4 simulated variables: [brightnessTemperature] observed variables: [brightnessTemperature] group: ObsValue From 1c01706c68b9a7fca9f56687b93f8a5b22114bda Mon Sep 17 00:00:00 2001 From: CoryMartin-NOAA Date: Tue, 8 Aug 2023 15:35:25 +0000 Subject: [PATCH 10/15] Fix things oops --- utils/{ => soca}/gdas_incr_handler.cc | 0 utils/{ => soca}/gdas_incr_handler.h | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename utils/{ => soca}/gdas_incr_handler.cc (100%) rename utils/{ => soca}/gdas_incr_handler.h (100%) diff --git a/utils/gdas_incr_handler.cc b/utils/soca/gdas_incr_handler.cc similarity index 100% rename from utils/gdas_incr_handler.cc rename to utils/soca/gdas_incr_handler.cc diff --git a/utils/gdas_incr_handler.h b/utils/soca/gdas_incr_handler.h similarity index 100% rename from utils/gdas_incr_handler.h rename to utils/soca/gdas_incr_handler.h From 43bdcf912b67883c47ddff68595380d99f640274 Mon Sep 17 00:00:00 2001 From: CoryMartin-NOAA Date: Tue, 8 Aug 2023 15:36:57 +0000 Subject: [PATCH 11/15] more oopsies --- utils/{ => soca}/gdas_postprocincr.h | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename utils/{ => soca}/gdas_postprocincr.h (100%) diff --git a/utils/gdas_postprocincr.h b/utils/soca/gdas_postprocincr.h similarity index 100% rename from utils/gdas_postprocincr.h rename to utils/soca/gdas_postprocincr.h From 8bb6a361e73a27883e718a65f1e977bf99632224 Mon Sep 17 00:00:00 2001 From: CoryMartin-NOAA Date: Tue, 8 Aug 2023 15:39:59 +0000 Subject: [PATCH 12/15] ligne vide --- utils/ioda_example/gdas_meanioda.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/utils/ioda_example/gdas_meanioda.h b/utils/ioda_example/gdas_meanioda.h index 470113b8c..11aad1321 100644 --- a/utils/ioda_example/gdas_meanioda.h +++ b/utils/ioda_example/gdas_meanioda.h @@ -31,11 +31,13 @@ namespace gdasapp { ioda::ObsTopLevelParameters obsparams; obsparams.validateAndDeserialize(obsConfig); // TODO CRM, can I remove this and then the simulated vars junk?? oops::Log::info() << "obs space: " << std::endl << obsConfig << std::endl; + // time window stuff std::string winbegin; std::string winend; fullConfig.get("window begin", winbegin); fullConfig.get("window end", winend); + // what variable to get the mean of std::string group; std::string variable; @@ -45,6 +47,7 @@ namespace gdasapp { if (fullConfig.has("channel")) { fullConfig.get("channel", chan); } + // read the obs space // Note, the below line does a lot of heavy lifting // we can probably go to a lower level function (and more of them) to accomplish the same thing @@ -52,6 +55,7 @@ namespace gdasapp { const size_t nlocs = ospace.nlocs(); oops::Log::info() << "nlocs =" << nlocs << std::endl; std::vector buffer(nlocs); + // below is grabbing from the IODA obs space the specified group/variable and putting it into the buffer if (chan == 0) { // no channel is selected @@ -60,10 +64,13 @@ namespace gdasapp { // give it the channel as a single item list ospace.get_db(group, variable, buffer, {chan}); } + // the below line computes the mean, aka sum divided by count const float mean = std::reduce(buffer.begin(), buffer.end()) / float(nlocs); + // write the mean out to the stdout oops::Log::info() << "mean value for " << group << "/" << variable << "=" << mean << std::endl; + // a better program should return a real exit code depending on result, but this is just an example! return 0; } From 34aa28be115787547c075567eeadfc15f603fc71 Mon Sep 17 00:00:00 2001 From: CoryMartin-NOAA Date: Tue, 8 Aug 2023 20:17:29 +0000 Subject: [PATCH 13/15] force c++17 --- utils/CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index 8523a1845..beda28531 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -1,5 +1,15 @@ project(gdas-utils LANGUAGES C CXX ) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) +set(CMAKE_C_STANDARD 11) +set(CMAKE_C_STANDARD_REQUIRED ON) +set(CMAKE_C_EXTENSIONS OFF) +set(CMAKE_FORTRAN_STANDARD 08) +set(CMAKE_FORTRAN_STANDARD_REQUIRED ON) +set(CMAKE_FORTRAN_EXTENSIONS OFF) + find_package(NetCDF REQUIRED COMPONENTS CXX) find_package(oops REQUIRED) find_package(atlas REQUIRED) From f899e05fe89179d8de06f7c7a3bc5dbe3485a166 Mon Sep 17 00:00:00 2001 From: CoryMartin-NOAA Date: Wed, 9 Aug 2023 12:35:35 +0000 Subject: [PATCH 14/15] make hera compiler happy --- utils/ioda_example/gdas_meanioda.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utils/ioda_example/gdas_meanioda.h b/utils/ioda_example/gdas_meanioda.h index 11aad1321..95742c196 100644 --- a/utils/ioda_example/gdas_meanioda.h +++ b/utils/ioda_example/gdas_meanioda.h @@ -1,4 +1,5 @@ #include +#include #include "eckit/config/LocalConfiguration.h" #include "ioda/Group.h" #include "ioda/ObsSpace.h" @@ -66,7 +67,7 @@ namespace gdasapp { } // the below line computes the mean, aka sum divided by count - const float mean = std::reduce(buffer.begin(), buffer.end()) / float(nlocs); + const float mean = std::accumulate(buffer.begin(), buffer.end(), 0) / float(nlocs); // write the mean out to the stdout oops::Log::info() << "mean value for " << group << "/" << variable << "=" << mean << std::endl; From 55f1b6c281445f6e3603ddd902566fcc36541f5c Mon Sep 17 00:00:00 2001 From: CoryMartin-NOAA Date: Wed, 9 Aug 2023 17:39:01 +0000 Subject: [PATCH 15/15] use soca obs file --- utils/test/testinput/gdas_meanioda.yaml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/utils/test/testinput/gdas_meanioda.yaml b/utils/test/testinput/gdas_meanioda.yaml index 46f3c1c30..ff71b1870 100644 --- a/utils/test/testinput/gdas_meanioda.yaml +++ b/utils/test/testinput/gdas_meanioda.yaml @@ -1,13 +1,16 @@ -window begin: 2020-11-01T09:00:00Z -window end: 2020-11-01T15:00:00Z +# the window is 30 years long to capture anything we can throw at it in this input file +window begin: 2000-11-01T09:00:00Z +window end: 2030-11-01T15:00:00Z obs space: - name: amsua_n19 + name: gmi_gpm_test_mean obsdatain: engine: type: H5File - obsfile: ../../../ufo-data/testinput_tier_1/instruments/radiance/amsua_n19_obs_2020110112_m.nc4 + obsfile: ../../../soca/test/Data/obs/gmi_gpm_obs.nc + # the below 2 lines are not used but needed by the IODA obsspace it seems... simulated variables: [brightnessTemperature] observed variables: [brightnessTemperature] group: ObsValue variable: brightnessTemperature +# channel is optional, depends on what variable you are reading channel: 6