IODA Bundle
BackgroundCheck.cc
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2020-2020 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 <vector>
11 
12 #include "lorenz95/L95Traits.h"
14 
15 // -----------------------------------------------------------------------------
16 namespace lorenz95 {
17 // -----------------------------------------------------------------------------
18 static oops::FilterMaker<L95ObsTraits,
20 
21 // -----------------------------------------------------------------------------
22 BackgroundCheck::BackgroundCheck(const ObsTable & obsdb, const Parameters_ & parameters,
23  std::shared_ptr<ObsData1D<int> > qcflags, std::shared_ptr<ObsData1D<float> > obserr)
24  : obsdb_(obsdb), options_(parameters), qcflags_(qcflags), obserr_(obserr), novars_()
25 {
26 }
27 
28 // -----------------------------------------------------------------------------
29 void BackgroundCheck::postFilter(const ObsVec1D & hofx, const ObsDiags1D &) const {
30  std::vector<float> yobs;
31  obsdb_.getdb("ObsValue", yobs);
32  size_t inflate = 0;
33  size_t ireject = 0;
34  for (size_t jj = 0; jj < yobs.size(); ++jj) {
35  if (std::abs(yobs[jj] - hofx[jj]) > options_.threshold) {
36  // inflate obs error variance
37  if (options_.inflation.value() != boost::none) {
38  (*obserr_)[jj] *= *options_.inflation.value();
39  ++inflate;
40  // or reject observation
41  } else {
42  (*qcflags_)[jj] = 1;
43  ++ireject;
44  }
45  }
46  }
47  oops::Log::info() << "BackgroundCheck::postFilter rejected = " << ireject
48  << ", inflated = " << inflate << std::endl;
49 }
50 
51 // -----------------------------------------------------------------------------
52 void BackgroundCheck::print(std::ostream & os) const {
53  os << "L95 Background check with absolute threshold " << options_.threshold;
54 }
55 
56 } // namespace lorenz95
57 
void print(std::ostream &os) const
BackgroundCheck(const ObsTable &, const Parameters_ &, std::shared_ptr< ObsData1D< int > >, std::shared_ptr< ObsData1D< float > >)
void postFilter(const ObsVec1D &, const ObsDiags1D &) const
oops::RequiredParameter< double > threshold
threshold for background check
oops::OptionalParameter< double > inflation
Data in observation space.
Definition: ObsData1D.h:35
A Simple Observation Data Handler.
Definition: ObsTable.h:41
void getdb(const std::string &, std::vector< int > &) const
Definition: ObsTable.cc:131
Vector in observation space.
Definition: ObsVec1D.h:33
The namespace for the L95 model.
static oops::FilterMaker< L95ObsTraits, oops::ObsFilter< L95ObsTraits, BackgroundCheck > > makerBackgroundCheck_("Background Check")