11 #ifndef OOPS_BASE_INCREMENTENSEMBLE_H_
12 #define OOPS_BASE_INCREMENTENSEMBLE_H_
19 #include <boost/ptr_container/ptr_vector.hpp>
21 #include "eckit/config/LocalConfiguration.h"
29 #include "oops/util/DateTime.h"
30 #include "oops/util/Logger.h"
44 typedef typename boost::ptr_vector<LinearVariableChangeBase_>
ChvarVec_;
45 typedef typename ChvarVec_::const_reverse_iterator
ircst_;
50 const util::DateTime &,
const int rank);
58 const eckit::Configuration &);
60 void write(
const eckit::Configuration &)
const;
77 template<
typename MODEL>
79 const util::DateTime & tslot,
const int rank)
80 : vars_(vars), ensemblePerturbs_()
83 for (
int m = 0; m < rank; ++m) {
86 Log::trace() <<
"IncrementEnsemble:contructor done" << std::endl;
91 template<
typename MODEL>
95 : vars_(vars), ensemblePerturbs_()
101 std::unique_ptr<Increment_> inflationField;
102 if (conf.has(
"inflation field")) {
103 const eckit::LocalConfiguration inflationConfig(conf,
"inflation field");
104 inflationField.reset(
new Increment_(resol, vars, tslot));
105 inflationField->read(inflationConfig);
109 double inflationValue = conf.getDouble(
"inflation value", 1.0);
113 std::vector<eckit::LocalConfiguration> chvarconfs;
114 conf.get(
"variable changes", chvarconfs);
115 for (
const auto & conf : chvarconfs) {
125 for (
unsigned int ie = 0; ie < ensemble.
size(); ++ie) {
128 dx.
diff(ensemble[ie], bgmean);
131 if (conf.has(
"inflation field")) {
134 dx *= inflationValue;
138 for (
ircst_ it = chvars.rbegin(); it != chvars.rend(); ++it) {
139 dx = it->multiplyInverse(dx);
144 Log::trace() <<
"IncrementEnsemble:contructor done" << std::endl;
149 template<
typename MODEL>
151 const eckit::Configuration & config)
152 : vars_(vars), ensemblePerturbs_()
154 std::vector<eckit::LocalConfiguration> memberConfig;
155 config.get(
"members", memberConfig);
158 util::DateTime tslot = util::DateTime(config.getString(
"date"));
164 for (
size_t jj = 0; jj < memberConfig.size(); ++jj) {
166 dx.
read(memberConfig[jj]);
169 Log::trace() <<
"IncrementEnsemble:contructor (by reading increment ensemble) done" << std::endl;
174 template<
typename MODEL>
176 const eckit::Configuration & configBase,
177 const eckit::Configuration & configPert)
178 : vars_(vars), ensemblePerturbs_()
180 std::vector<eckit::LocalConfiguration> memberConfigBase;
181 configBase.get(
"members", memberConfigBase);
183 std::vector<eckit::LocalConfiguration> memberConfigPert;
184 configPert.get(
"members", memberConfigPert);
187 ASSERT(memberConfigBase.size() == memberConfigPert.size());
193 for (
size_t jj = 0; jj < memberConfigBase.size(); ++jj) {
194 State_ xBase(resol, memberConfigBase[jj]);
195 State_ xPert(resol, memberConfigPert[jj]);
197 dx.
diff(xBase, xPert);
200 Log::trace() <<
"IncrementEnsemble:contructor (by diffing state ensembles) done" << std::endl;
205 template<
typename MODEL>
208 eckit::LocalConfiguration outConfig(config);
209 for (
size_t ii=0; ii < size(); ++ii) {
210 outConfig.set(
"member", ii+1);
211 ensemblePerturbs_[ii].write(outConfig);
Geometry class used in oops; subclass of interface class interface::Geometry.
Increment< MODEL > Increment_
Increment_ & operator[](const int ii)
ChvarVec_::const_reverse_iterator ircst_
boost::ptr_vector< LinearVariableChangeBase_ > ChvarVec_
std::vector< Increment_ > ensemblePerturbs_
size_t size() const
Accessors.
void write(const eckit::Configuration &) const
StateEnsemble< MODEL > StateEnsemble_
IncrementEnsemble(const Geometry_ &resol, const Variables &vars, const util::DateTime &, const int rank)
Constructor.
const Increment_ & operator[](const int ii) const
LinearVariableChangeBase< MODEL > LinearVariableChangeBase_
Geometry< MODEL > Geometry_
const Variables & controlVariables() const
Control variables.
Increment class used in oops.
LinearVariableChange factory.
size_t size() const
Accessors.
State_ mean() const
calculate ensemble mean
State class used in oops; subclass of interface class interface::State.
void schur_product_with(const Increment &other)
Compute Schur product of this Increment with other, assign to this Increment.
void read(const eckit::Configuration &)
Read this Increment from file.
void diff(const State_ &state1, const State_ &state2)
Set this Increment to be difference between state1 and state2.
const util::DateTime validTime() const
Accessor to the time of this State.
The namespace for the main oops code.