UFO
ObsBackgroundErrorVertInterp.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<ObsBackgroundErrorVertInterp> maker("BackgroundErrorVertInterp");
28 
30  const Parameters_ & parameters)
31  : ObsOperatorBase(odb),
32  odb_(odb), parameters_(parameters)
33 {
34  oops::Log::trace() << "ObsBackgroundErrorVertInterp constructor entered" << std::endl;
35 
37  // simulateObs() may be asked to interpolate the background errors of any simulated variables.
38  // We need to assume the worst, i.e. that we'll need to interpolate all of them.
39  const oops::Variables &obsvars = odb.obsvariables();
40  for (size_t ivar = 0; ivar < obsvars.size(); ++ivar)
41  requiredVars_.push_back(obsvars[ivar] + "_background_error");
42 
43  oops::Log::trace() << "ObsBackgroundErrorVertInterp created" << std::endl;
44 }
45 
47  oops::Log::trace() << "ObsBackgroundErrorVertInterp destructed" << std::endl;
48 }
49 
50 void ObsBackgroundErrorVertInterp::simulateObs(const GeoVaLs & geovals, ioda::ObsVector & hofx,
51  ObsDiagnostics & ydiags) const {
52  oops::Log::trace() << "ObsBackgroundErrorVertInterp: simulateObs entered" << std::endl;
53 
54  const std::string &obsVerticalCoordinate = parameters_.observationVerticalCoordinate;
55  const std::string &verticalCoordinate = parameters_.verticalCoordinate;
56 
57  oops::Variables variables;
58  if (parameters_.variables.value() != boost::none)
59  for (const Variable &variable : *parameters_.variables.value())
60  variables += variable.toOopsVariables();
61  else
62  variables = odb_.obsvariables();
63 
64  ufo_backgrounderrorvertinterp_fillobsdiags_f90(obsVerticalCoordinate.size(),
65  obsVerticalCoordinate.c_str(),
66  verticalCoordinate.size(),
67  verticalCoordinate.c_str(),
68  geovals.toFortran(), odb_, hofx.nlocs(),
69  variables,
70  ydiags.toFortran());
71 
72  oops::Log::trace() << "ObsBackgroundErrorVertInterp: simulateObs exit" << std::endl;
73 }
74 
75 const oops::Variables & ObsBackgroundErrorVertInterp::requiredVars() const {
76  return requiredVars_;
77 }
78 
80  // This operator doesn't simulate any variables -- it only produces diagnostics.
81  return oops::Variables();
82 }
83 
84 void ObsBackgroundErrorVertInterp::print(std::ostream & os) const {
85  os << "ObsBackgroundErrorVertInterp: config = " << parameters_ << std::endl;
86 }
87 
88 } // namespace ufo
GeoVaLs: geophysical values at locations.
void print(std::ostream &) const override
const oops::Variables & requiredVars() const override
Operator input required from Model.
oops::Variables simulatedVars() const override
List of variables simulated by this operator.
void simulateObs(const GeoVaLs &, ioda::ObsVector &, ObsDiagnostics &) const override
Obs Operator.
ObsBackgroundErrorVertInterp(const ioda::ObsSpace &, const Parameters_ &)
Options controlling the ObsBackgroundErrorVertInterp observation operator.
oops::RequiredParameter< std::string > verticalCoordinate
Name of the GeoVaL storing the interpolation levels of background errors.
oops::RequiredParameter< std::string > observationVerticalCoordinate
oops::OptionalParameter< std::vector< Variable > > variables
Definition: RunCRTM.h:27
static ObsOperatorMaker< ObsBackgroundErrorIdentity > maker("BackgroundErrorIdentity")
void ufo_backgrounderrorvertinterp_fillobsdiags_f90(const int &len_obs_vcoord, const char *obs_vcoord, const int &len_vcoord, const char *vcoord, const F90goms &geovals, const ioda::ObsSpace &obsspace, const int &nlocs, const oops::Variables &obsvars, const F90goms &obsdiags)