UFO
ObsCategorical.cc
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2021 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 <utility>
13 #include <vector>
14 
15 #include "ioda/ObsVector.h"
16 
17 #include "oops/util/Logger.h"
18 
20 #include "ufo/GeoVaLs.h"
21 #include "ufo/ObsDiagnostics.h"
22 
23 namespace ufo {
24 
25 // -----------------------------------------------------------------------------
27 // -----------------------------------------------------------------------------
28 
29 ObsCategorical::ObsCategorical(const ioda::ObsSpace & odb,
30  const Parameters_ & params)
31  : ObsOperatorBase(odb), odb_(odb)
32 {
33  oops::Log::trace() << "ObsCategorical constructor starting" << std::endl;
34 
35  data_.configure(odb, params);
36 
37  oops::Log::trace() << "ObsCategorical constructor finished" << std::endl;
38 }
39 
40 // -----------------------------------------------------------------------------
41 
43  oops::Log::trace() << "ObsCategorical destructed" << std::endl;
44 }
45 
46 // -----------------------------------------------------------------------------
47 
48 void ObsCategorical::simulateObs(const GeoVaLs & gv, ioda::ObsVector & ovec,
49  ObsDiagnostics & ydiags) const {
50  oops::Log::trace() << "ObsCategorical: simulateObs entered" << std::endl;
51 
52  oops::Log::debug() << "Running operators" << std::endl;
53 
54  // Container of ObsVectors produced by each operator.
55  std::map <std::string, ioda::ObsVector> ovecs;
56  // Run each operator and store output in ovecs.
57  for (const auto& component : data_.components()) {
58  ioda::ObsVector ovecTemp(ovec);
59  component.second->simulateObs(gv, ovecTemp, ydiags);
60  ovecs.insert({component.first, ovecTemp});
61  }
62 
63  oops::Log::debug() << "Producing final ObsVector" << std::endl;
64 
65  data_.fillHofX(ovecs, ovec);
66 
67  oops::Log::trace() << "ObsCategorical: simulateObs finished" << std::endl;
68 }
69 
70 // -----------------------------------------------------------------------------
71 
72 void ObsCategorical::print(std::ostream & os) const {
73  data_.print(os);
74 }
75 
76 // -----------------------------------------------------------------------------
77 
78 } // namespace ufo
GeoVaLs: geophysical values at locations.
~ObsCategorical() override
ObsCategoricalData< ObsOperatorBase > data_
Data handler for the Categorical operator and TL/AD code.
void simulateObs(const GeoVaLs &, ioda::ObsVector &, ObsDiagnostics &) const override
Obs Operator.
void print(std::ostream &) const override
ObsCategorical(const ioda::ObsSpace &, const Parameters_ &)
Configuration options recognized by the Categorical operator.
Definition: RunCRTM.h:27
static ObsOperatorMaker< ObsCategorical > obsCategoricalMaker_("Categorical")