IODA Bundle
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 <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/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 OBS>
35 class ObsOperator : public util::Printable,
36  private boost::noncopyable,
37  private util::ObjectCounter<ObsOperator<OBS> > {
38  typedef typename OBS::ObsOperator ObsOperator_;
45 
46  public:
47  static const std::string classname() {return "oops::ObsOperator";}
48 
49  ObsOperator(const ObsSpace_ &, const eckit::Configuration &);
50  ~ObsOperator();
51 
52 /// Obs Operator
53  void simulateObs(const GeoVaLs_ &, ObsVector_ &, const ObsAuxControl_ &, ObsDiags_ &) const;
54 
55 /// Interfacing
56  const ObsOperator_ & obsoperator() const {return *oper_;}
57 
58 /// Other
59  const Variables & requiredVars() const; // Required input variables from Model
60  Locations_ locations() const;
61 
62  private:
63  void print(std::ostream &) const;
64  std::unique_ptr<ObsOperator_> oper_;
65 };
66 
67 // -----------------------------------------------------------------------------
68 
69 template <typename OBS>
71  const eckit::Configuration & config) : oper_() {
72  Log::trace() << "ObsOperator<OBS>::ObsOperator starting" << std::endl;
73  util::Timer timer(classname(), "ObsOperator");
74  oper_.reset(new ObsOperator_(os.obsspace(), config));
75  Log::trace() << "ObsOperator<OBS>::ObsOperator done" << std::endl;
76 }
77 
78 // -----------------------------------------------------------------------------
79 
80 template <typename OBS>
82  Log::trace() << "ObsOperator<OBS>::~ObsOperator starting" << std::endl;
83  util::Timer timer(classname(), "~ObsOperator");
84  oper_.reset();
85  Log::trace() << "ObsOperator<OBS>::~ObsOperator done" << std::endl;
86 }
87 
88 // -----------------------------------------------------------------------------
89 
90 template <typename OBS>
92  const ObsAuxControl_ & aux, ObsDiags_ & ydiag) const {
93  Log::trace() << "ObsOperator<OBS>::simulateObs starting" << std::endl;
94  util::Timer timer(classname(), "simulateObs");
95  oper_->simulateObs(gvals.geovals(), yy.obsvector(), aux.obsauxcontrol(), ydiag.obsdiagnostics());
96  Log::trace() << "ObsOperator<OBS>::simulateObs done" << std::endl;
97 }
98 
99 // -----------------------------------------------------------------------------
100 
101 template <typename OBS>
103  Log::trace() << "ObsOperator<OBS>::requiredVars starting" << std::endl;
104  util::Timer timer(classname(), "requiredVars");
105  return oper_->requiredVars();
106 }
107 
108 // -----------------------------------------------------------------------------
109 
110 template <typename OBS>
112  Log::trace() << "ObsOperator<OBS>::locations starting" << std::endl;
113  util::Timer timer(classname(), "locations");
114  return Locations_(oper_->locations());
115 }
116 
117 // -----------------------------------------------------------------------------
118 
119 template<typename OBS>
120 void ObsOperator<OBS>::print(std::ostream & os) const {
121  Log::trace() << "ObsOperator<OBS>::print starting" << std::endl;
122  util::Timer timer(classname(), "print");
123  os << *oper_;
124  Log::trace() << "ObsOperator<OBS>::print done" << std::endl;
125 }
126 
127 // -----------------------------------------------------------------------------
128 
129 } // namespace oops
130 
131 #endif // OOPS_INTERFACE_OBSOPERATOR_H_
const GeoVaLs_ & geovals() const
Interfacing.
Locations of observations for observation operator.
const ObsAuxControl_ & obsauxcontrol() const
Interfacing.
ObsDiags_ & obsdiagnostics()
Interfacing.
void print(std::ostream &) const
ObsDiagnostics< OBS > ObsDiags_
const Variables & requiredVars() const
Other.
std::unique_ptr< ObsOperator_ > oper_
Locations_ locations() const
ObsOperator(const ObsSpace_ &, const eckit::Configuration &)
const ObsOperator_ & obsoperator() const
Interfacing.
static const std::string classname()
void simulateObs(const GeoVaLs_ &, ObsVector_ &, const ObsAuxControl_ &, ObsDiags_ &) const
Obs Operator.
ObsAuxControl< OBS > ObsAuxControl_
ObsSpace_ & obsspace() const
Interfacing.
ObsVector_ & obsvector()
Interfacing.
The namespace for the main oops code.