12 #ifndef OOPS_BASE_STATE4D_H_
13 #define OOPS_BASE_STATE4D_H_
19 #include "eckit/config/LocalConfiguration.h"
23 #include "oops/util/Logger.h"
24 #include "oops/util/Printable.h"
29 template<
typename MODEL>
class State4D :
public util::Printable {
34 static const std::string
classname() {
return "State4D";}
40 void write(
const eckit::Configuration &)
const;
49 const std::vector<util::DateTime>
validTimes()
const;
56 void print(std::ostream &)
const;
63 template<
typename MODEL>
65 Log::trace() <<
"State4D config : " << config << std::endl;
67 if (config.has(
"states")) {
68 std::vector<eckit::LocalConfiguration> confs;
69 config.get(
"states", confs);
70 state4d_.reserve(confs.size());
71 for (
auto & conf : confs) {
72 state4d_.emplace_back(
State_(resol, conf));
76 state4d_.emplace_back(
State_(resol, config));
78 for (
size_t jj = 1; jj < state4d_.size(); ++jj) {
79 ASSERT(state4d_[jj].variables() == state4d_[0].variables());
81 Log::trace() <<
"State4D constructed." << std::endl;
86 template<
typename MODEL>
89 if (config.has(
"states")) {
90 std::vector<eckit::LocalConfiguration> confs;
91 config.get(
"states", confs);
92 ASSERT(state4d_.size() == confs.size());
93 for (
size_t jj = 0; jj < state4d_.size(); ++jj) {
94 if (config.has(
"member")) confs[jj].set(
"member", config.getInt(
"member"));
95 state4d_[jj].write(confs[jj]);
99 ASSERT(state4d_.size() == 1);
100 state4d_[0].write(config);
106 template<
typename MODEL>
108 std::vector<util::DateTime> times;
109 times.reserve(state4d_.size());
110 for (
const State_ & state : state4d_) {
111 times.push_back(state.validTime());
118 template<
typename MODEL>
120 Log::trace() <<
"State4D<MODEL>::zero starting" << std::endl;
121 for (
State_ & state : state4d_) {
124 Log::trace() <<
"State4D<MODEL>::zero done" << std::endl;
129 template<
typename MODEL>
131 Log::trace() <<
"State4D<MODEL>::accumul starting" << std::endl;
132 ASSERT(xx.
size() == state4d_.size());
133 for (
size_t jj = 0; jj < state4d_.size(); ++jj) {
134 state4d_[jj].accumul(zz, xx[jj]);
136 Log::trace() <<
"State4D<MODEL>::accumul done" << std::endl;
141 template <
typename MODEL>
143 for (
const State_ & state : state4d_) {
144 outs << state << std::endl;
Geometry class used in oops; subclass of interface class interface::Geometry.
Four dimensional state (vector of 3D States)
const Variables & variables() const
void accumul(const double &, const State4D &)
State4D(const Geometry_ &, const eckit::Configuration &)
The arguments define all states in 4D and their resolution.
std::vector< State_ > state4d_
Geometry< MODEL > Geometry_
State_ & operator[](const int ii)
void print(std::ostream &) const
size_t size() const
Get 3D model state.
static const std::string classname()
const std::vector< util::DateTime > validTimes() const
const State_ & operator[](const int ii) const
void write(const eckit::Configuration &) const
I/O.
Geometry_ geometry() const
State class used in oops; subclass of interface class interface::State.
The namespace for the main oops code.