UFO
DifferenceCheck.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 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 
8 #ifndef UFO_FILTERS_DIFFERENCECHECK_H_
9 #define UFO_FILTERS_DIFFERENCECHECK_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/parameters/RequiredParameter.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 DifferenceCheck filter.
37  OOPS_CONCRETE_PARAMETERS(DifferenceCheckParameters, FilterParametersBase)
38 
39  public:
40  /// Name of the reference variable.
41  oops::RequiredParameter<Variable> ref{"reference", this};
42  /// Name of the test variable.
43  oops::RequiredParameter<Variable> val{"value", this};
44 
45  /// The filter will flag observations for which the difference `test - reference` is below
46  /// `minvalue`.
47  oops::OptionalParameter<float> minvalue{"minvalue", this};
48  /// The filter will flag observations for which the difference `test - reference` is above
49  /// `maxvalue`.
50  oops::OptionalParameter<float> maxvalue{"maxvalue", this};
51 
52  /// If the `threshold` option is specified, the filter behaves as if `minvalue` was set to
53  /// `-threshold` and `maxvalue` was set to `threshold` (overriding any values of these options
54  /// specified independently).
55  oops::OptionalParameter<float> threshold{"threshold", this};
56 };
57 
58 /// A filter that compares the difference between a test variable and a reference variable and
59 /// flags observations for which this difference is outside of a prescribed range.
60 ///
61 /// See DifferenceCheckParameters for the documentation of the parameters controlling this filter.
62 class DifferenceCheck : public FilterBase,
63  private util::ObjectCounter<DifferenceCheck> {
64  public:
65  /// The type of parameters accepted by the constructor of this filter.
66  /// This typedef is used by the FilterFactory.
68 
69  static const std::string classname() {return "ufo::DifferenceCheck";}
70 
71  DifferenceCheck(ioda::ObsSpace &, const Parameters_ &,
72  std::shared_ptr<ioda::ObsDataVector<int> >,
73  std::shared_ptr<ioda::ObsDataVector<float> >);
75 
76  private:
77  void print(std::ostream &) const override;
78  void applyFilter(const std::vector<bool> &, const Variables &,
79  std::vector<std::vector<bool>> &) const override;
80  int qcFlag() const override {return QCflags::diffref;}
81 
83 };
84 
85 } // namespace ufo
86 
87 #endif // UFO_FILTERS_DIFFERENCECHECK_H_
void print(std::ostream &) const override
DifferenceCheck(ioda::ObsSpace &, const Parameters_ &, std::shared_ptr< ioda::ObsDataVector< int > >, std::shared_ptr< ioda::ObsDataVector< float > >)
int qcFlag() const override
static const std::string classname()
DifferenceCheckParameters Parameters_
void applyFilter(const std::vector< bool > &, const Variables &, std::vector< std::vector< bool >> &) const override
Parameters controlling the operation of the DifferenceCheck filter.
oops::RequiredParameter< Variable > ref
Name of the reference variable.
oops::OptionalParameter< float > maxvalue
oops::RequiredParameter< Variable > val
Name of the test variable.
oops::OptionalParameter< float > minvalue
oops::OptionalParameter< float > threshold
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 diffref
Definition: QCflags.h:27
Definition: RunCRTM.h:27