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 
11 
12 #include "ioda/ObsSpace.h"
13 
14 #include "oops/util/abor1_cpp.h"
15 #include "oops/util/Logger.h"
16 
17 #include "ufo/utils/Constants.h"
18 
19 namespace ufo {
20 
22 
23 // -----------------------------------------------------------------------------
24 
25 ScanAngle::ScanAngle(const eckit::Configuration & conf, const std::vector<int> & jobs)
26  : PredictorBase(conf, jobs), order_(1) {
27  // get the order if it is provided in options
28  if (conf.has("predictor.options.order")) {
29  conf.get("predictor.options.order", order_);
30 
31  // override the predictor name for differentiable
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 std::size_t nlocs = odb.nlocs();
43 
44  // assure shape of out
45  ASSERT(out.nlocs() == nlocs);
46 
47  // retrieve the sensor view angle
48  std::vector<float> view_angle(nlocs, 0.0);
49  odb.get_db("MetaData", "sensor_view_angle", view_angle);
50 
51  const std::size_t njobs = jobs_.size();
52  for (std::size_t jl = 0; jl < nlocs; ++jl) {
53  for (std::size_t jb = 0; jb < njobs; ++jb) {
54  out[jl*njobs+jb] = pow(view_angle[jl] * Constants::deg2rad, order_);
55  }
56  }
57 }
58 
59 // -----------------------------------------------------------------------------
60 
61 } // namespace ufo
ufo::ScanAngle::order_
int order_
Definition: ScanAngle.h:38
ufo
Definition: RunCRTM.h:27
ufo::PredictorBase::name
std::string & name()
predictor name
Definition: PredictorBase.h:56
ufo::PredictorMaker
Definition: PredictorBase.h:89
ufo::makerFuncScanAngle_
static PredictorMaker< ScanAngle > makerFuncScanAngle_("scan_angle")
ufo::ObsDiagnostics
Definition: src/ufo/ObsDiagnostics.h:35
ufo::ScanAngle::ScanAngle
ScanAngle(const eckit::Configuration &, const std::vector< int > &)
Definition: ScanAngle.cc:25
ufo::PredictorBase
Base class for computing predictors.
Definition: PredictorBase.h:38
ScanAngle.h
ufo::Constants::deg2rad
static constexpr double deg2rad
Definition: Constants.h:21
ufo::GeoVaLs
GeoVaLs: geophysical values at locations.
Definition: src/ufo/GeoVaLs.h:39
ufo::ScanAngle::compute
void compute(const ioda::ObsSpace &, const GeoVaLs &, const ObsDiagnostics &, ioda::ObsVector &) const override
compute the predictor
Definition: ScanAngle.cc:38
ufo::PredictorBase::jobs_
const std::vector< int > jobs_
jobs(channels)
Definition: PredictorBase.h:60
Constants.h
conf
Definition: conf.py:1