FV3 Bundle
ObsFilter.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 OOPS_BASE_OBSFILTER_H_
9 #define OOPS_BASE_OBSFILTER_H_
10 
11 #include <vector>
12 
13 #include <boost/shared_ptr.hpp>
14 
15 #include "oops/base/FilterBase.h"
16 #include "oops/interface/GeoVaLs.h"
19 #include "oops/util/Printable.h"
20 
21 namespace oops {
22 
23 /// Controls application of QC filters to observations
24 
25 // -----------------------------------------------------------------------------
26 
27 template<typename MODEL>
28 class ObsFilter : public util::Printable {
33 
34  public:
35  ObsFilter() : filters_(0) {}
36  ObsFilter(const ObsFilter & pp): filters_(pp.filters_) {}
38 
39  void enrollFilter(FilterBase_ *);
40  void enrollFilter(boost::shared_ptr<FilterBase_>);
41 
42  void postFilter(const GeoVaLs_ &, const ObsVector_ &, const ObsSpace_ &) const;
43 
44  private:
45  void print(std::ostream &) const;
46  std::vector< boost::shared_ptr<FilterBase_> > filters_;
48 };
49 
50 // -----------------------------------------------------------------------------
51 
52 template<typename MODEL>
54  if (pp != 0) {
55  boost::shared_ptr<FilterBase_> sp(pp);
56  filters_.push_back(sp);
57  }
58 }
59 
60 // -----------------------------------------------------------------------------
61 
62 template<typename MODEL>
63 void ObsFilter<MODEL>::enrollFilter(boost::shared_ptr<FilterBase_> pp) {
64  if (pp != 0) filters_.push_back(pp);
65 }
66 
67 // -----------------------------------------------------------------------------
68 
69 template<typename MODEL>
70 void ObsFilter<MODEL>::postFilter(const GeoVaLs_ & gv, const ObsVector_ & ovec,
71  const ObsSpace_ & obsdb) const {
72  for (std::size_t jf = 0; jf < filters_.size(); ++jf) {
73  filters_.at(jf)->postFilter(gv, ovec, obsdb);
74  }
75 }
76 
77 // -----------------------------------------------------------------------------
78 
79 template <typename MODEL>
80 void ObsFilter<MODEL>::print(std::ostream & os) const {
81  os << "ObsFilter " << filters_.size() << " filters:" << std::endl;
82  for (std::size_t jj = 0; jj < filters_.size(); ++jj) {
83  os << *filters_[jj] << std::endl;
84  }
85 }
86 
87 // -----------------------------------------------------------------------------
88 
89 } // namespace oops
90 
91 #endif // OOPS_BASE_OBSFILTER_H_
Base class for QC filters applied to observations.
Definition: FilterBase.h:29
real(r8), dimension(cast_m, cast_n) sp
GeoVaLs< MODEL > GeoVaLs_
Definition: ObsFilter.h:30
ObsFilter operator=(const ObsFilter &)
ObservationSpace< MODEL > ObsSpace_
Definition: ObsFilter.h:31
FilterBase< MODEL > FilterBase_
Definition: ObsFilter.h:29
The namespace for the main oops code.
void postFilter(const GeoVaLs_ &, const ObsVector_ &, const ObsSpace_ &) const
Definition: ObsFilter.h:70
ObsVector< MODEL > ObsVector_
Definition: ObsFilter.h:32
std::vector< boost::shared_ptr< FilterBase_ > > filters_
Definition: ObsFilter.h:46
void enrollFilter(FilterBase_ *)
Definition: ObsFilter.h:53
ObsFilter(const ObsFilter &pp)
Definition: ObsFilter.h:36
void print(std::ostream &) const
Definition: ObsFilter.h:80
Controls application of QC filters to observations.
Definition: ObsFilter.h:28