10 #include "ioda/distribution/Accumulator.h"
11 #include "ioda/ObsDataVector.h"
12 #include "oops/util/missingValues.h"
57 std::vector<float> obslow(
nlocs), obshigh(
nlocs);
58 std::vector<float> bgdlow(
nlocs), bgdhigh(
nlocs);
67 std::vector<float> biaslow(
nlocs), biashigh(
nlocs);
72 for (
size_t iloc = 0; iloc <
nlocs; ++iloc) {
73 bgdlow[iloc] -= biaslow[iloc];
74 bgdhigh[iloc] -= biashigh[iloc];
82 std::unique_ptr<ioda::Accumulator<size_t>> countAccumulator =
83 obsdb.distribution()->createAccumulator<
size_t>();
86 enum {OMB_LOW, OMB_HIGH, NUM_OMBS};
87 std::unique_ptr<ioda::Accumulator<std::vector<double>>> totalsAccumulator =
88 obsdb.distribution()->createAccumulator<
double>(NUM_OMBS);
91 std::vector<float> omblow(
nlocs), ombhigh(
nlocs);
92 for (
size_t iloc = 0; iloc <
nlocs; ++iloc) {
98 omblow[iloc] = obslow[iloc] - bgdlow[iloc];
99 ombhigh[iloc] = obshigh[iloc] - bgdhigh[iloc];
100 totalsAccumulator->addTerm(iloc, OMB_LOW, omblow[iloc]);
101 totalsAccumulator->addTerm(iloc, OMB_HIGH, ombhigh[iloc]);
102 countAccumulator->addTerm(iloc, 1);
106 const std::size_t count = countAccumulator->computeResult();
107 const std::vector<double> totals = totalsAccumulator->computeResult();
110 const double MeanOmbLow = totals[OMB_LOW] / count;
111 const double MeanOmbHigh = totals[OMB_HIGH] / count;
114 for (
size_t iloc = 0; iloc <
nlocs; ++iloc) {
119 out[0][iloc] =
std::abs((omblow[iloc]-MeanOmbLow) - (ombhigh[iloc]-MeanOmbHigh));
BgdDepartureAnomalyParameters options_
std::vector< int > channels_
BgdDepartureAnomaly(const eckit::LocalConfiguration &=eckit::LocalConfiguration())
const ufo::Variables & requiredVariables() const
geovals required to compute the function
void compute(const ObsFilterData &, ioda::ObsDataVector< float > &) const
compute the result of the function
oops::RequiredParameter< int > obslow
Lower frequency channel number.
oops::Parameter< std::string > ObsBias
Name of the bias correction group used to apply correction to ObsValue.
oops::Parameter< std::string > testHofX
Name of the HofX group used to replace the default group (default is HofX)
oops::RequiredParameter< int > obshigh
Higher frequency channel number.
ObsFilterData provides access to all data related to an ObsFilter.
size_t nlocs() const
Returns the number of locations in the associated ObsSpace.
ioda::ObsSpace & obsspace() const
Returns reference to ObsSpace associated with ObsFilterData.
void get(const Variable &varname, std::vector< float > &values) const
Fills a std::vector with values of the specified variable.
integer function nlocs(this)
Return the number of observational locations in this Locations object.
static ObsFunctionMaker< BgdDepartureAnomaly > makerBgdDepartureAnomaly_("BgdDepartureAnomaly")
util::Duration abs(const util::Duration &duration)