7 #ifndef OOPS_BASE_OBSERVER_H_
8 #define OOPS_BASE_OBSERVER_H_
15 #include "eckit/config/LocalConfiguration.h"
30 #include "oops/util/Logger.h"
31 #include "oops/util/parameters/Parameter.h"
32 #include "oops/util/parameters/Parameters.h"
33 #include "oops/util/parameters/RequiredParameter.h"
37 template <
typename OBS>
45 oops::Parameter<std::vector<ObsFilterParametersWrapper<OBS>>>
obsFilters{
"obs filters", {},
this};
46 oops::Parameter<eckit::LocalConfiguration>
getValues{
47 "get values", eckit::LocalConfiguration(),
this};
49 "linear get values", eckit::LocalConfiguration(),
this};
55 template <
typename MODEL,
typename OBS>
78 ObsError_ &,
const eckit::Configuration &);
86 std::unique_ptr<ObsOperator_>
obsop_;
95 std::unique_ptr<eckit::LocalConfiguration>
iterconf_;
100 template <
typename MODEL,
typename OBS>
102 : parameters_(params), obspace_(obspace), obsop_(), locations_(),
103 biascoeff_(nullptr), filters_(), qcflags_(), initialized_(false)
105 Log::trace() <<
"Observer::Observer start" << std::endl;
110 Log::trace() <<
"Observer::Observer done" << std::endl;
115 template <
typename MODEL,
typename OBS>
116 std::shared_ptr<GetValuePost<MODEL, OBS>>
118 ObsError_ & R,
const eckit::Configuration & conf) {
119 Log::trace() <<
"Observer<MODEL, OBS>::initialize start" << std::endl;
121 iterconf_.reset(
new eckit::LocalConfiguration(conf));
122 biascoeff_ = &biascoeff;
124 obserr_.reset(
new ObsVector_(Rmat_->obserrors()));
127 const int iterfilt = iterconf_->getInt(
"iteration", 0);
128 filters_.reset(
new ObsFilters_(obspace_, parameters_.obsFilters,
129 qcflags_, *obserr_, iterfilt));
130 filters_->preProcess();
132 locations_.reset(
new Locations_(obsop_->locations()));
136 geovars += obsop_->requiredVars();
137 geovars += biascoeff_->requiredVars();
138 geovars += filters_->requiredVars();
141 getvals_.reset(
new GetValPost_(parameters_.getValues, geom, obspace_.windowStart(),
142 obspace_.windowEnd(), *locations_, geovars));
145 Log::trace() <<
"Observer<MODEL, OBS>::initialize done" << std::endl;
151 template <
typename MODEL,
typename OBS>
153 oops::Log::trace() <<
"Observer<MODEL, OBS>::finalize start" << std::endl;
154 ASSERT(initialized_);
157 std::unique_ptr<GeoVaLs_> geovals = getvals_->releaseGeoVaLs();
160 filters_->priorFilter(*geovals);
164 vars += filters_->requiredHdiagnostics();
165 vars += biascoeff_->requiredHdiagnostics();
166 ObsDiags_ ydiags(obspace_, *locations_, vars);
173 obsop_->simulateObs(*geovals, yobsim, *biascoeff_, ybias, ydiags);
176 filters_->postFilter(yobsim, ybias, ydiags);
179 Rmat_->update(*obserr_);
182 std::string siter =
"";
183 if (iterconf_->has(
"iteration")) siter = iterconf_->getString(
"iteration");
185 if (iterconf_->getBool(
"save qc",
true)) {
186 const std::string qcname =
"EffectiveQC" + siter;
187 qcflags_->save(qcname);
189 if (iterconf_->getBool(
"save hofx",
true)) {
190 const std::string obsname =
"hofx" + siter;
191 yobsim.
save(obsname);
193 if (iterconf_->getBool(
"save obs errors",
true)) {
194 const std::string errname =
"EffectiveError" + siter;
195 Rmat_->save(errname);
197 if (iterconf_->getBool(
"save obs bias",
true)) {
198 const std::string biasname =
"ObsBias" + siter;
199 ybias.
save(biasname);
202 Log::info() <<
"Observer::finalize QC = " << *qcflags_ << std::endl;
204 initialized_ =
false;
205 Log::trace() <<
"Observer<MODEL, OBS>::finalize done" << std::endl;
Geometry class used in oops; subclass of interface class interface::Geometry.
Fills GeoVaLs with requested variables at requested locations during model run.
Locations of observations for observation operator.
Auxiliary state related to observations, templated on <OBS>
ObsDataVector is a vector templated on data type, in the observation space.
Observation error covariance matrix of observations from a single ObsSpace.
Holds observation filters (usually QC) for one observation type.
MODEL-agnostic part of nonlinear observation (forward) operator. The full nonlinear observation opera...
const Variables & obsvariables() const
ObsVector class used in oops; subclass of interface class interface::ObsVector.
Computes observation operator, applying bias correction and QC filters.
Geometry< MODEL > Geometry_
ObsVector< OBS > ObsVector_
ObsDiagnostics< OBS > ObsDiags_
std::unique_ptr< eckit::LocalConfiguration > iterconf_
std::unique_ptr< ObsFilters_ > filters_
ObsDataVector< OBS, int > ObsDataInt_
std::shared_ptr< GetValPost_ > getvals_
std::shared_ptr< ObsDataInt_ > qcflags_
const ObsAuxCtrl_ * biascoeff_
ObsError< OBS > ObsError_
std::unique_ptr< ObsOperator_ > obsop_
const ObsSpace_ & obspace_
ObserverParameters< OBS > Parameters_
ObsAuxControl< OBS > ObsAuxCtrl_
ObsFilters< OBS > ObsFilters_
Locations< OBS > Locations_
std::unique_ptr< ObsVector_ > obserr_
Observer(const ObsSpace_ &, const Parameters_ &)
Initializes ObsOperators, Locations, and QC data.
std::shared_ptr< GetValPost_ > initialize(const Geometry_ &, const ObsAuxCtrl_ &, ObsError_ &, const eckit::Configuration &)
Initializes variables, obs bias, obs filters (could be different for different iterations.
ObsSpace< OBS > ObsSpace_
GetValuePost< MODEL, OBS > GetValPost_
std::unique_ptr< Locations_ > locations_
void finalize(ObsVector_ &)
Computes H(x) from the filled in GeoVaLs.
ObsOperator< OBS > ObsOperator_
oops::Parameter< std::vector< ObsFilterParametersWrapper< OBS > > > obsFilters
oops::Parameter< eckit::LocalConfiguration > linearGetValues
oops::RequiredParameter< ObsOperatorParameters_ > obsOperator
OBS::ObsOperator::Parameters_ ObsOperatorParameters_
oops::Parameter< eckit::LocalConfiguration > getValues
void save(const std::string &) const
Save this ObsVector as group name in the ObsSpace.
void zero()
Zero out this ObsVector.
The namespace for the main oops code.