OOPS
oops/interface/GetValues.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2019-2020 UCAR
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  */
7 
8 #ifndef OOPS_INTERFACE_GETVALUES_H_
9 #define OOPS_INTERFACE_GETVALUES_H_
10 
11 #include <memory>
12 #include <string>
13 
14 
15 #include "eckit/config/Configuration.h"
17 #include "oops/interface/GeoVaLs.h"
19 #include "oops/interface/State.h"
20 #include "oops/util/DateTime.h"
21 #include "oops/util/ObjectCounter.h"
22 #include "oops/util/Printable.h"
23 #include "oops/util/Timer.h"
24 
25 namespace oops {
26 
27 /// \brief Gets values from model State to observation locations (fills GeoVaLs)
28 // -----------------------------------------------------------------------------
29 
30 template <typename MODEL, typename OBS>
31 class GetValues : public util::Printable,
32  private util::ObjectCounter<GetValues<MODEL, OBS> > {
33  typedef typename MODEL::GetValues GetValues_;
38 
39  public:
40  static const std::string classname() {return "oops::GetValues";}
41 
42 /// Constructor, destructor
43  GetValues(const Geometry_ &, const Locations_ &);
44  ~GetValues();
45 
46 /// Interfacing
48  const GetValues_ & getvalues() const {return *getvalues_;}
49 
50 /// Get state values at observation locations
51  void fillGeoVaLs(const State_ &, const util::DateTime &, const util::DateTime &,
52  GeoVaLs_ &) const;
53 
54  private:
55  void print(std::ostream &) const;
56  std::unique_ptr<GetValues_> getvalues_;
57 };
58 
59 // =============================================================================
60 
61 template<typename MODEL, typename OBS>
62 GetValues<MODEL, OBS>::GetValues(const Geometry_ & resol, const Locations_ & locs) : getvalues_()
63 {
64  Log::trace() << "GetValues<MODEL, OBS>::GetValues starting" << std::endl;
65  util::Timer timer(classname(), "GetValues");
66  getvalues_.reset(new GetValues_(resol.geometry(), locs.locations()));
67  Log::trace() << "GetValues<MODEL, OBS>::GetValues done" << std::endl;
68 }
69 
70 // -----------------------------------------------------------------------------
71 
72 template<typename MODEL, typename OBS>
74  Log::trace() << "GetValues<MODEL, OBS>::~GetValues starting" << std::endl;
75  util::Timer timer(classname(), "~GetValues");
76  getvalues_.reset();
77  Log::trace() << "GetValues<MODEL, OBS>::~GetValues done" << std::endl;
78 }
79 
80 // -----------------------------------------------------------------------------
81 
82 template<typename MODEL, typename OBS>
83 void GetValues<MODEL, OBS>::fillGeoVaLs(const State_ & state, const util::DateTime & t1,
84  const util::DateTime & t2, GeoVaLs_ & gvals) const {
85  Log::trace() << "GetValues<MODEL, OBS>::fillGeoVaLs starting" << std::endl;
86  util::Timer timer(classname(), "fillGeoVaLs");
87  getvalues_->fillGeoVaLs(state.state(), t1, t2, gvals.geovals());
88  Log::trace() << "GetValues<MODEL, OBS>::fillGeoVaLs done" << std::endl;
89 }
90 
91 // -----------------------------------------------------------------------------
92 
93 template<typename MODEL, typename OBS>
94 void GetValues<MODEL, OBS>::print(std::ostream & os) const {
95  Log::trace() << "GetValues<MODEL, OBS>::print starting" << std::endl;
96  util::Timer timer(classname(), "print");
97  os << *getvalues_;
98  Log::trace() << "GetValues<MODEL, OBS>::print done" << std::endl;
99 }
100 
101 // -----------------------------------------------------------------------------
102 
103 } // namespace oops
104 
105 #endif // OOPS_INTERFACE_GETVALUES_H_
oops::GetValues::GeoVaLs_
GeoVaLs< OBS > GeoVaLs_
Definition: oops/interface/GetValues.h:35
oops
The namespace for the main oops code.
Definition: ErrorCovarianceL95.cc:22
oops::GetValues::print
void print(std::ostream &) const
Definition: oops/interface/GetValues.h:94
oops::GeoVaLs::geovals
const GeoVaLs_ & geovals() const
Interfacing.
Definition: oops/interface/GeoVaLs.h:47
Locations.h
oops::GetValues::GetValues_
MODEL::GetValues GetValues_
Definition: oops/interface/GetValues.h:33
oops::GetValues
Gets values from model State to observation locations (fills GeoVaLs)
Definition: oops/interface/GetValues.h:32
oops::GetValues::getvalues
const GetValues_ & getvalues() const
Definition: oops/interface/GetValues.h:48
oops::State::state
State_ & state()
Interfacing.
Definition: oops/interface/State.h:56
oops::GetValues::getvalues
GetValues_ & getvalues()
Interfacing.
Definition: oops/interface/GetValues.h:47
oops::GetValues::fillGeoVaLs
void fillGeoVaLs(const State_ &, const util::DateTime &, const util::DateTime &, GeoVaLs_ &) const
Get state values at observation locations.
Definition: oops/interface/GetValues.h:83
oops::GetValues::State_
State< MODEL > State_
Definition: oops/interface/GetValues.h:37
oops::Geometry
Geometry class used in oops; subclass of interface class above.
Definition: oops/interface/Geometry.h:189
oops::Locations::locations
const Locations_ & locations() const
Interfacing.
Definition: oops/interface/Locations.h:54
oops::State
Encapsulates the model state.
Definition: CostJbState.h:28
oops::GetValues::~GetValues
~GetValues()
Definition: oops/interface/GetValues.h:73
State.h
oops::GetValues::Geometry_
Geometry< MODEL > Geometry_
Definition: oops/interface/GetValues.h:34
oops::GetValues::Locations_
Locations< OBS > Locations_
Definition: oops/interface/GetValues.h:36
oops::Locations
Locations of observations for observation operator.
Definition: oops/interface/Locations.h:36
oops::GetValues::classname
static const std::string classname()
Definition: oops/interface/GetValues.h:40
GeoVaLs.h
oops::GeoVaLs
Definition: oops/interface/GeoVaLs.h:32
oops::GetValues::GetValues
GetValues(const Geometry_ &, const Locations_ &)
Constructor, destructor.
Definition: oops/interface/GetValues.h:62
oops::GetValues::getvalues_
std::unique_ptr< GetValues_ > getvalues_
Definition: oops/interface/GetValues.h:56
Geometry.h
oops::Geometry::geometry
const Geometry_ & geometry() const
Interfacing with other oops classes.
Definition: oops/interface/Geometry.h:206