UFO
ObsTimeOperTLAD.cc
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2019 UK Met Office
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 
9 
10 #include <algorithm>
11 #include <ostream>
12 #include <vector>
13 
14 #include "ioda/ObsSpace.h"
15 #include "ioda/ObsVector.h"
16 
17 #include "oops/base/Variables.h"
18 #include "oops/util/DateTime.h"
19 #include "oops/util/Duration.h"
20 #include "oops/util/Logger.h"
21 
22 #include "ufo/GeoVaLs.h"
24 
25 namespace ufo {
26 
27 // -----------------------------------------------------------------------------
29 // -----------------------------------------------------------------------------
30 
31 ObsTimeOperTLAD::ObsTimeOperTLAD(const ioda::ObsSpace & odb,
32  const eckit::Configuration & config)
33  : LinearObsOperatorBase(odb),
34  actualoperator_(LinearObsOperatorFactory::create(
35  odb,
36  oops::validateAndDeserialize<LinearObsOperatorParametersWrapper>(
37  eckit::LocalConfiguration(config, "obs operator")).operatorParameters)),
38  timeWeights_(timeWeightCreate(odb, config))
39 {
40  oops::Log::trace() << "ObsTimeOperTLAD created" << std::endl;
41 }
42 
43 // -----------------------------------------------------------------------------
44 
46  oops::Log::trace() << "ObsTimeOperTLAD destructed" << std::endl;
47 }
48 
49 // -----------------------------------------------------------------------------
50 
52  ObsDiagnostics & ydiags) {
53  oops::Log::trace() << "ObsTimeOperTLAD::setTrajectory entering" << std::endl;
54 
55  oops::Log::debug() << "ObsTimeOperTLAD::setTrajectory input geovals "
56  << geovals << std::endl;
57 
58  GeoVaLs gv1(obsspace().distribution(), geovals.getVars());
59  GeoVaLs gv2(obsspace().distribution(), geovals.getVars());
60  geovals.split(gv1, gv2);
61 
62  oops::Log::debug() << "ObsTimeOperTLAD::setTrajectory split geovals gv1 "
63  << gv1 << std::endl;
64 
65  oops::Log::debug() << "ObsTimeOperTLAD::setTrajectory split geovals gv2 "
66  << gv2 << std::endl;
67 
68  gv1 *= timeWeights_[0];
69  gv2 *= timeWeights_[1];
70  gv1 += gv2;
71 
72  oops::Log::debug() << "ObsTimeOperTLAD::setTrajectory final geovals gv1 "
73  << gv1 << std::endl;
74 
75  actualoperator_->setTrajectory(gv1, ydiags);
76 
77  oops::Log::debug() << gv1;
78 
79  oops::Log::trace() << "ObsTimeOperTLAD::setTrajectory exiting" << std::endl;
80 }
81 
82 // -----------------------------------------------------------------------------
83 
84 void ObsTimeOperTLAD::simulateObsTL(const GeoVaLs & geovals, ioda::ObsVector & ovec) const {
85  oops::Log::trace() << "ObsTimeOperTLAD::simulateObsTL entering" << std::endl;
86 
87  oops::Log::debug() << "ObsTimeOperTLAD::setTrajectory input geovals "
88  << geovals << std::endl;
89 
90  GeoVaLs gv1(obsspace().distribution(), geovals.getVars());
91  GeoVaLs gv2(obsspace().distribution(), geovals.getVars());
92  geovals.split(gv1, gv2);
93 
94  oops::Log::debug() << "ObsTimeOperTLAD::simulateObsTL split geovals gv1 "
95  << gv1 << std::endl;
96 
97  oops::Log::debug() << "ObsTimeOperTLAD::simulateObsTL split geovals gv2 "
98  << gv2 << std::endl;
99 
100  gv1 *= timeWeights_[0];
101  gv2 *= timeWeights_[1];
102  gv1 += gv2;
103 
104  oops::Log::debug() << "ObsTimeOperTLAD::simulateObsTL final geovals gv1 "
105  << gv1 << std::endl;
106 
107  actualoperator_->simulateObsTL(gv1, ovec);
108 
109  oops::Log::trace() << "ObsTimeOperTLAD::simulateObsTL exiting" << std::endl;
110 }
111 
112 // -----------------------------------------------------------------------------
113 
114 void ObsTimeOperTLAD::simulateObsAD(GeoVaLs & geovals, const ioda::ObsVector & ovec) const {
115  oops::Log::trace() << "ObsTimeOperTLAD::simulateObsAD entering" << std::endl;
116 
117  oops::Log::debug() << "ObsTimeOperTLAD::simulateObsAD input geovals "
118  << geovals << std::endl;
119 
120  GeoVaLs gv1(obsspace().distribution(), geovals.getVars());
121  GeoVaLs gv2(obsspace().distribution(), geovals.getVars());
122  geovals.split(gv1, gv2);
123 
124  oops::Log::debug() << "ObsTimeOperTLAD::simulateObsAD split geovals gv1 "
125  << gv1 << std::endl;
126 
127  oops::Log::debug() << "ObsTimeOperTLAD::simulateObsAD split geovals gv2 "
128  << gv2 << std::endl;
129 
130  actualoperator_->simulateObsAD(gv1, ovec);
131 
132  gv2 = gv1;
133  gv1 *= timeWeights_[0];
134  gv2 *= timeWeights_[1];
135 
136  geovals.merge(gv1, gv2);
137 
138  oops::Log::debug() << "ObsTimeOperTLAD::simulateObsAD final geovals "
139  << geovals << std::endl;
140 
141  oops::Log::trace() << "ObsTimeOperTLAD::simulateObsAD exiting" << std::endl;
142 }
143 
144 // -----------------------------------------------------------------------------
145 
146 void ObsTimeOperTLAD::print(std::ostream & os) const {
147  os << "ObsTimeOperTLAD::print not implemented" << std::endl;
148 }
149 
150 // -----------------------------------------------------------------------------
151 
152 } // namespace ufo
GeoVaLs: geophysical values at locations.
void split(GeoVaLs &, GeoVaLs &) const
Split two GeoVaLs.
Definition: GeoVaLs.cc:259
const oops::Variables & getVars() const
void merge(const GeoVaLs &, const GeoVaLs &)
Merge two GeoVaLs.
Definition: GeoVaLs.cc:267
const ioda::ObsSpace & obsspace() const
The space containing the observations to be simulated by this operator.
Linear obs operator factory.
Contains a polymorphic parameter holding an instance of a subclass of ObsOperatorParametersBase.
std::vector< std::vector< float > > timeWeights_
std::unique_ptr< LinearObsOperatorBase > actualoperator_
void simulateObsAD(GeoVaLs &, const ioda::ObsVector &) const override
void simulateObsTL(const GeoVaLs &, ioda::ObsVector &) const override
ObsTimeOperTLAD(const ioda::ObsSpace &, const eckit::Configuration &)
void print(std::ostream &) const override
void setTrajectory(const GeoVaLs &, ObsDiagnostics &) override
Obs Operator.
Forward declarations.
Definition: ObsAodExt.h:21
Definition: RunCRTM.h:27
static LinearObsOperatorMaker< ObsTimeOperTLAD > makerTimeOperTL_("TimeOperLinInterp")
std::vector< std::vector< float > > timeWeightCreate(const ioda::ObsSpace &odb_, const eckit::Configuration &config)