UFO
ObsBackgroundErrorIdentity.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 
12 #include "ioda/ObsVector.h"
13 
14 #include "oops/base/Variables.h"
15 #include "oops/util/DateTime.h"
16 #include "oops/util/Duration.h"
17 #include "oops/util/Logger.h"
18 
20 #include "ufo/GeoVaLs.h"
21 #include "ufo/Locations.h"
22 #include "ufo/ObsDiagnostics.h"
23 #include "ufo/ObsOperatorBase.h"
24 
25 namespace ufo {
26 
27 static ObsOperatorMaker<ObsBackgroundErrorIdentity> maker("BackgroundErrorIdentity");
28 
30  const Parameters_ & parameters)
31  : ObsOperatorBase(odb),
32  odb_(odb), parameters_(parameters)
33 {
34  oops::Log::trace() << "ObsBackgroundErrorIdentity constructor entered" << std::endl;
35 
36  // simulateObs() may be asked to interpolate the background errors of any simulated variables.
37  // We need to assume the worst, i.e. that we'll need to interpolate all of them.
38  const oops::Variables &obsvars = odb.obsvariables();
39  for (size_t ivar = 0; ivar < obsvars.size(); ++ivar)
40  requiredVars_.push_back(obsvars[ivar] + "_background_error");
41 
42  oops::Log::trace() << "ObsBackgroundErrorIdentity created" << std::endl;
43 }
44 
46  oops::Log::trace() << "ObsBackgroundErrorIdentity destructed" << std::endl;
47 }
48 
49 void ObsBackgroundErrorIdentity::simulateObs(const GeoVaLs & geovals, ioda::ObsVector & hofx,
50  ObsDiagnostics & ydiags) const {
51  oops::Log::trace() << "ObsBackgroundErrorIdentity: simulateObs entered" << std::endl;
52 
53  oops::Variables variables;
54  if (parameters_.variables.value() != boost::none)
55  for (const Variable &variable : *parameters_.variables.value())
56  variables += variable.toOopsVariables();
57  else
58  variables = odb_.obsvariables();
59 
60  ufo_backgrounderroridentity_fillobsdiags_f90(geovals.toFortran(), hofx.nlocs(), variables,
61  ydiags.toFortran());
62 
63  oops::Log::trace() << "ObsBackgroundErrorIdentity: simulateObs exit" << std::endl;
64 }
65 
66 const oops::Variables & ObsBackgroundErrorIdentity::requiredVars() const {
67  return requiredVars_;
68 }
69 
71  // This operator doesn't simulate any variables -- it only produces diagnostics.
72  return oops::Variables();
73 }
74 
75 void ObsBackgroundErrorIdentity::print(std::ostream & os) const {
76  os << "ObsBackgroundErrorIdentity: config = " << parameters_ << std::endl;
77 }
78 
79 } // namespace ufo
GeoVaLs: geophysical values at locations.
const oops::Variables & requiredVars() const override
Operator input required from Model.
void print(std::ostream &) const override
ObsBackgroundErrorIdentity(const ioda::ObsSpace &, const Parameters_ &)
void simulateObs(const GeoVaLs &, ioda::ObsVector &, ObsDiagnostics &) const override
Obs Operator.
oops::Variables simulatedVars() const override
List of variables simulated by this operator.
Options controlling the ObsBackgroundErrorIdentity observation operator.
oops::OptionalParameter< std::vector< Variable > > variables
Definition: RunCRTM.h:27
static ObsOperatorMaker< ObsBackgroundErrorIdentity > maker("BackgroundErrorIdentity")
void ufo_backgrounderroridentity_fillobsdiags_f90(const F90goms &geovals, const int &nlocs, const oops::Variables &obsvars, const F90goms &obsdiags)