11 #ifndef OOPS_GENERIC_OBSERRORBASE_H_
12 #define OOPS_GENERIC_OBSERRORBASE_H_
18 #include <boost/noncopyable.hpp>
19 #include "eckit/config/Configuration.h"
23 #include "oops/util/abor1_cpp.h"
24 #include "oops/util/Logger.h"
25 #include "oops/util/Printable.h"
38 template<
typename OBS>
40 private boost::noncopyable {
57 virtual void save(
const std::string &
name)
const = 0;
73 virtual void print(std::ostream &)
const = 0;
79 template <
typename OBS>
84 static std::unique_ptr<ObsErrorBase_>
create(
const eckit::Configuration &,
90 virtual std::unique_ptr<ObsErrorBase_>
make(
const eckit::Configuration &,
const ObsSpace_ &) = 0;
91 static std::map < std::string, ObsErrorFactory<OBS> * > &
getMakers() {
92 static std::map < std::string, ObsErrorFactory<OBS> * > makers_;
101 template<
class OBS,
class T>
105 std::unique_ptr<ObsErrorBase_>
make(
const eckit::Configuration & conf,
107 {
return std::make_unique<T>(conf,
obs); }
114 template <
typename OBS>
116 if (getMakers().find(
name) != getMakers().end()) {
117 throw std::runtime_error(
name +
" already registered in obs error factory.");
119 getMakers()[
name] =
this;
124 template <
typename OBS>
125 std::unique_ptr<ObsErrorBase<OBS>>
127 Log::trace() <<
"ObsErrorFactory<OBS>::create starting" << std::endl;
128 const std::string
id = conf.getString(
"covariance model",
"diagonal");
129 Log::trace() <<
"ObsError matrix type is: " <<
id << std::endl;
130 typename std::map<std::string, ObsErrorFactory<OBS>*>::iterator
131 jerr = getMakers().find(
id);
132 if (jerr == getMakers().end()) {
133 throw std::runtime_error(
id +
" does not exist in obs error factory.");
135 std::unique_ptr<ObsErrorBase<OBS>> ptr(jerr->second->make(conf,
obs));
136 Log::trace() <<
"ObsErrorFactory<OBS>::create done" << std::endl;
Base class for generic implementations of observation error covariance matrices.
virtual void update(const ObsVector_ &stddev)=0
Set the diagonal of the covariance matrix to stddev squared.
virtual void multiply(ObsVector_ &dy) const =0
Multiply a Departure dy by .
ObsVector< OBS > ObsVector_
virtual void print(std::ostream &) const =0
virtual double getRMSE() const =0
Get mean error for Jo table.
ObsSpace< OBS > ObsSpace_
virtual ObsVector_ obserrors() const =0
virtual ~ObsErrorBase()=default
virtual void randomize(ObsVector_ &dy) const =0
Generate random perturbation in dy.
virtual void save(const std::string &name) const =0
Save obs errors to the group name.
virtual void inverseMultiply(ObsVector_ &dy) const =0
Multiply a Departure dy by .
virtual ObsVector_ inverseVariance() const =0
Return the vector of inverse obs error variances.
A factory creating instances of concrete subclasses of ObsErrorBase.
virtual std::unique_ptr< ObsErrorBase_ > make(const eckit::Configuration &, const ObsSpace_ &)=0
virtual ~ObsErrorFactory()=default
ObsErrorBase< OBS > ObsErrorBase_
ObsSpace< OBS > ObsSpace_
static std::unique_ptr< ObsErrorBase_ > create(const eckit::Configuration &, const ObsSpace_ &)
static std::map< std::string, ObsErrorFactory< OBS > * > & getMakers()
ObsErrorFactory(const std::string &)
A subclass of ObsErrorFactory able to create instances of T (a concrete subclass of ObsErrorBase<OBS>...
std::unique_ptr< ObsErrorBase_ > make(const eckit::Configuration &conf, const ObsSpace_ &obs) override
ObsSpace< OBS > ObsSpace_
ObsErrorBase< OBS > ObsErrorBase_
ObsErrorMaker(const std::string &name)
The namespace for the main oops code.