UFO
ScanAngle.cc
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2020 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 <string>
9 #include <vector>
10 
12 
13 #include "ioda/ObsSpace.h"
14 
15 #include "oops/util/abor1_cpp.h"
16 #include "oops/util/Logger.h"
17 
18 #include "ufo/utils/Constants.h"
19 
20 namespace ufo {
21 
23 
24 // -----------------------------------------------------------------------------
25 
26 ScanAngle::ScanAngle(const Parameters_ & parameters, const oops::Variables & vars)
27  : PredictorBase(parameters, vars),
28  order_(parameters.order.value().value_or(1)),
29  var_name_(parameters.varName) {
30  if (parameters.order.value() != boost::none) {
31  // override the predictor name to distinguish between scan_angle predictors of different orders
32  name() = name() + "_order_" + std::to_string(order_);
33  }
34 }
35 
36 // -----------------------------------------------------------------------------
37 
38 void ScanAngle::compute(const ioda::ObsSpace & odb,
39  const GeoVaLs &,
40  const ObsDiagnostics &,
41  ioda::ObsVector & out) const {
42  const size_t nlocs = out.nlocs();
43  const size_t nvars = out.nvars();
44 
45  // retrieve the sensor view angle
46  std::vector<float> view_angle(nlocs, 0.0);
47  odb.get_db("MetaData", var_name_, view_angle);
48 
49  for (std::size_t jloc = 0; jloc < nlocs; ++jloc) {
50  for (std::size_t jvar = 0; jvar < nvars; ++jvar) {
51  out[jloc*nvars+jvar] = pow(view_angle[jloc] * Constants::deg2rad, order_);
52  }
53  }
54 }
55 
56 // -----------------------------------------------------------------------------
57 
58 } // namespace ufo
GeoVaLs: geophysical values at locations.
std::string & name()
predictor name
Definition: PredictorBase.h:80
ScanAngle(const Parameters_ &, const oops::Variables &)
Definition: ScanAngle.cc:26
void compute(const ioda::ObsSpace &, const GeoVaLs &, const ObsDiagnostics &, ioda::ObsVector &) const override
compute the predictor
Definition: ScanAngle.cc:38
std::string var_name_
Definition: ScanAngle.h:63
Configuration parameters of the ScanAngle predictor.
Definition: ScanAngle.h:32
oops::OptionalParameter< int > order
Definition: ScanAngle.h:40
integer function nlocs(this)
Return the number of observational locations in this Locations object.
Definition: RunCRTM.h:27
static PredictorMaker< ScanAngle > makerFuncScanAngle_("scan_angle")
static constexpr double deg2rad
Definition: Constants.h:21