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