FV3 Bundle
oops/src/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 <string>
15 
16 #include <boost/noncopyable.hpp>
17 #include <boost/scoped_ptr.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 MODEL>
36 class LinearObsOperator : public util::Printable,
37  private boost::noncopyable,
38  private util::ObjectCounter<LinearObsOperator<MODEL> > {
39  typedef typename MODEL::LinearObsOperator LinearObsOper_;
45 
46  public:
47  static const std::string classname() {return "oops::LinearObsOperator";}
48 
49  explicit LinearObsOperator(const ObsSpace_ &);
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 & variables() const; // Required inputs variables from LinearModel
62 
63  private:
64  void print(std::ostream &) const;
65  boost::scoped_ptr<LinearObsOper_> oper_;
66 };
67 
68 // -----------------------------------------------------------------------------
69 
70 template <typename MODEL>
72  Log::trace() << "LinearObsOperator<MODEL>::LinearObsOperator starting" << std::endl;
73  util::Timer timer(classname(), "LinearObsOperator");
74  oper_.reset(new LinearObsOper_(os.observationspace(), os.config()));
75  Log::trace() << "LinearObsOperator<MODEL>::LinearObsOperator done" << std::endl;
76 }
77 
78 // -----------------------------------------------------------------------------
79 
80 template <typename MODEL>
82  Log::trace() << "LinearObsOperator<MODEL>::~LinearObsOperator starting" << std::endl;
83  util::Timer timer(classname(), "~LinearObsOperator");
84  oper_.reset();
85  Log::trace() << "LinearObsOperator<MODEL>::~LinearObsOperator done" << std::endl;
86 }
87 
88 // -----------------------------------------------------------------------------
89 
90 template <typename MODEL>
92  Log::trace() << "LinearObsOperator<MODEL>::setTrajectory starting" << std::endl;
93  util::Timer timer(classname(), "setTrajectory");
94  oper_->setTrajectory(gvals.geovals(), aux.obsauxcontrol());
95  Log::trace() << "LinearObsOperator<MODEL>::setTrajectory done" << std::endl;
96 }
97 
98 // -----------------------------------------------------------------------------
99 
100 template <typename MODEL>
102  const ObsAuxIncrement_ & aux) const {
103  Log::trace() << "LinearObsOperator<MODEL>::simulateObsTL starting" << std::endl;
104  util::Timer timer(classname(), "simulateObsTL");
105  oper_->simulateObsTL(gvals.geovals(), yy.obsvector(), aux.obsauxincrement());
106  Log::trace() << "LinearObsOperator<MODEL>::simulateObsTL done" << std::endl;
107 }
108 
109 // -----------------------------------------------------------------------------
110 
111 template <typename MODEL>
113  ObsAuxIncrement_ & aux) const {
114  Log::trace() << "LinearObsOperator<MODEL>::simulateObsAD starting" << std::endl;
115  util::Timer timer(classname(), "simulateObsAD");
116  oper_->simulateObsAD(gvals.geovals(), yy.obsvector(), aux.obsauxincrement());
117  Log::trace() << "LinearObsOperator<MODEL>::simulateObsAD done" << std::endl;
118 }
119 
120 // -----------------------------------------------------------------------------
121 
122 template <typename MODEL>
124  Log::trace() << "LinearObsOperator<MODEL>::variables starting" << std::endl;
125  util::Timer timer(classname(), "variables");
126  return oper_->variables();
127 }
128 
129 // -----------------------------------------------------------------------------
130 
131 template<typename MODEL>
132 void LinearObsOperator<MODEL>::print(std::ostream & os) const {
133  Log::trace() << "LinearObsOperator<MODEL>::print starting" << std::endl;
134  util::Timer timer(classname(), "print");
135  os << *oper_;
136  Log::trace() << "LinearObsOperator<MODEL>::print done" << std::endl;
137 }
138 
139 // -----------------------------------------------------------------------------
140 
141 } // namespace oops
142 
143 #endif // OOPS_INTERFACE_LINEAROBSOPERATOR_H_
void simulateObsTL(const GeoVaLs_ &, ObsVector_ &, const ObsAuxIncrement_ &) const
const GeoVaLs_ & geovals() const
Interfacing.
const Variables & variables() const
Other.
const eckit::Configuration & config() const
const ObsAuxIncrement_ & obsauxincrement() const
Interfacing.
The namespace for the main oops code.
void setTrajectory(const GeoVaLs_ &, const ObsAuxControl_ &)
Obs Operators.
ObsVector_ & obsvector()
Interfacing.
ObsSpace_ & observationspace() const
Interfacing.
boost::scoped_ptr< LinearObsOper_ > oper_
void simulateObsAD(GeoVaLs_ &, const ObsVector_ &, ObsAuxIncrement_ &) const
const ObsAuxControl_ & obsauxcontrol() const
Interfacing.
const LinearObsOper_ & linearobsoperator() const
Interfacing.