OOPS
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 ObsTableView & obsdb, const eckit::Configuration & conf,
23  std::shared_ptr<ObsData1D<int> > qcflags, std::shared_ptr<ObsData1D<float> > obserr)
24  : obsdb_(obsdb), qcflags_(qcflags), obserr_(obserr), novars_()
25 {
26  options_.deserialize(conf);
27 }
28 
29 // -----------------------------------------------------------------------------
30 void BackgroundCheck::postFilter(const ObsVec1D & hofx, const ObsDiags1D &) const {
31  std::vector<float> yobs;
32  obsdb_.getdb("ObsValue", yobs);
33  for (size_t jj = 0; jj < yobs.size(); ++jj) {
34  if (std::abs(yobs[jj] - hofx[jj]) > options_.threshold) {
35  // inflate obs error variance
36  if (options_.inflation.value() != boost::none) {
37  (*obserr_)[jj] *= *options_.inflation.value();
38  // or reject observation
39  } else {
40  (*qcflags_)[jj] = 1;
41  }
42  }
43  }
44 }
45 
46 // -----------------------------------------------------------------------------
47 void BackgroundCheck::print(std::ostream & os) const {
48  os << "L95 Background check with absolute threshold " << options_.threshold << std::endl;
49 }
50 
51 } // namespace lorenz95
52 
oops::FilterMaker
Definition: ObsFilterBase.h:80
oops::ObsFilter
Definition: ObsFilter.h:30
lorenz95::BackgroundCheckParameters::threshold
oops::RequiredParameter< double > threshold
threshold for background check
Definition: BackgroundCheck.h:36
lorenz95::ObsTableView::getdb
void getdb(const std::string &, std::vector< int > &) const
Definition: ObsTableView.cc:115
lorenz95::ObsVec1D
Vector in observation space.
Definition: ObsVec1D.h:34
BackgroundCheck.h
ObsFilter.h
lorenz95::BackgroundCheck::postFilter
void postFilter(const ObsVec1D &, const ObsDiags1D &) const
Definition: BackgroundCheck.cc:30
lorenz95::BackgroundCheck::BackgroundCheck
BackgroundCheck(const ObsTableView &, const eckit::Configuration &, std::shared_ptr< ObsData1D< int > >, std::shared_ptr< ObsData1D< float > >)
Definition: BackgroundCheck.cc:22
lorenz95::BackgroundCheck::obsdb_
const ObsTableView & obsdb_
Definition: BackgroundCheck.h:60
lorenz95::ObsDiags1D
Definition: ObsDiags1D.h:24
lorenz95::makerBackgroundCheck_
static oops::FilterMaker< L95ObsTraits, oops::ObsFilter< L95ObsTraits, BackgroundCheck > > makerBackgroundCheck_("Background Check")
lorenz95::ObsData1D
Data in observation space.
Definition: BackgroundCheck.h:24
L95Traits.h
lorenz95::ObsTableView
A Simple Observation Data Handler.
Definition: ObsTableView.h:38
lorenz95::BackgroundCheckParameters::inflation
oops::OptionalParameter< double > inflation
Definition: BackgroundCheck.h:41
lorenz95::BackgroundCheck::print
void print(std::ostream &os) const
Definition: BackgroundCheck.cc:47
lorenz95
The namespace for the L95 model.
Definition: l95/src/lorenz95/AnalyticInit.cc:17
lorenz95::BackgroundCheck::options_
BackgroundCheckParameters options_
Definition: BackgroundCheck.h:61