Skip to content

Commit

Permalink
Working example; need test now
Browse files Browse the repository at this point in the history
  • Loading branch information
CoryMartin-NOAA committed Aug 7, 2023
1 parent 072b63d commit 0741a92
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions utils/ioda_example/gdas_dumpioda.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<float> 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;
}
Expand Down

0 comments on commit 0741a92

Please sign in to comment.