UFO
PerformAction.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2021 Met Office UK
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_PERFORMACTION_H_
9 #define UFO_FILTERS_PERFORMACTION_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/Parameters.h"
18 #include "oops/util/parameters/RequiredParameter.h"
19 #include "oops/util/parameters/RequiredPolymorphicParameter.h"
20 #include "ufo/filters/FilterBase.h"
21 #include "ufo/filters/QCflags.h"
22 
23 namespace eckit {
24  class Configuration;
25 }
26 
27 namespace ioda {
28  template <typename DATATYPE> class ObsDataVector;
29  class ObsSpace;
30 }
31 
32 namespace ufo {
33 
34 /// \brief Parameters controlling the action performed on observations flagged by a filter.
35 ///
36 /// The action must be specified explicitly (there is no default action).
37 class RequiredFilterActionParameters : public oops::Parameters {
38  OOPS_CONCRETE_PARAMETERS(RequiredFilterActionParameters, Parameters)
39 
40  public:
41  /// After deserialization, holds an instance of a subclass of FilterActionParametersBase
42  /// controlling the behavior of a filter action. The type of the subclass is determined
43  /// by the value of the `name` key in the Configuration object from which this object
44  /// is deserialized.
45  oops::RequiredPolymorphicParameter<FilterActionParametersBase, FilterActionFactory>
46  actionParameters{"name", this};
47 };
48 
49 /// \brief Parameters controlling the Perform Action filter.
52 
53  public:
54  /// Parameters controlling the action performed on observations flagged by the filter.
55  const FilterActionParametersBase &action() const override {
56  return action_.value().actionParameters.value();
57  }
58 
59  private:
60  /// Parameters controlling the action performed on observations flagged by the filter.
61  oops::RequiredParameter<RequiredFilterActionParameters> action_{"action", this};
62 };
63 
64 /// \brief Perform the action specified in the `action` YAML section on each observation selected by
65 /// the `where` statement.
66 ///
67 /// In contrast to other filters, this filter requires the action to be specified explicitly in the
68 /// YAML file; there is no default action.
69 class PerformAction : public FilterBase,
70  private util::ObjectCounter<PerformAction> {
71  public:
72  /// The type of parameters accepted by the constructor of this filter.
73  /// This typedef is used by the FilterFactory.
75 
76  static const std::string classname() {return "ufo::PerformAction";}
77 
78  PerformAction(ioda::ObsSpace &, const Parameters_ &,
79  std::shared_ptr<ioda::ObsDataVector<int> >,
80  std::shared_ptr<ioda::ObsDataVector<float> >);
81 
82  private:
83  void print(std::ostream &) const override;
84  void applyFilter(const std::vector<bool> &, const Variables &,
85  std::vector<std::vector<bool>> &) const override;
86  int qcFlag() const override {return QCflags::black;}
87 
89 };
90 
91 } // namespace ufo
92 
93 #endif // UFO_FILTERS_PERFORMACTION_H_
Parameters controlling a filter action.
Base class for UFO QC filters.
Definition: FilterBase.h:45
Parameters shared by all filters derived from FilterBase.
Perform the action specified in the action YAML section on each observation selected by the where sta...
Definition: PerformAction.h:70
PerformActionParameters Parameters_
Definition: PerformAction.h:74
Parameters_ parameters_
Definition: PerformAction.h:88
static const std::string classname()
Definition: PerformAction.h:76
void applyFilter(const std::vector< bool > &, const Variables &, std::vector< std::vector< bool >> &) const override
int qcFlag() const override
Definition: PerformAction.h:86
void print(std::ostream &) const override
PerformAction(ioda::ObsSpace &, const Parameters_ &, std::shared_ptr< ioda::ObsDataVector< int > >, std::shared_ptr< ioda::ObsDataVector< float > >)
Parameters controlling the Perform Action filter.
Definition: PerformAction.h:50
oops::RequiredParameter< RequiredFilterActionParameters > action_
Parameters controlling the action performed on observations flagged by the filter.
Definition: PerformAction.h:61
const FilterActionParametersBase & action() const override
Parameters controlling the action performed on observations flagged by the filter.
Definition: PerformAction.h:55
Parameters controlling the action performed on observations flagged by a filter.
Definition: PerformAction.h:37
oops::RequiredPolymorphicParameter< FilterActionParametersBase, FilterActionFactory > actionParameters
Definition: PerformAction.h:46
Forward declarations.
Definition: ObsAodExt.h:21
Forward declarations.
Definition: ObsAodExt.h:25
constexpr int black
Definition: QCflags.h:24
Definition: RunCRTM.h:27