11 #ifndef OOPS_BASE_WEIGHTEDMEAN_H_
12 #define OOPS_BASE_WEIGHTEDMEAN_H_
18 #include "eckit/exception/Exceptions.h"
26 #include "oops/util/DateTime.h"
27 #include "oops/util/Duration.h"
40 template <
typename MODEL,
typename FLDS>
46 const Geometry_ &,
const eckit::Configuration &);
52 void doInitialize(
const FLDS &,
const util::DateTime &,
const util::Duration &)
override;
56 std::unique_ptr<WeightingFct>
wfct_;
69 template <
typename MODEL,
typename FLDS>
71 const util::DateTime & vt,
72 const util::Duration & span,
74 const eckit::Configuration & config)
75 :
PostBase<FLDS>(vt-span/2, vt+span/2),
76 wfct_(), weights_(), avg_(0), sum_(0.0), linit_(false),
77 bgn_(vt-span/2), end_(vt+span/2), endleg_()
85 template <
typename MODEL,
typename FLDS>
88 ASSERT(std::abs(sum_ - 1.0) < 1.0e-8);
94 template <
typename MODEL,
typename FLDS>
96 const util::DateTime & end,
97 const util::Duration & tstep) {
98 const util::DateTime bgn(xx.validTime());
99 if (!linit_ && bgn <= end_ && end >= bgn_) {
100 weights_ = wfct_->setWeights(bgn_, end_, tstep);
108 template <
typename MODEL,
typename FLDS>
110 const util::DateTime now(xx.validTime());
111 if (now != endleg_ || now == end_) {
112 ASSERT(weights_.find(now) != weights_.end());
113 const double zz = weights_[now];
114 avg_->accumul(zz, xx);
116 Log::debug() <<
"WeightedMean: time = " << now
117 <<
", weight = " << zz <<
", sum = " << sum_ << std::endl;
Geometry class used in oops; subclass of interface class interface::Geometry.
Handles post-processing of model fields.
Compute time average of states or increments during model run.
std::unique_ptr< WeightingFct > wfct_
Geometry< MODEL > Geometry_
std::map< util::DateTime, double > weights_
const util::DateTime bgn_
void doInitialize(const FLDS &, const util::DateTime &, const util::Duration &) override
void doProcessing(const FLDS &) override
Actual processing.
Accumulator< MODEL, FLDS, FLDS > * avg_
const util::DateTime end_
WeightedMean(const Variables &, const util::DateTime &, const util::Duration &, const Geometry_ &, const eckit::Configuration &)
The namespace for the main oops code.