UFO
BackgroundCheck.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2017-2018 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 
8 #ifndef UFO_FILTERS_BACKGROUNDCHECK_H_
9 #define UFO_FILTERS_BACKGROUNDCHECK_H_
10 
11 #include <memory>
12 #include <ostream>
13 #include <string>
14 #include <vector>
15 
16 #include "oops/util/ObjectCounter.h"
17 #include "oops/util/parameters/OptionalParameter.h"
18 #include "oops/util/Printable.h"
19 #include "ufo/filters/FilterBase.h"
20 #include "ufo/filters/QCflags.h"
21 #include "ufo/filters/Variable.h"
23 
24 namespace eckit {
25  class Configuration;
26 }
27 
28 namespace ioda {
29  template <typename DATATYPE> class ObsDataVector;
30  class ObsSpace;
31 }
32 
33 namespace ufo {
34 
35 /// Parameters controlling the operation of the BackgroundCheck filter.
37  OOPS_CONCRETE_PARAMETERS(BackgroundCheckParameters, FilterParametersBase)
38 
39  public:
40  /// The filter will flag observations whose bias-corrected value differs from its model equivalent
41  /// by more than `threshold` times the current estimate of the observation error. Or if the
42  /// option "threshold wrt background error" is true, the `threshold` is multiplied by the
43  /// background error rather than observation error. E.g.
44  ///
45  /// filter variables:
46  /// - name: sea_surface_height
47  /// threshold wrt background error: true
48  /// threshold: 3.0
49  ///
50  /// `threshold` can be a real number or the name of a variable.
51  oops::OptionalParameter<std::string> threshold{"threshold", this};
52 
53  /// A switch indicating whether threshold must be multiplied by background error rather than
54  /// observation error. If true, `threshold` must have a value.
55  oops::Parameter<bool> thresholdWrtBGerror{"threshold wrt background error", false, this};
56 
57  /// The filter will flag observations whose bias-corrected value differs from its model equivalent
58  /// by more than `absolute threshold`
59  ///
60  /// `absolute threshold` can be a real number or the name of a variable.
61  oops::OptionalParameter<std::string> absoluteThreshold{"absolute threshold", this};
62 
63  /// The filter will flag observations whose bias-corrected value differs from its model equivalent
64  /// by more than `function absolute threshold`
65  ///
66  /// `function absolute threshold` should be a list of ObsFunctions (but only the first element
67  /// of this list is currently taken into account). The ObsFunctions may return multiple values
68  /// per observation, which is especially useful for quality checking data with multiple channels.
69  ///
70  /// If `function absolute threshold` is set, neither `threshold` nor `absolute threshold` should
71  /// be set.
72  oops::OptionalParameter<std::vector<Variable>> functionAbsoluteThreshold{
73  "function absolute threshold", this};
74 
75  /// The filter uses bias-corrected H(x) unless `remove bias correction` is set to true.
76  oops::Parameter<bool> removeBiasCorrection{"remove bias correction", false, this};
77 
78  /// Name of the HofX group used to replace the default group (default is HofX)
79  oops::Parameter<std::string> test_hofx{"test_hofx", "HofX", this};
80 };
81 
82 /// BackgroundCheck: check observation closeness to background.
83 ///
84 /// See BackgroundCheckParameters for the documentation of the parameters controlling this filter.
85 class BackgroundCheck : public FilterBase,
86  private util::ObjectCounter<BackgroundCheck> {
87  public:
88  /// The type of parameters accepted by the constructor of this filter.
89  /// This typedef is used by the FilterFactory.
91 
92  static const std::string classname() {return "ufo::BackgroundCheck";}
93 
94  BackgroundCheck(ioda::ObsSpace &, const Parameters_ &,
95  std::shared_ptr<ioda::ObsDataVector<int> >,
96  std::shared_ptr<ioda::ObsDataVector<float> >);
98 
99  private:
100  void print(std::ostream &) const override;
101  void applyFilter(const std::vector<bool> &, const Variables &,
102  std::vector<std::vector<bool>> &) const override;
103  int qcFlag() const override {return QCflags::fguess;}
104  /// \brief Return the name of the variable containing the background error estimate of the
105  /// specified filter variable.
106  Variable backgrErrVariable(const Variable & filterVariable) const;
107 
109 };
110 
111 } // namespace ufo
112 
113 #endif // UFO_FILTERS_BACKGROUNDCHECK_H_
void applyFilter(const std::vector< bool > &, const Variables &, std::vector< std::vector< bool >> &) const override
Variable backgrErrVariable(const Variable &filterVariable) const
Return the name of the variable containing the background error estimate of the specified filter vari...
BackgroundCheck(ioda::ObsSpace &, const Parameters_ &, std::shared_ptr< ioda::ObsDataVector< int > >, std::shared_ptr< ioda::ObsDataVector< float > >)
void print(std::ostream &) const override
BackgroundCheckParameters Parameters_
static const std::string classname()
int qcFlag() const override
Parameters controlling the operation of the BackgroundCheck filter.
oops::OptionalParameter< std::string > absoluteThreshold
oops::Parameter< std::string > test_hofx
Name of the HofX group used to replace the default group (default is HofX)
oops::Parameter< bool > removeBiasCorrection
The filter uses bias-corrected H(x) unless remove bias correction is set to true.
oops::OptionalParameter< std::string > threshold
oops::Parameter< bool > thresholdWrtBGerror
oops::OptionalParameter< std::vector< Variable > > functionAbsoluteThreshold
Base class for UFO QC filters.
Definition: FilterBase.h:45
Parameters shared by all filters having a default action (typically "reject").
Forward declarations.
Definition: ObsAodExt.h:21
Forward declarations.
Definition: ObsAodExt.h:25
constexpr int fguess
Definition: QCflags.h:29
Definition: RunCRTM.h:27