UFO
FinalCheck.cc
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2018-2019 UCAR
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 
9 
10 #include <string>
11 #include <utility>
12 #include <vector>
13 
14 #include "ioda/ObsSpace.h"
15 #include "oops/base/Variables.h"
16 #include "oops/util/Logger.h"
17 #include "oops/util/missingValues.h"
18 #include "ufo/filters/QCflags.h"
19 
20 namespace ufo {
21 
22 // -----------------------------------------------------------------------------
23 
24 FinalCheck::FinalCheck(ioda::ObsSpace & obsdb, const Parameters_ &,
25  std::shared_ptr<ioda::ObsDataVector<int>> qcflags,
26  std::shared_ptr<ioda::ObsDataVector<float>> obserr)
27  : ObsProcessorBase(obsdb, true /*deferToPost?*/, std::move(qcflags), std::move(obserr))
28 {
29  oops::Log::trace() << "FinalCheck constructed" << std::endl;
30 }
31 
32 // -----------------------------------------------------------------------------
33 
35  oops::Log::trace() << "FinalCheck destructed" << std::endl;
36 }
37 
38 // -----------------------------------------------------------------------------
39 
40 void FinalCheck::doFilter() const {
41  oops::Log::trace() << "FinalCheck doFilter starts" << std::endl;
42 
43  const oops::Variables &derived = obsdb_.derived_obsvariables();
44  for (size_t jv = 0; jv < derived.size(); ++jv) {
45  if (!obsdb_.has("ObsValue", derived[jv]))
46  throw eckit::UnexpectedState(
47  "All filters have been run, but the derived simulated variable " + derived[jv] +
48  " can't be found either in the ObsValue or the DerivedObsValue group", Here());
49  }
50 
51  // Set the QC flag to missing for any observations that haven't been rejected yet,
52  // but have missing error estimates.
53  const float missing = util::missingValue(missing);
54  for (size_t jv = 0; jv < obsdb_.obsvariables().size(); ++jv) {
55  for (size_t jobs = 0; jobs < obsdb_.nlocs(); ++jobs) {
56  if ((*flags_)[jv][jobs] == QCflags::pass && (*obserr_)[jv][jobs] == missing) {
57  (*flags_)[jv][jobs] = QCflags::missing;
58  }
59  }
60  }
61 
62  oops::Log::trace() << "FinalCheck doFilter done" << std::endl;
63 }
64 
65 // -----------------------------------------------------------------------------
66 
67 void FinalCheck::print(std::ostream & os) const {
68  os << "Final Check" << std::endl;
69 }
70 
71 // -----------------------------------------------------------------------------
72 
73 } // namespace ufo
void print(std::ostream &) const override
Definition: FinalCheck.cc:67
~FinalCheck() override
Definition: FinalCheck.cc:34
FinalCheck(ioda::ObsSpace &obsdb, const Parameters_ &params, std::shared_ptr< ioda::ObsDataVector< int >> qcflags, std::shared_ptr< ioda::ObsDataVector< float >> obserr)
Definition: FinalCheck.cc:24
void doFilter() const override
Definition: FinalCheck.cc:40
Base class for UFO observation processors (including QC filters).
std::shared_ptr< ioda::ObsDataVector< float > > obserr_
ioda::ObsSpace & obsdb_
std::shared_ptr< ioda::ObsDataVector< int > > flags_
constexpr int pass
Definition: QCflags.h:14
constexpr int missing
Definition: QCflags.h:20
Definition: RunCRTM.h:27