UFO
ObsOperator.cc
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2021 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 #include <vector>
9 
10 #include "ufo/ObsOperator.h"
11 
12 #include "eckit/config/Configuration.h"
13 
14 #include "ioda/ObsSpace.h"
15 #include "ioda/ObsVector.h"
16 
17 #include "oops/base/Variables.h"
18 
19 #include "ufo/GeoVaLs.h"
20 #include "ufo/Locations.h"
21 #include "ufo/ObsBias.h"
22 #include "ufo/ObsBiasOperator.h"
23 #include "ufo/ObsDiagnostics.h"
24 #include "ufo/ObsOperatorBase.h"
25 
26 namespace ufo {
27 
28 // -----------------------------------------------------------------------------
29 
30 ObsOperator::ObsOperator(ioda::ObsSpace & os, const Parameters_ & params)
31  : oper_(ObsOperatorFactory::create(os, params.operatorParameters)), odb_(os)
32 {
33  // We use += rather than = to make sure the Variables objects contain no duplicate entries
34  // and the variables are sorted alphabetically.
35  oops::Variables operatorVars;
36  operatorVars += oper_->simulatedVars();
37  oops::Variables obsSpaceVars;
38  obsSpaceVars += os.obsvariables();
39  if (!(operatorVars == obsSpaceVars))
40  throw eckit::UserError("The list of variables simulated by the obs operator differs from "
41  "the list of simulated variables in the obs space",
42  Here());
43 }
44 
45 // -----------------------------------------------------------------------------
46 
47 void ObsOperator::simulateObs(const GeoVaLs & gvals, ioda::ObsVector & yy,
48  const ObsBias & biascoeff, ioda::ObsVector & ybias,
49  ObsDiagnostics & ydiags) const {
50  oper_->simulateObs(gvals, yy, ydiags);
51  if (biascoeff) {
52  ObsBiasOperator biasoper(odb_);
53  biasoper.computeObsBias(gvals, ybias, biascoeff, ydiags);
54  // update H(x) with bias correction
55  yy += ybias;
56  }
57 }
58 
59 // -----------------------------------------------------------------------------
60 
61 const oops::Variables & ObsOperator::requiredVars() const {
62  return oper_->requiredVars();
63 }
64 
65 // -----------------------------------------------------------------------------
66 
67 std::unique_ptr<Locations> ObsOperator::locations() const {
68  return oper_->locations();
69 }
70 
71 // -----------------------------------------------------------------------------
72 
73 void ObsOperator::print(std::ostream & os) const {
74  os << *oper_;
75 }
76 
77 // -----------------------------------------------------------------------------
78 
79 } // namespace ufo
GeoVaLs: geophysical values at locations.
Application of bias correction.
void computeObsBias(const GeoVaLs &, ioda::ObsVector &, const ObsBias &, ObsDiagnostics &) const
Compute bias correction.
Obs Operator Factory.
ioda::ObsSpace & odb_
Definition: ObsOperator.h:62
std::unique_ptr< ObsOperatorBase > oper_
Definition: ObsOperator.h:61
std::unique_ptr< Locations > locations() const
Operator locations.
Definition: ObsOperator.cc:67
void simulateObs(const GeoVaLs &, ioda::ObsVector &, const ObsBias &, ioda::ObsVector &, ObsDiagnostics &) const
Obs Operator.
Definition: ObsOperator.cc:47
ObsOperator(ioda::ObsSpace &, const Parameters_ &)
Definition: ObsOperator.cc:30
void print(std::ostream &) const
Definition: ObsOperator.cc:73
const oops::Variables & requiredVars() const
Operator input required from Model.
Definition: ObsOperator.cc:61
Contains a polymorphic parameter holding an instance of a subclass of ObsOperatorParametersBase.
Definition: RunCRTM.h:27