11 #ifndef OOPS_BASE_STATEENSEMBLE_H_ 12 #define OOPS_BASE_STATEENSEMBLE_H_ 17 #include <boost/ptr_container/ptr_vector.hpp> 18 #include <boost/scoped_ptr.hpp> 20 #include "eckit/config/LocalConfiguration.h" 27 #include "oops/util/DateTime.h" 28 #include "oops/util/dot_product.h" 29 #include "oops/util/Duration.h" 30 #include "oops/util/Logger.h" 44 typedef typename boost::ptr_vector<LinearVariableChangeBase_>
ChvarVec_;
45 typedef typename ChvarVec_::const_reverse_iterator
ircst_;
49 StateEnsemble(
const util::DateTime &,
const eckit::Configuration &);
55 unsigned int size()
const {
75 boost::scoped_ptr<const Geometry_>
resol_;
82 template<
typename MODEL>
84 const eckit::Configuration &
conf)
85 : config_(
conf), rank_(
conf.getInt(
"members")), validTime_(validTime),
86 vars_(
eckit::LocalConfiguration(
conf,
"variables")),
87 resol_(), ensemblePerturbs_()
89 Log::trace() <<
"StateEnsemble:contructor done" << std::endl;
94 template<
typename MODEL>
97 ASSERT(
xb.validTime() == validTime_);
102 if (config_.has(
"variable_changes")) {
103 std::vector<eckit::LocalConfiguration> chvarconfs;
104 config_.get(
"variable_changes", chvarconfs);
105 for (
const auto &
conf : chvarconfs) {
113 const double rr = 1.0/
static_cast<double>(rank_);
115 std::vector<eckit::LocalConfiguration> confs;
116 config_.get(
"state", confs);
117 ASSERT(confs.size() == rank_);
120 std::vector<State_> ensemble;
121 for (
unsigned int jm = 0;
jm < rank_; ++
jm) {
122 xread.read(confs[
jm]);
123 ASSERT(xread.validTime() == validTime_);
124 ensemble.push_back(xread);
130 const double rk = 1.0 / sqrt((static_cast<double>(rank_) - 1.0));
131 for (
unsigned int jm = 0;
jm < rank_; ++
jm) {
133 boost::scoped_ptr<Increment_> dx(
new Increment_(*resol_, vars_, validTime_));
134 dx->diff(ensemble[
jm], bgmean);
139 for (
ircst_ it = chvars.rbegin(); it != chvars.rend(); ++it) {
140 Increment_ dxchvarout = it->multiplyInverse(*dx);
145 ensemblePerturbs_.push_back(dxunbalptr);
148 ensemblePerturbs_[
jm] *= rk;
155 #endif // OOPS_BASE_STATEENSEMBLE_H_
const util::DateTime validTime_
boost::ptr_vector< Increment_ > ensemblePerturbs_
unsigned int size() const
Accessors.
Increment_ & operator[](const int ii)
Encapsulates the model state.
virtual ~StateEnsemble()
Destructor.
The namespace for the main oops code.
void accumul(const double &zz, const FLDS &xx)
boost::ptr_vector< LinearVariableChangeBase_ > ChvarVec_
Increment< MODEL > Increment_
const Increment_ & operator[](const int ii) const
LinearVariableChangeFactory Factory.
Geometry< MODEL > Geometry_
Base class for generic variable transform.
boost::scoped_ptr< const Geometry_ > resol_
StateEnsemble(const util::DateTime &, const eckit::Configuration &)
Constructor.
const eckit::LocalConfiguration config_
Increment Class: Difference between two states.
void linearize(const State_ &, const State_ &, const Geometry_ &)
ChvarVec_::const_reverse_iterator ircst_
LinearVariableChangeBase< MODEL > LinearVariableChangeBase_
const Variables & controlVariables() const