UFO
EntireSampleDataHandler.cc
Go to the documentation of this file.
1 /*
2  * (C) Crown copyright 2020, Met Office
3  *
4  * This software is licensed under the terms of the Apache Licence Version 2.0
5  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6  */
7 
8 #include <algorithm>
9 
12 
13 namespace ufo {
15  const DataHandlerParameters &options)
16  : obsdb_(obsdb),
17  options_(options)
18  {}
19 
21  {
22  // Write out all variables in particular groups.
23  for (const auto& it_data : entireSampleData_) {
24  std::string fullname = it_data.first;
25  std::string varname;
26  std::string groupname;
27  ufo::splitVarGroup(fullname, varname, groupname);
28 
29  if (groupname == "QCFlags") {
30  putDataVector(fullname, get<int>(fullname));
31  } else if (groupname == "Corrections" ||
32  groupname == "DerivedValue") {
33  // todo(ctgh): Add ModelLevelsDerivedValue, ModelRhoLevelsDerivedValue,
34  // ModelLevelsFlags and ModelRhoLevelsFlags to this list when
35  // it is possible to save variables with different nlocs.
36  putDataVector(fullname, get<float>(fullname));
37  }
38  }
39 
40  // Write out the NumAnyErrors counter, which is used in multiple QC checks.
41  const std::vector <int> &NumAnyErrors =
44  }
45 
46  int EntireSampleDataHandler::defaultValue(const std::vector <int> &vec,
47  const std::string &groupname)
48  {
49  if (groupname == "Counters")
50  return 0;
51  else
52  return missingValueInt;
53  }
54 
55  float EntireSampleDataHandler::defaultValue(const std::vector <float> &vec,
56  const std::string &groupname)
57  {
58  if (groupname == "Corrections")
59  return 0.0f;
60  else
61  return missingValueFloat;
62  }
63 
64  std::string EntireSampleDataHandler::defaultValue(const std::vector <std::string> &vec,
65  const std::string &groupname)
66  {
67  return missingValueString;
68  }
69 } // namespace ufo
Options controlling the operation of the EntireSampleDataHandler and ProfileDataHandler classes.
void putDataVector(const std::string &fullname, const std::vector< T > &datavec)
Put entire data vector on obsdb.
std::unordered_map< std::string, boost::variant< std::vector< int >, std::vector< float >, std::vector< std::string > > > entireSampleData_
Container of each variable in the entire data set.
EntireSampleDataHandler(ioda::ObsSpace &obsdb, const DataHandlerParameters &options)
const float missingValueFloat
Missing value (float)
int defaultValue(const std::vector< int > &vec, const std::string &groupname)
Default value used to fill vector of integers.
const std::string missingValueString
Missing value (string)
const int missingValueInt
Missing value (int)
Definition: RunCRTM.h:27
void splitVarGroup(const std::string &vargrp, std::string &var, std::string &grp)
Definition: StringUtils.cc:27
static constexpr const char *const counter_NumAnyErrors