UFO
ModelObThreshold.h
Go to the documentation of this file.
1 /* -----------------------------------------------------------------------------
2  * (C) British Crown Copyright 2021 Met Office
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_MODELOBTHRESHOLD_H_
9 #define UFO_FILTERS_MODELOBTHRESHOLD_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 
20 #include "ufo/filters/FilterBase.h"
21 #include "ufo/filters/QCflags.h"
22 #include "ufo/filters/Variable.h"
24 
25 namespace eckit {
26  class Configuration;
27 }
28 
29 namespace ioda {
30  template <typename DATATYPE> class ObsDataVector;
31  class ObsSpace;
32 }
33 
34 namespace ufo {
35 
36 enum class ThresholdType {
37  MIN, MAX
38 };
39 
42  static constexpr char enumTypeName[] = "ThresholdType";
43  static constexpr util::NamedEnumerator<ThresholdType> namedValues[] = {
44  { ThresholdType::MIN, "min" },
45  { ThresholdType::MAX, "max" }
46  };
47 };
48 
49 } // namespace ufo
50 
51 namespace oops {
52 
53 template <>
54 struct ParameterTraits<ufo::ThresholdType> :
55  public EnumParameterTraits<ufo::ThresholdTypeParameterTraitsHelper>
56 {};
57 
58 } // namespace oops
59 
60 namespace ufo {
61 
62 /// \brief Parameters controlling the operation of the ModelObThreshold filter.
64  OOPS_CONCRETE_PARAMETERS(ModelObThresholdParameters, FilterParametersBase)
65 
66  public:
67  /// Name of the model profile variable (GeoVaLs)
68  oops::RequiredParameter<Variable> model_profile{"model profile", this};
69  /// Name of the model vertical coordinate variable (GeoVal)
70  oops::RequiredParameter<Variable> model_vcoord{"model vertical coordinate", this};
71  /// Name of the observation height variable to interpolate to
72  oops::RequiredParameter<Variable> obs_height{"observation height", this};
73  /// Vector of threshold values
74  oops::RequiredParameter<std::vector<double>> thresholds{"thresholds", this};
75  /// Vector of vertical coordinates corresponding to vector of thresholds
76  oops::RequiredParameter<std::vector<double>> coord_vals{"coordinate values", this};
77  /// Threshold type: min or max
78  oops::RequiredParameter<ThresholdType> threshold_type{"threshold type", this};
79 };
80 
81 // -----------------------------------------------------------------------------
82 
83 /// \brief A filter that interpolates a model profile (GeoVaL) and a height-dependent
84 /// threshold to the observation location and flags observations which are outside the
85 /// specified limit.
86 ///
87 /// See ModelObThresholdParameters for the documentation of the parameters controlling this filter.
89  private util::ObjectCounter<ModelObThreshold> {
90  public:
91  /// The type of parameters accepted by the constructor of this filter.
92  /// This typedef is used by the FilterFactory.
94 
95  static const std::string classname() {return "ufo::ModelObThreshold";}
96 
97  ModelObThreshold(ioda::ObsSpace &, const Parameters_ &,
98  std::shared_ptr<ioda::ObsDataVector<int> >,
99  std::shared_ptr<ioda::ObsDataVector<float> >);
101 
102  private:
103  void print(std::ostream &) const override;
104  void applyFilter(const std::vector<bool> &, const Variables &,
105  std::vector<std::vector<bool>> &) const override;
106  int qcFlag() const override {return QCflags::modelobthresh;}
107 
109 };
110 
111 } // namespace ufo
112 
113 #endif // UFO_FILTERS_MODELOBTHRESHOLD_H_
Base class for UFO QC filters.
Definition: FilterBase.h:45
Parameters shared by all filters having a default action (typically "reject").
A filter that interpolates a model profile (GeoVaL) and a height-dependent threshold to the observati...
ModelObThresholdParameters Parameters_
static const std::string classname()
void print(std::ostream &) const override
int qcFlag() const override
ModelObThreshold(ioda::ObsSpace &, const Parameters_ &, std::shared_ptr< ioda::ObsDataVector< int > >, std::shared_ptr< ioda::ObsDataVector< float > >)
void applyFilter(const std::vector< bool > &, const Variables &, std::vector< std::vector< bool >> &) const override
Filter to apply a threshold to a model profile interpolated to the observation height.
Parameters controlling the operation of the ModelObThreshold filter.
oops::RequiredParameter< Variable > obs_height
Name of the observation height variable to interpolate to.
oops::RequiredParameter< std::vector< double > > thresholds
Vector of threshold values.
oops::RequiredParameter< ThresholdType > threshold_type
Threshold type: min or max.
oops::RequiredParameter< Variable > model_vcoord
Name of the model vertical coordinate variable (GeoVal)
oops::RequiredParameter< std::vector< double > > coord_vals
Vector of vertical coordinates corresponding to vector of thresholds.
oops::RequiredParameter< Variable > model_profile
Name of the model profile variable (GeoVaLs)
Forward declarations.
Definition: ObsAodExt.h:21
Forward declarations.
Definition: ObsAodExt.h:25
constexpr int modelobthresh
Definition: QCflags.h:37
Definition: RunCRTM.h:27
static constexpr util::NamedEnumerator< ThresholdType > namedValues[]