OOPS
ObserversTLAD.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_BASE_OBSERVERSTLAD_H_
12 #define OOPS_BASE_OBSERVERSTLAD_H_
13 
14 #include <algorithm>
15 #include <memory>
16 #include <utility>
17 #include <vector>
18 
19 #include "eckit/config/Configuration.h"
20 #include "oops/base/Departures.h"
22 #include "oops/base/Geometry.h"
26 #include "oops/base/ObserverTLAD.h"
27 #include "oops/base/ObsSpaces.h"
29 #include "oops/util/DateTime.h"
30 #include "oops/util/Duration.h"
31 
32 namespace oops {
33 
34 /// Computes observation equivalent TL and AD to/from increments.
35 
36 template <typename MODEL, typename OBS>
48 
49  public:
50  ObserversTLAD(const ObsSpaces_ &, const eckit::Configuration &);
51 
52  void initializeTraj(const Geometry_ &, const ObsAuxCtrls_ &, PostProcTLAD_ &);
53  void finalizeTraj();
54 
56  void finalizeTL(const ObsAuxIncrs_ &, Departures_ &);
57 
59  void finalizeAD();
60 
61  private:
62  std::vector<std::unique_ptr<ObserverTLAD_>> observers_;
63  util::DateTime winbgn_;
64  util::DateTime winend_;
65 };
66 
67 // -----------------------------------------------------------------------------
68 template <typename MODEL, typename OBS>
70  const eckit::Configuration & obsConfig)
71  : observers_(), winbgn_(obspaces.windowStart()), winend_(obspaces.windowEnd())
72 {
73  Log::trace() << "ObserversTLAD<MODEL, OBS>::ObserversTLAD start" << std::endl;
74  std::vector<eckit::LocalConfiguration> obsconfs = obsConfig.getSubConfigurations();
75  for (size_t jj = 0; jj < obspaces.size(); ++jj) {
76  bool passive = obsconfs[jj].getBool("monitoring only", false);
77  std::unique_ptr<ObserverTLAD_> tmp;
78  if (!passive) tmp.reset(new ObserverTLAD_(obspaces[jj], obsconfs[jj]));
79  observers_.push_back(std::move(tmp));
80  }
81  Log::trace() << "ObserversTLAD<MODEL, OBS>::ObserversTLAD done" << std::endl;
82 }
83 // -----------------------------------------------------------------------------
84 template <typename MODEL, typename OBS>
86  PostProcTLAD_ & pp) {
87  Log::trace() << "ObserversTLAD<MODEL, OBS>::initializeTraj start" << std::endl;
88  std::shared_ptr<GetValueTLADs_> getvals(new GetValueTLADs_(winbgn_, winend_));
89  for (size_t jj = 0; jj < observers_.size(); ++jj) {
90  if (observers_[jj]) getvals->append(observers_[jj]->initializeTraj(geom, ybias[jj]));
91  }
92  pp.enrollProcessor(getvals);
93  Log::trace() << "ObserversTLAD<MODEL, OBS>::initializeTraj done" << std::endl;
94 }
95 // -----------------------------------------------------------------------------
96 template <typename MODEL, typename OBS>
98  Log::trace() << "ObserversTLAD<MODEL, OBS>::finalizeTraj start" << std::endl;
99  for (size_t jj = 0; jj < observers_.size(); ++jj) {
100  if (observers_[jj]) observers_[jj]->finalizeTraj();
101  }
102  Log::trace() << "ObserversTLAD<MODEL, OBS>::finalizeTraj done" << std::endl;
103 }
104 // -----------------------------------------------------------------------------
105 template <typename MODEL, typename OBS>
107  Log::trace() << "ObserversTLAD<MODEL, OBS>::initializeTL start" << std::endl;
108  std::shared_ptr<GetValueTLADs_> getvals(new GetValueTLADs_(winbgn_, winend_));
109  for (size_t jj = 0; jj < observers_.size(); ++jj) {
110  if (observers_[jj]) getvals->append(observers_[jj]->initializeTL());
111  }
112  pp.enrollProcessor(getvals);
113  Log::trace() << "ObserversTLAD<MODEL, OBS>::initializeTL done" << std::endl;
114 }
115 // -----------------------------------------------------------------------------
116 template <typename MODEL, typename OBS>
118  Log::trace() << "ObserversTLAD<MODEL, OBS>::finalizeTL start" << std::endl;
119  for (size_t jj = 0; jj < observers_.size(); ++jj) {
120  if (observers_[jj]) observers_[jj]->finalizeTL(ybias[jj], dy[jj]);
121  }
122  Log::trace() << "ObserversTLAD<MODEL, OBS>::finalizeTL done" << std::endl;
123 }
124 // -----------------------------------------------------------------------------
125 template <typename MODEL, typename OBS>
127  PostProcTLAD_ & pp) {
128  Log::trace() << "ObserversTLAD<MODEL, OBS>::initializeAD start" << std::endl;
129  std::shared_ptr<GetValueTLADs_> getvals(new GetValueTLADs_(winbgn_, winend_));
130  for (size_t jj = 0; jj < observers_.size(); ++jj) {
131  if (observers_[jj]) getvals->append(observers_[jj]->initializeAD(dy[jj], ybias[jj]));
132  }
133  pp.enrollProcessor(getvals);
134  Log::trace() << "ObserversTLAD<MODEL, OBS>::initializeAD done" << std::endl;
135 }
136 // -----------------------------------------------------------------------------
137 template <typename MODEL, typename OBS>
139  Log::trace() << "ObserversTLAD<MODEL, OBS>::finalizeAD start" << std::endl;
140  for (size_t jj = 0; jj < observers_.size(); ++jj) {
141  if (observers_[jj]) observers_[jj]->finalizeAD();
142  }
143  Log::trace() << "ObserversTLAD<MODEL, OBS>::finalizeAD done" << std::endl;
144 }
145 // -----------------------------------------------------------------------------
146 
147 } // namespace oops
148 
149 #endif // OOPS_BASE_OBSERVERSTLAD_H_
Difference between two observation vectors.
Definition: Departures.h:44
Geometry class used in oops; subclass of interface class interface::Geometry.
Computes observation equivalent TL and AD to/from increments.
Definition: GetValueTLADs.h:26
Holds a vector of ObsAuxControl.
Holds a vector of ObsAuxIncrement.
std::size_t size() const
Access.
Definition: ObsSpaces.h:61
Observations Class.
Definition: Observations.h:35
Computes observation equivalent TL and AD to/from increments.
Definition: ObserverTLAD.h:35
Computes observation equivalent TL and AD to/from increments.
Definition: ObserversTLAD.h:37
ObserversTLAD(const ObsSpaces_ &, const eckit::Configuration &)
Definition: ObserversTLAD.h:69
void initializeAD(const Departures_ &, ObsAuxIncrs_ &, PostProcTLAD_ &)
util::DateTime winend_
Definition: ObserversTLAD.h:64
GeoVaLs< OBS > GeoVaLs_
Definition: ObserversTLAD.h:40
std::vector< std::unique_ptr< ObserverTLAD_ > > observers_
Definition: ObserversTLAD.h:62
Geometry< MODEL > Geometry_
Definition: ObserversTLAD.h:39
ObserverTLAD< MODEL, OBS > ObserverTLAD_
Definition: ObserversTLAD.h:45
PostProcessorTLAD< MODEL > PostProcTLAD_
Definition: ObserversTLAD.h:47
ObsAuxControls< OBS > ObsAuxCtrls_
Definition: ObserversTLAD.h:43
ObsAuxIncrements< OBS > ObsAuxIncrs_
Definition: ObserversTLAD.h:44
void finalizeTL(const ObsAuxIncrs_ &, Departures_ &)
void initializeTraj(const Geometry_ &, const ObsAuxCtrls_ &, PostProcTLAD_ &)
Definition: ObserversTLAD.h:85
Observations< OBS > Observations_
Definition: ObserversTLAD.h:42
void initializeTL(PostProcTLAD_ &)
ObsSpaces< OBS > ObsSpaces_
Definition: ObserversTLAD.h:46
GetValueTLADs< MODEL, OBS > GetValueTLADs_
Definition: ObserversTLAD.h:41
util::DateTime winbgn_
Definition: ObserversTLAD.h:63
Departures< OBS > Departures_
Definition: ObserversTLAD.h:38
Control model post processing.
void enrollProcessor(PostBaseTLAD_ *pp)
The namespace for the main oops code.