UFO
OrbitalAngle.cc
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2021 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 
8 #include <cmath>
9 #include <string>
10 #include "ioda/ObsSpace.h"
11 #include "oops/util/Logger.h"
13 #include "ufo/utils/Constants.h"
14 
15 namespace ufo {
16 
18 constexpr util::NamedEnumerator<FourierTermType>
20 
22 
23 // -----------------------------------------------------------------------------
24 
25 OrbitalAngle::OrbitalAngle(const Parameters_ & parameters, const oops::Variables & vars)
26  : PredictorBase(parameters, vars),
27  order_(parameters.order),
28  component_(parameters.component) {
29  // override the predictor name to distinguish between Orbital angle predictors of
30  // different orders as well as the two components, sine and cosine.
31  name() = name() + "_order_" + std::to_string(order_)+ "_" +
32  (component_ == FourierTermType::SIN ? "sin" : "cos");
33 }
34 
35 // -----------------------------------------------------------------------------
36 
37 void OrbitalAngle::compute(const ioda::ObsSpace & odb,
38  const GeoVaLs &,
39  const ObsDiagnostics &,
40  ioda::ObsVector & out) const {
41  const size_t nlocs = out.nlocs();
42  const size_t nvars = out.nvars();
43 
44  // retrieve the sensor orbital angle
45  std::vector<double> orbital_angle(nlocs, 0.0);
46  odb.get_db("MetaData", "satellite_orbital_angle", orbital_angle);
47 
48  switch (component_)
49  {
51  for (std::size_t jl = 0; jl < nlocs; ++jl) {
52  double cos_oa{ std::cos(orbital_angle[jl]*order_*Constants::deg2rad)};
53  for (std::size_t jb = 0; jb < nvars; ++jb) {
54  out[jl*nvars+jb] = cos_oa;
55  }
56  }
57  break;
59  for (std::size_t jl = 0; jl < nlocs; ++jl) {
60  double sin_oa{ std::sin(orbital_angle[jl]*order_*Constants::deg2rad)};
61  for (std::size_t jb = 0; jb < nvars; ++jb) {
62  out[jl*nvars+jb] = sin_oa;
63  }
64  }
65  break;
66  }
67 }
68 
69 // -----------------------------------------------------------------------------
70 
71 } // namespace ufo
GeoVaLs: geophysical values at locations.
OrbitalAngle(const Parameters_ &, const oops::Variables &)
Definition: OrbitalAngle.cc:25
void compute(const ioda::ObsSpace &, const GeoVaLs &, const ObsDiagnostics &, ioda::ObsVector &) const override
compute the predictor
Definition: OrbitalAngle.cc:37
FourierTermType component_
Definition: OrbitalAngle.h:90
Configuration parameters of the OrbitalAngle predictor.
Definition: OrbitalAngle.h:55
std::string & name()
predictor name
Definition: PredictorBase.h:80
integer function nlocs(this)
Return the number of observational locations in this Locations object.
Definition: RunCRTM.h:27
static PredictorMaker< OrbitalAngle > makerFuncOrbitalAngle_("orbital_angle")
static constexpr double deg2rad
Definition: Constants.h:21
static constexpr char enumTypeName[]
Definition: OrbitalAngle.h:32
static constexpr util::NamedEnumerator< FourierTermType > namedValues[]
Definition: OrbitalAngle.h:33