8 #ifndef OOPS_BASE_OBSAUXCONTROLS_H_
9 #define OOPS_BASE_OBSAUXCONTROLS_H_
18 #include "oops/util/ConfigFunctions.h"
19 #include "oops/util/Logger.h"
20 #include "oops/util/parameters/Parameters.h"
21 #include "oops/util/Printable.h"
29 template <
typename OBS>
36 static const std::string
classname() {
return "oops::ObsAuxControls";}
49 void read(
const eckit::Configuration &);
50 void write(
const eckit::Configuration &)
const;
56 void print(std::ostream &)
const;
57 std::vector<std::unique_ptr<ObsAuxControl_> >
auxs_;
62 template<
typename OBS>
64 const std::vector<Parameters_> & params)
67 ASSERT(odb.
size() == params.size());
68 for (std::size_t jobs = 0; jobs < params.size(); ++jobs) {
70 std::unique_ptr<ObsAuxControl_>(
new ObsAuxControl_(odb[jobs], params[jobs])));
76 template<
typename OBS>
81 validateAndDeserialize<
Parameters_>(
util::vectoriseAndFilter(conf,
"obs bias")))
86 template<
typename OBS>
90 Log::trace() <<
"ObsAuxControls<OBS>::ObsAuxControls copy starting" << std::endl;
91 for (std::size_t jobs = 0; jobs < other.
size(); ++jobs) {
94 Log::trace() <<
"ObsAuxControls<OBS>::ObsAuxControls copy done" << std::endl;
99 template<
typename OBS>
101 Log::trace() <<
"ObsAuxControls<OBS>::~ObsAuxControls starting" << std::endl;
102 for (std::size_t jobs = 0; jobs < auxs_.size(); ++jobs) auxs_[jobs].reset();
103 Log::trace() <<
"ObsAuxControls<OBS>::~ObsAuxControls done" << std::endl;
108 template<
typename OBS>
110 Log::trace() <<
"ObsAuxControls<OBS>::read starting" << std::endl;
111 std::vector<eckit::LocalConfiguration> obsconfs = conf.getSubConfigurations(
"observations");
112 ASSERT(obsconfs.size() == auxs_.size());
113 for (std::size_t jobs = 0; jobs < auxs_.size(); ++jobs) {
114 eckit::LocalConfiguration obsauxconf = obsconfs[jobs].getSubConfiguration(
"obs bias");
116 params.validateAndDeserialize(obsauxconf);
117 auxs_[jobs]->read(params);
119 Log::trace() <<
"ObsAuxControls<OBS>::read done" << std::endl;
124 template<
typename OBS>
126 Log::trace() <<
"ObsAuxControls<OBS>::write starting" << std::endl;
127 std::vector<eckit::LocalConfiguration> obsconfs = conf.getSubConfigurations(
"observations");
128 ASSERT(obsconfs.size() == auxs_.size());
129 for (std::size_t jobs = 0; jobs < auxs_.size(); ++jobs) {
130 eckit::LocalConfiguration obsauxconf = obsconfs[jobs].getSubConfiguration(
"obs bias");
132 params.validateAndDeserialize(obsauxconf);
133 auxs_[jobs]->write(params);
135 Log::trace() <<
"ObsAuxControls<OBS>::write done" << std::endl;
140 template<
typename OBS>
142 Log::trace() <<
"ObsAuxControls<OBS>::norm starting" << std::endl;
143 double zz =
static_cast<double>(0.0);
146 for (std::size_t jobs = 0; jobs < auxs_.size(); ++jobs) {
147 norm = auxs_[jobs]->norm();
153 Log::trace() <<
"ObsAuxControls<OBS>::norm done" << std::endl;
154 return std::sqrt(zz/ii);
159 template<
typename OBS>
161 for (
const auto & aux : auxs_) {
162 os << *aux << std::endl;
Auxiliary state related to observations, templated on <OBS>
ObsAuxControl_::Parameters_ Parameters_
Holds a vector of ObsAuxControl.
void read(const eckit::Configuration &)
I/O and diagnostics.
std::vector< std::unique_ptr< ObsAuxControl_ > > auxs_
const ObsAuxControl_ & operator[](const std::size_t ii) const
ObsSpaces< OBS > ObsSpaces_
void write(const eckit::Configuration &) const
void print(std::ostream &) const
ObsAuxControl_::Parameters_ Parameters_
ObsAuxControls(const ObsSpaces_ &, const eckit::Configuration &)
ObsAuxControl< OBS > ObsAuxControl_
std::size_t size() const
Access.
ObsAuxControls & operator=(const ObsAuxControls &)
static const std::string classname()
ObsAuxControl_ & operator[](const std::size_t ii)
std::size_t size() const
Access.
The namespace for the main oops code.