UFO
Thinning.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_THINNING_H_
9 #define UFO_FILTERS_THINNING_H_
10 
11 #include <memory>
12 #include <ostream>
13 #include <string>
14 #include <vector>
15 
16 #include "ioda/ObsDataVector.h"
17 #include "oops/util/ObjectCounter.h"
18 #include "oops/util/parameters/OptionalParameter.h"
19 #include "oops/util/parameters/Parameter.h"
20 #include "oops/util/parameters/RequiredParameter.h"
21 #include "ufo/filters/FilterBase.h"
22 #include "ufo/filters/QCflags.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 Thinning filter.
37  OOPS_CONCRETE_PARAMETERS(ThinningParameters, FilterParametersBase)
38 
39  public:
40  /// (Approximate) fraction of observations to be thinned.
41  oops::RequiredParameter<float> amount{"amount", this};
42 
43  /// Seed used to initialize the random number generator (if it has not been initialized
44  /// before). If not set, the seed is derived from the calendar time.
45  oops::OptionalParameter<int> randomSeed{"random seed", this};
46 
47  /// Index of the ensemble member.
48  oops::Parameter<int> member{"member", 0, this};
49 };
50 
51 /// \brief Randomly thin a given percentage of observations.
52 ///
53 /// See ThinningParameters for the documentation of the parameters controlling this filter.
54 
55 class Thinning : public FilterBase,
56  private util::ObjectCounter<Thinning> {
57  public:
58  /// The type of parameters accepted by the constructor of this filter.
59  /// This typedef is used by the FilterFactory.
61 
62  static const std::string classname() {return "ufo::Thinning";}
63 
64  Thinning(ioda::ObsSpace &, const Parameters_ &,
65  std::shared_ptr<ioda::ObsDataVector<int> >,
66  std::shared_ptr<ioda::ObsDataVector<float> >);
67  ~Thinning();
68 
69  private:
70  void print(std::ostream &) const override;
71  void applyFilter(const std::vector<bool> &, const Variables &,
72  std::vector<std::vector<bool>> &) const override;
73  int qcFlag() const override {return QCflags::thinned;}
74 
76 };
77 
78 } // namespace ufo
79 
80 #endif // UFO_FILTERS_THINNING_H_
Base class for UFO QC filters.
Definition: FilterBase.h:45
Parameters shared by all filters having a default action (typically "reject").
Randomly thin a given percentage of observations.
Definition: Thinning.h:56
static const std::string classname()
Definition: Thinning.h:62
void applyFilter(const std::vector< bool > &, const Variables &, std::vector< std::vector< bool >> &) const override
Definition: Thinning.cc:39
ThinningParameters Parameters_
Definition: Thinning.h:60
Parameters_ parameters_
Definition: Thinning.h:75
void print(std::ostream &) const override
Definition: Thinning.cc:66
int qcFlag() const override
Definition: Thinning.h:73
Thinning(ioda::ObsSpace &, const Parameters_ &, std::shared_ptr< ioda::ObsDataVector< int > >, std::shared_ptr< ioda::ObsDataVector< float > >)
Definition: Thinning.cc:25
Parameters controlling the operation of the Thinning filter.
Definition: Thinning.h:36
oops::Parameter< int > member
Index of the ensemble member.
Definition: Thinning.h:48
oops::OptionalParameter< int > randomSeed
Definition: Thinning.h:45
oops::RequiredParameter< float > amount
(Approximate) fraction of observations to be thinned.
Definition: Thinning.h:41
Forward declarations.
Definition: ObsAodExt.h:21
Forward declarations.
Definition: ObsAodExt.h:25
constexpr int thinned
Definition: QCflags.h:26
Definition: RunCRTM.h:27