FV3 Bundle
oops/src/oops/interface/ObsOperator.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_OBSOPERATOR_H_
12 #define OOPS_INTERFACE_OBSOPERATOR_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"
24 #include "oops/util/DateTime.h"
25 #include "oops/util/Logger.h"
26 #include "oops/util/ObjectCounter.h"
27 #include "oops/util/Printable.h"
28 #include "oops/util/Timer.h"
29 
30 namespace oops {
31 
32 // -----------------------------------------------------------------------------
33 
34 template <typename MODEL>
35 class ObsOperator : public util::Printable,
36  private boost::noncopyable,
37  private util::ObjectCounter<ObsOperator<MODEL> > {
38  typedef typename MODEL::ObsOperator ObsOperator_;
43 
44  public:
45  static const std::string classname() {return "oops::ObsOperator";}
46 
47  explicit ObsOperator(const ObsSpace_ &);
48  ~ObsOperator();
49 
50 /// Obs Operator
51  void simulateObs(const GeoVaLs_ &, ObsVector_ &, const ObsAuxControl_ &) const;
52 
53 /// Interfacing
54  const ObsOperator_ & obsoperator() const {return *oper_;}
55 
56 /// Other
57  const Variables & variables() const; // Required inputs variables from Model
58 
59  private:
60  void print(std::ostream &) const;
61  boost::scoped_ptr<ObsOperator_> oper_;
62 };
63 
64 // -----------------------------------------------------------------------------
65 
66 template <typename MODEL>
68  Log::trace() << "ObsOperator<MODEL>::ObsOperator starting" << std::endl;
69  util::Timer timer(classname(), "ObsOperator");
70  oper_.reset(new ObsOperator_(os.observationspace(), os.config()));
71  Log::trace() << "ObsOperator<MODEL>::ObsOperator done" << std::endl;
72 }
73 
74 // -----------------------------------------------------------------------------
75 
76 template <typename MODEL>
78  Log::trace() << "ObsOperator<MODEL>::~ObsOperator starting" << std::endl;
79  util::Timer timer(classname(), "~ObsOperator");
80  oper_.reset();
81  Log::trace() << "ObsOperator<MODEL>::~ObsOperator done" << std::endl;
82 }
83 
84 // -----------------------------------------------------------------------------
85 
86 template <typename MODEL>
88  const ObsAuxControl_ & aux) const {
89  Log::trace() << "ObsOperator<MODEL>::simulateObs starting" << std::endl;
90  util::Timer timer(classname(), "simulateObs");
91  oper_->simulateObs(gvals.geovals(), yy.obsvector(), aux.obsauxcontrol());
92  Log::trace() << "ObsOperator<MODEL>::simulateObs done" << std::endl;
93 }
94 
95 // -----------------------------------------------------------------------------
96 
97 template <typename MODEL>
99  Log::trace() << "ObsOperator<MODEL>::variables starting" << std::endl;
100  util::Timer timer(classname(), "variables");
101  return oper_->variables();
102 }
103 
104 // -----------------------------------------------------------------------------
105 
106 template<typename MODEL>
107 void ObsOperator<MODEL>::print(std::ostream & os) const {
108  Log::trace() << "ObsOperator<MODEL>::print starting" << std::endl;
109  util::Timer timer(classname(), "print");
110  os << *oper_;
111  Log::trace() << "ObsOperator<MODEL>::print done" << std::endl;
112 }
113 
114 // -----------------------------------------------------------------------------
115 
116 } // namespace oops
117 
118 #endif // OOPS_INTERFACE_OBSOPERATOR_H_
const GeoVaLs_ & geovals() const
Interfacing.
const ObsOperator_ & obsoperator() const
Interfacing.
const Variables & variables() const
Other.
static const std::string classname()
const eckit::Configuration & config() const
The namespace for the main oops code.
boost::scoped_ptr< ObsOperator_ > oper_
ObsVector_ & obsvector()
Interfacing.
ObservationSpace< MODEL > ObsSpace_
void print(std::ostream &) const
ObsSpace_ & observationspace() const
Interfacing.
ObsAuxControl< MODEL > ObsAuxControl_
const ObsAuxControl_ & obsauxcontrol() const
Interfacing.
void simulateObs(const GeoVaLs_ &, ObsVector_ &, const ObsAuxControl_ &) const
Obs Operator.