UFO
BennartzScatIndex.cc
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2020 Met Office UK
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 "ioda/ObsDataVector.h"
9 #include "oops/util/missingValues.h"
11 #include "ufo/filters/Variable.h"
12 
13 namespace ufo {
14 
16 
17 BennartzScatIndex::BennartzScatIndex(const eckit::LocalConfiguration & conf)
18  : invars_() {
19  // Initialize options
20  options_.deserialize(conf);
21 
22  // Get channels for computing scattering index from options
23  channels_ = {options_.ch89.value(), options_.ch150.value()};
24 
25  // Include list of required data from ObsSpace
26  invars_ += Variable("brightness_temperature@ObsValue", channels_);
27  if (options_.applyBias.value().size()) {
28  invars_ += Variable("brightness_temperature@"+options_.applyBias.value(), channels_);
29  }
30  invars_ += Variable("sensor_zenith_angle@MetaData");
31 }
32 
33 // -----------------------------------------------------------------------------
34 
36  ioda::ObsDataVector<float> & out) const {
37  // Get dimension
38  const size_t nlocs = in.nlocs();
39  const float missing = util::missingValue(missing);
40 
41  ASSERT(out.nvars() == 1);
42 
43  // Get satellite zenith angle
44  std::vector<float> satzen(nlocs);
45  in.get(Variable("sensor_zenith_angle@MetaData"), satzen);
46 
47  // Get observation values for required channels
48  std::vector<float> bt89(nlocs), bt150(nlocs);
49  in.get(Variable("brightness_temperature@ObsValue", channels_)[0], bt89);
50  in.get(Variable("brightness_temperature@ObsValue", channels_)[1], bt150);
51 
52  // Apply bias correction if apply_bias is present in filter options
53  std::vector<float> bias89(nlocs), bias150(nlocs);
54  if (options_.applyBias.value().size()) {
55  in.get(Variable("brightness_temperature@"+options_.applyBias.value(), channels_)[0], bias89);
56  in.get(Variable("brightness_temperature@"+options_.applyBias.value(), channels_)[1], bias150);
57  // Apply bias correction
58  for (size_t iloc = 0; iloc < nlocs; ++iloc) {
59  bt89[iloc] -= bias89[iloc];
60  bt150[iloc] -= bias150[iloc];
61  }
62  }
63 
64  // Compute Bennartz scattering index
65  float Offset;
66  for (size_t iloc = 0; iloc < nlocs; ++iloc) {
67  Offset = options_.coeff1.value() + options_.coeff2.value()*satzen[iloc];
68  if (bt89[iloc] == missing || bt150[iloc] == missing || satzen[iloc] == missing) {
69  out[0][iloc] = missing;
70  } else {
71  out[0][iloc] = bt89[iloc] - bt150[iloc] - Offset;
72  }
73  }
74 }
75 
76 // -----------------------------------------------------------------------------
77 
79  return invars_;
80 }
81 
82 // -----------------------------------------------------------------------------
83 
84 } // namespace ufo
BennartzScatIndexParameters options_
void compute(const ObsFilterData &, ioda::ObsDataVector< float > &) const
compute the result of the function
std::vector< int > channels_
BennartzScatIndex(const eckit::LocalConfiguration &=eckit::LocalConfiguration())
const ufo::Variables & requiredVariables() const
geovals required to compute the function
oops::RequiredParameter< int > ch89
Channel number corresponding to 89 GHz (or nearby frequency depending on sensor channel specification...
oops::RequiredParameter< float > coeff1
First coefficient used to compute scattering index.
oops::Parameter< std::string > applyBias
Name of the bias correction group used to apply correction to ObsValue.
oops::RequiredParameter< float > coeff2
Second coefficient used to compute scattering index.
oops::RequiredParameter< int > ch150
Channel number corresponding to 150 GHz (or nearby frequency depending on sensor channel specificatio...
ObsFilterData provides access to all data related to an ObsFilter.
size_t nlocs() const
Returns the number of locations in the associated ObsSpace.
void get(const Variable &varname, std::vector< float > &values) const
Fills a std::vector with values of the specified variable.
constexpr int missing
Definition: QCflags.h:20
integer function nlocs(this)
Return the number of observational locations in this Locations object.
Definition: RunCRTM.h:27
static ObsFunctionMaker< BennartzScatIndex > makerBennartzScatIndex_("BennartzScatIndex")