UFO
Emissivity.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 "ufo/GeoVaLs.h"
16 #include "ufo/ObsDiagnostics.h"
17 
18 #include "oops/base/Variables.h"
19 #include "oops/util/abor1_cpp.h"
20 #include "oops/util/Logger.h"
21 
22 namespace ufo {
23 
25 
26 // -----------------------------------------------------------------------------
27 
28 Emissivity::Emissivity(const Parameters_ & parameters, const oops::Variables & vars)
29  : PredictorBase(parameters, vars) {
30  // required variables
31  geovars_ += oops::Variables({"water_area_fraction"});
32  if (vars.size() > 0) {
33  hdiags_ += oops::Variables({"brightness_temperature_jacobian_surface_emissivity"},
34  vars.channels());
35  } else {
36  oops::Log::error() << "Channels size is ZERO !" << std::endl;
37  ABORT("Channels size is ZERO !");
38  }
39 }
40 
41 // -----------------------------------------------------------------------------
42 
43 void Emissivity::compute(const ioda::ObsSpace & odb,
44  const GeoVaLs & geovals,
45  const ObsDiagnostics & ydiags,
46  ioda::ObsVector & out) const {
47  const std::size_t nvars = out.nvars();
48  const std::size_t nlocs = out.nlocs();
49 
50  std::vector<float> pred(nlocs, 0.0);
51  std::vector<float> h2o_frac(nlocs, 0.0);
52  geovals.get(h2o_frac, "water_area_fraction");
53  std::string hdiags;
54  out.zero();
55  for (std::size_t jvar = 0; jvar < nvars; ++jvar) {
56  hdiags = "brightness_temperature_jacobian_surface_emissivity_" +
57  std::to_string(vars_.channels()[jvar]);
58  ydiags.get(pred, hdiags);
59  for (std::size_t jloc = 0; jloc < nlocs; ++jloc) {
60  if (h2o_frac[jloc] < 0.99 && std::fabs(pred[jloc]) > 0.001) {
61  out[jloc*nvars+jvar] = pred[jloc];
62  }
63  }
64  }
65 }
66 
67 // -----------------------------------------------------------------------------
68 
69 } // namespace ufo
Emissivity(const Parameters_ &, const oops::Variables &)
Definition: Emissivity.cc:28
void compute(const ioda::ObsSpace &, const GeoVaLs &, const ObsDiagnostics &, ioda::ObsVector &) const override
compute the predictor
Definition: Emissivity.cc:43
GeoVaLs: geophysical values at locations.
void get(std::vector< double > &, const std::string &var) const
Get 2D GeoVaLs for variable var (fails for 3D GeoVaLs)
Definition: GeoVaLs.cc:359
void get(std::vector< float > &, const std::string &) const
oops::Variables vars_
variables that will be bias-corrected using this predictor
Definition: PredictorBase.h:84
oops::Variables geovars_
required GeoVaLs
Definition: PredictorBase.h:85
oops::Variables hdiags_
required ObsDiagnostics
Definition: PredictorBase.h:86
integer function nlocs(this)
Return the number of observational locations in this Locations object.
Definition: RunCRTM.h:27
static PredictorMaker< Emissivity > makerFuncEmissivity_("emissivity")