IODA Bundle
oops/interface/LinearObsOperator.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2009-2016 ECMWF.
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  * In applying this licence, ECMWF does not waive the privileges and immunities
7  * granted to it by virtue of its status as an intergovernmental organisation nor
8  * does it submit to any jurisdiction.
9  */
10 
11 #ifndef OOPS_INTERFACE_LINEAROBSOPERATOR_H_
12 #define OOPS_INTERFACE_LINEAROBSOPERATOR_H_
13 
14 #include <memory>
15 #include <string>
16 
17 #include <boost/noncopyable.hpp>
18 
19 #include "oops/base/Variables.h"
20 #include "oops/interface/GeoVaLs.h"
25 #include "oops/util/DateTime.h"
26 #include "oops/util/Logger.h"
27 #include "oops/util/ObjectCounter.h"
28 #include "oops/util/Printable.h"
29 #include "oops/util/Timer.h"
30 
31 namespace oops {
32 
33 // -----------------------------------------------------------------------------
34 
35 template <typename OBS>
36 class LinearObsOperator : public util::Printable,
37  private boost::noncopyable,
38  private util::ObjectCounter<LinearObsOperator<OBS> > {
39  typedef typename OBS::LinearObsOperator LinearObsOper_;
45 
46  public:
47  static const std::string classname() {return "oops::LinearObsOperator";}
48 
49  LinearObsOperator(const ObsSpace_ &, const eckit::Configuration &);
51 
52 /// Interfacing
53  const LinearObsOper_ & linearobsoperator() const {return *oper_;}
54 
55 /// Obs Operators
56  void setTrajectory(const GeoVaLs_ &, const ObsAuxControl_ &);
57  void simulateObsTL(const GeoVaLs_ &, ObsVector_ &, const ObsAuxIncrement_ &) const;
58  void simulateObsAD(GeoVaLs_ &, const ObsVector_ &, ObsAuxIncrement_ &) const;
59 
60 /// Other
61  const Variables & requiredVars() const; // Required inputs variables from LinearModel
62 
63  private:
64  void print(std::ostream &) const;
65  std::unique_ptr<LinearObsOper_> oper_;
66 };
67 
68 // -----------------------------------------------------------------------------
69 
70 template <typename OBS>
72  const eckit::Configuration & config): oper_() {
73  Log::trace() << "LinearObsOperator<OBS>::LinearObsOperator starting" << std::endl;
74  util::Timer timer(classname(), "LinearObsOperator");
75  oper_.reset(new LinearObsOper_(os.obsspace(), config));
76  Log::trace() << "LinearObsOperator<OBS>::LinearObsOperator done" << std::endl;
77 }
78 
79 // -----------------------------------------------------------------------------
80 
81 template <typename OBS>
83  Log::trace() << "LinearObsOperator<OBS>::~LinearObsOperator starting" << std::endl;
84  util::Timer timer(classname(), "~LinearObsOperator");
85  oper_.reset();
86  Log::trace() << "LinearObsOperator<OBS>::~LinearObsOperator done" << std::endl;
87 }
88 
89 // -----------------------------------------------------------------------------
90 
91 template <typename OBS>
93  Log::trace() << "LinearObsOperator<OBS>::setTrajectory starting" << std::endl;
94  util::Timer timer(classname(), "setTrajectory");
95  oper_->setTrajectory(gvals.geovals(), aux.obsauxcontrol());
96  Log::trace() << "LinearObsOperator<OBS>::setTrajectory done" << std::endl;
97 }
98 
99 // -----------------------------------------------------------------------------
100 
101 template <typename OBS>
103  const ObsAuxIncrement_ & aux) const {
104  Log::trace() << "LinearObsOperator<OBS>::simulateObsTL starting" << std::endl;
105  util::Timer timer(classname(), "simulateObsTL");
106  oper_->simulateObsTL(gvals.geovals(), yy.obsvector(), aux.obsauxincrement());
107  Log::trace() << "LinearObsOperator<OBS>::simulateObsTL done" << std::endl;
108 }
109 
110 // -----------------------------------------------------------------------------
111 
112 template <typename OBS>
114  ObsAuxIncrement_ & aux) const {
115  Log::trace() << "LinearObsOperator<OBS>::simulateObsAD starting" << std::endl;
116  util::Timer timer(classname(), "simulateObsAD");
117  oper_->simulateObsAD(gvals.geovals(), yy.obsvector(), aux.obsauxincrement());
118  Log::trace() << "LinearObsOperator<OBS>::simulateObsAD done" << std::endl;
119 }
120 
121 // -----------------------------------------------------------------------------
122 
123 template <typename OBS>
125  Log::trace() << "LinearObsOperator<OBS>::requiredVars starting" << std::endl;
126  util::Timer timer(classname(), "requiredVars");
127  return oper_->requiredVars();
128 }
129 
130 // -----------------------------------------------------------------------------
131 
132 template<typename OBS>
133 void LinearObsOperator<OBS>::print(std::ostream & os) const {
134  Log::trace() << "LinearObsOperator<OBS>::print starting" << std::endl;
135  util::Timer timer(classname(), "print");
136  os << *oper_;
137  Log::trace() << "LinearObsOperator<OBS>::print done" << std::endl;
138 }
139 
140 // -----------------------------------------------------------------------------
141 
142 } // namespace oops
143 
144 #endif // OOPS_INTERFACE_LINEAROBSOPERATOR_H_
const GeoVaLs_ & geovals() const
Interfacing.
const LinearObsOper_ & linearobsoperator() const
Interfacing.
void simulateObsTL(const GeoVaLs_ &, ObsVector_ &, const ObsAuxIncrement_ &) const
std::unique_ptr< LinearObsOper_ > oper_
const Variables & requiredVars() const
Other.
void simulateObsAD(GeoVaLs_ &, const ObsVector_ &, ObsAuxIncrement_ &) const
static const std::string classname()
void setTrajectory(const GeoVaLs_ &, const ObsAuxControl_ &)
Obs Operators.
LinearObsOperator(const ObsSpace_ &, const eckit::Configuration &)
const ObsAuxControl_ & obsauxcontrol() const
Interfacing.
const ObsAuxIncrement_ & obsauxincrement() const
Interfacing.
ObsSpace_ & obsspace() const
Interfacing.
ObsVector_ & obsvector()
Interfacing.
The namespace for the main oops code.