FV3 Bundle
oops/interface/ObsAuxCovariance.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_OBSAUXCOVARIANCE_H_
12 #define OOPS_INTERFACE_OBSAUXCOVARIANCE_H_
13 
14 #include <iostream>
15 #include <string>
16 
17 #include <boost/noncopyable.hpp>
18 #include <boost/scoped_ptr.hpp>
19 
20 #include "eckit/config/Configuration.h"
23 #include "oops/util/Logger.h"
24 #include "oops/util/ObjectCounter.h"
25 #include "oops/util/Printable.h"
26 #include "oops/util/Timer.h"
27 
28 namespace oops {
29 
30 // -----------------------------------------------------------------------------
31 
32 template <typename MODEL>
33 class ObsAuxCovariance : public util::Printable,
34  private boost::noncopyable,
35  private util::ObjectCounter<ObsAuxCovariance<MODEL> > {
36  typedef typename MODEL::ObsAuxCovariance ObsAuxCovariance_;
39 
40  public:
41  static const std::string classname() {return "oops::ObsAuxCovariance";}
42 
43  explicit ObsAuxCovariance(const eckit::Configuration &);
45 
46 /// Operators
47  void linearize(const ObsAuxControl_ &);
48  void multiply(const ObsAuxIncrement_ &, ObsAuxIncrement_ &) const;
49  void inverseMultiply(const ObsAuxIncrement_ &, ObsAuxIncrement_ &) const;
50  void randomize(ObsAuxIncrement_ &) const;
51 
52  const eckit::Configuration & config() const {return cov_->config();}
53 
54  private:
55  void print(std::ostream &) const;
56  boost::scoped_ptr<ObsAuxCovariance_> cov_;
57 };
58 
59 // =============================================================================
60 
61 template<typename MODEL>
62 ObsAuxCovariance<MODEL>::ObsAuxCovariance(const eckit::Configuration & conf) : cov_()
63 {
64  Log::trace() << "ObsAuxCovariance<MODEL>::ObsAuxCovariance starting" << std::endl;
65  util::Timer timer(classname(), "ObsAuxCovariance");
66  cov_.reset(new ObsAuxCovariance_(conf));
67  Log::trace() << "ObsAuxCovariance<MODEL>::ObsAuxCovariance done" << std::endl;
68 }
69 
70 // -----------------------------------------------------------------------------
71 
72 template<typename MODEL>
74  Log::trace() << "ObsAuxCovariance<MODEL>::~ObsAuxCovariance starting" << std::endl;
75  util::Timer timer(classname(), "~ObsAuxCovariance");
76  cov_.reset();
77  Log::trace() << "ObsAuxCovariance<MODEL>::~ObsAuxCovariance done" << std::endl;
78 }
79 
80 // -----------------------------------------------------------------------------
81 
82 template<typename MODEL>
84  Log::trace() << "ObsAuxCovariance<MODEL>::linearize starting" << std::endl;
85  util::Timer timer(classname(), "linearize");
86  cov_->linearize(xx.obsauxcontrol());
87  Log::trace() << "ObsAuxCovariance<MODEL>::linearize done" << std::endl;
88 }
89 
90 // -----------------------------------------------------------------------------
91 
92 template<typename MODEL>
94  Log::trace() << "ObsAuxCovariance<MODEL>::multiply starting" << std::endl;
95  util::Timer timer(classname(), "multiply");
96  cov_->multiply(dx1.obsauxincrement(), dx2.obsauxincrement());
97  Log::trace() << "ObsAuxCovariance<MODEL>::multiply done" << std::endl;
98 }
99 
100 // -----------------------------------------------------------------------------
101 
102 template<typename MODEL>
104  ObsAuxIncrement_ & dx2) const {
105  Log::trace() << "ObsAuxCovariance<MODEL>::inverseMultiply starting" << std::endl;
106  util::Timer timer(classname(), "inverseMultiply");
107  cov_->inverseMultiply(dx1.obsauxincrement(), dx2.obsauxincrement());
108  Log::trace() << "ObsAuxCovariance<MODEL>::inverseMultiply done" << std::endl;
109 }
110 
111 // -----------------------------------------------------------------------------
112 
113 template<typename MODEL>
115  Log::trace() << "ObsAuxCovariance<MODEL>::randomize starting" << std::endl;
116  util::Timer timer(classname(), "randomize");
117  cov_->randomize(dx.obsauxincrement());
118  Log::trace() << "ObsAuxCovariance<MODEL>::randomize done" << std::endl;
119 }
120 
121 // -----------------------------------------------------------------------------
122 
123 template<typename MODEL>
124 void ObsAuxCovariance<MODEL>::print(std::ostream & os) const {
125  Log::trace() << "ObsAuxCovariance<MODEL>::print starting" << std::endl;
126  util::Timer timer(classname(), "print");
127  os << *cov_;
128  Log::trace() << "ObsAuxCovariance<MODEL>::print done" << std::endl;
129 }
130 
131 // -----------------------------------------------------------------------------
132 
133 } // namespace oops
134 
135 #endif // OOPS_INTERFACE_OBSAUXCOVARIANCE_H_
ObsAuxCovariance(const eckit::Configuration &)
Definition: conf.py:1
const eckit::Configuration & config() const
const ObsAuxIncrement_ & obsauxincrement() const
Interfacing.
The namespace for the main oops code.
void multiply(const ObsAuxIncrement_ &, ObsAuxIncrement_ &) const
void print(std::ostream &) const
boost::scoped_ptr< ObsAuxCovariance_ > cov_
void randomize(ObsAuxIncrement_ &) const
void inverseMultiply(const ObsAuxIncrement_ &, ObsAuxIncrement_ &) const
MODEL::ObsAuxCovariance ObsAuxCovariance_
void linearize(const ObsAuxControl_ &)
Operators.
const ObsAuxControl_ & obsauxcontrol() const
Interfacing.
static const std::string classname()
ObsAuxIncrement< MODEL > ObsAuxIncrement_