Skip to content

Commit

Permalink
ligne vide
Browse files Browse the repository at this point in the history
  • Loading branch information
CoryMartin-NOAA committed Aug 8, 2023
1 parent 43bdcf9 commit 8bb6a36
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions utils/ioda_example/gdas_meanioda.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -45,13 +47,15 @@ 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
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<float> 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
Expand All @@ -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;
}
Expand Down

0 comments on commit 8bb6a36

Please sign in to comment.