UFO
ObsIdentity.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 <ostream>
11 #include <vector>
12 
13 #include "ioda/ObsVector.h"
14 
15 #include "oops/util/Logger.h"
16 
17 #include "ufo/GeoVaLs.h"
18 #include "ufo/ObsDiagnostics.h"
19 #include "ufo/utils/OperatorUtils.h" // for getOperatorVariables
20 
21 namespace ufo {
22 
23 // -----------------------------------------------------------------------------
25 // -----------------------------------------------------------------------------
26 
27 ObsIdentity::ObsIdentity(const ioda::ObsSpace & odb,
28  const eckit::Configuration & config)
29  : ObsOperatorBase(odb, config)
30 {
31  oops::Log::trace() << "ObsIdentity constructor starting" << std::endl;
32 
33  getOperatorVariables(config, odb.obsvariables(), operatorVars_, operatorVarIndices_);
35 
36  oops::Log::trace() << "ObsIdentity constructor finished" << std::endl;
37 }
38 
39 // -----------------------------------------------------------------------------
40 
42  oops::Log::trace() << "ObsIdentity destructed" << std::endl;
43 }
44 
45 // -----------------------------------------------------------------------------
46 
47 void ObsIdentity::simulateObs(const GeoVaLs & gv, ioda::ObsVector & ovec,
48  ObsDiagnostics & ydiags) const {
49  oops::Log::trace() << "ObsIdentity: simulateObs starting" << std::endl;
50 
51  std::vector<double> vec(ovec.nlocs());
52  for (int jvar : operatorVarIndices_) {
53  const std::string& varname = ovec.varnames().variables()[jvar];
54  // Get GeoVaL at the lowest level.
55  gv.getAtLevel(vec, varname, 0);
56  for (size_t jloc = 0; jloc < ovec.nlocs(); ++jloc) {
57  const size_t idx = jloc * ovec.nvars() + jvar;
58  ovec[idx] = vec[jloc];
59  }
60  }
61 
62  oops::Log::trace() << "ObsIdentity: simulateObs finished" << std::endl;
63 }
64 
65 // -----------------------------------------------------------------------------
66 
67 void ObsIdentity::print(std::ostream & os) const {
68  os << "ObsIdentity operator" << std::endl;
69 }
70 
71 // -----------------------------------------------------------------------------
72 
73 } // namespace ufo
GeoVaLs: geophysical values at locations.
void getAtLevel(std::vector< double > &, const std::string &, const int) const
Get GeoVaLs at a specified level.
Definition: GeoVaLs.cc:330
ObsIdentity(const ioda::ObsSpace &, const eckit::Configuration &)
Definition: ObsIdentity.cc:27
oops::Variables operatorVars_
Operator variables.
Definition: ObsIdentity.h:73
std::vector< int > operatorVarIndices_
Indices of operator variables.
Definition: ObsIdentity.h:76
oops::Variables requiredVars_
Required variables.
Definition: ObsIdentity.h:70
~ObsIdentity() override
Definition: ObsIdentity.cc:41
void simulateObs(const GeoVaLs &, ioda::ObsVector &, ObsDiagnostics &) const override
Obs Operator.
Definition: ObsIdentity.cc:47
void print(std::ostream &) const override
Definition: ObsIdentity.cc:67
Definition: RunCRTM.h:27
static ObsOperatorMaker< ObsIdentity > obsIdentityMaker_("Identity")
void getOperatorVariables(const eckit::Configuration &conf, const oops::Variables &simulatedVariables, oops::Variables &operatorVariables, std::vector< int > &operatorVariableIndices)