12 #ifndef OOPS_RUNS_HOFX4D_H_
13 #define OOPS_RUNS_HOFX4D_H_
18 #include "eckit/config/LocalConfiguration.h"
19 #include "eckit/exception/Exceptions.h"
35 #include "oops/util/algorithms.h"
36 #include "oops/util/DateTime.h"
37 #include "oops/util/Duration.h"
38 #include "oops/util/Logger.h"
39 #include "oops/util/parameters/OptionalParameter.h"
40 #include "oops/util/parameters/Parameter.h"
41 #include "oops/util/parameters/Parameters.h"
42 #include "oops/util/parameters/RequiredParameter.h"
49 template <
typename OBS>
57 oops::RequiredParameter<eckit::LocalConfiguration>
obsSpace{
"obs space",
this};
63 oops::Parameter<eckit::LocalConfiguration>
obsError{
64 "obs error", eckit::LocalConfiguration(),
this};
67 oops::Parameter<ObsAuxControlParameters_>
obsBias{
"obs bias", {},
this};
73 template <
typename MODEL,
typename OBS>
83 oops::RequiredParameter<util::DateTime>
windowBegin{
"window begin",
this};
84 oops::RequiredParameter<util::Duration>
windowLength{
"window length",
this};
87 oops::RequiredParameter<util::Duration>
forecastLength{
"forecast length",
this};
90 oops::Parameter<std::vector<ObsTypeParameters<OBS>>>
observations{
"observations", {},
this};
93 oops::RequiredParameter<GeometryParameters_>
geometry{
"geometry",
this};
96 oops::RequiredParameter<ModelParameters_>
model{
"model",
this};
99 oops::RequiredParameter<eckit::LocalConfiguration>
initialCondition{
"initial condition",
this};
102 oops::Parameter<eckit::LocalConfiguration>
prints{
"prints", eckit::LocalConfiguration(),
this};
108 oops::Parameter<bool>
makeObs{
"make obs",
false,
this};
112 oops::Parameter<eckit::LocalConfiguration>
test{
"test", eckit::LocalConfiguration(),
this};
139 instantiateObsErrorFactory<OBS>();
140 instantiateObsFilterFactory<OBS>();
145 int execute(
const eckit::Configuration & fullConfig)
const {
148 params.validateAndDeserialize(fullConfig);
151 const util::Duration &winlen =
params.windowLength;
152 const util::DateTime &winbgn =
params.windowBegin;
153 const util::DateTime winend(winbgn + winlen);
154 Log::info() <<
"Observation window from " << winbgn <<
" to " << winend << std::endl;
160 const Model_ model(geometry,
params.model.value().modelParameters);
165 const util::Duration &flength =
params.forecastLength;
166 Log::test() <<
"Initial state: " << xx << std::endl;
170 Log::error() <<
"Observation window can not be outside of forecast window." << std::endl;
171 Log::error() <<
"Obs window: " << winbgn <<
" to " << winend << std::endl;
172 Log::error() <<
"Forecast runs from: " << xx.
validTime() <<
" for " << flength << std::endl;
173 throw eckit::BadValue(
"Observation window can not be outside of forecast window.");
183 const eckit::LocalConfiguration obsConfig(fullConfig,
"observations");
186 const std::vector<ObsAuxControlParameters_> obsauxParams = util::transformVector(
187 params.observations.value(),
188 [](
const ObsTypeParameters_ & obsTypeParams) { return obsTypeParams.obsBias.value(); });
189 ObsAux_ obsaux(obspaces, obsauxParams);
194 std::vector<ObserverParameters_> observerParams = util::transformVector(
195 params.observations.value(),
198 hofx.
initialize(geometry, obsaux, Rmat, post);
201 model.
forecast(xx, moderr, flength, post);
202 Log::test() <<
"Final state: " << xx << std::endl;
207 Log::test() <<
"H(x): " << std::endl << yobs <<
"End H(x)" << std::endl;
211 if (
params.obsPerturbations) {
213 Log::test() <<
"Perturbed H(x): " << std::endl << yobs <<
"End Perturbed H(x)" << std::endl;
const eckit::mpi::Comm & getComm() const
Geometry class used in oops; subclass of interface class interface::Geometry.
interface::Geometry< MODEL >::Parameters_ Parameters_
HofX4D(const eckit::mpi::Comm &comm=oops::mpi::world())
int execute(const eckit::Configuration &fullConfig) const
ObserverParameters< OBS > ObserverParameters_
Observations< OBS > Observations_
Observers< MODEL, OBS > Observers_
ModelAuxControl< MODEL > ModelAux_
ObsSpaces< OBS > ObsSpaces_
HofX4DParameters< MODEL, OBS > HofX4DParameters_
virtual ~HofX4D()=default
std::string appname() const
ObsTypeParameters< OBS > ObsTypeParameters_
Geometry< MODEL > Geometry_
ObsErrors< OBS > ObsErrors_
ObsAuxControl< OBS >::Parameters_ ObsAuxControlParameters_
ObsAuxControls< OBS > ObsAux_
Top-level options taken by the HofX4D application.
oops::Parameter< std::vector< ObsTypeParameters< OBS > > > observations
A list whose elements determine treatment of observations from individual observation spaces.
oops::RequiredParameter< eckit::LocalConfiguration > initialCondition
Initial state parameters.
oops::RequiredParameter< util::DateTime > windowBegin
oops::RequiredParameter< ModelParameters_ > model
Model parameters.
oops::Parameter< eckit::LocalConfiguration > prints
Options passed to the object writing out forecast fields.
Geometry< MODEL >::Parameters_ GeometryParameters_
oops::RequiredParameter< util::Duration > forecastLength
Forecast length.
oops::Parameter< bool > obsPerturbations
Whether to perturb the H(x) vector before saving.
oops::RequiredParameter< util::Duration > windowLength
ModelParametersWrapper< MODEL > ModelParameters_
oops::RequiredParameter< GeometryParameters_ > geometry
Geometry parameters.
oops::Parameter< bool > makeObs
Whether to save the H(x) vector as ObsValues.
Abstract nonlinear forecast model used by high level algorithms and applications.
void forecast(State_ &xx, const ModelAux_ &, const util::Duration &len, PostProcessor< State_ > &post) const
Run the forecast from state xx for len time, with post postprocessors Does not need to be implemented...
Contains a polymorphic parameter holding an instance of a subclass of ModelParametersBase.
ObsAuxControl_::Parameters_ Parameters_
Container for ObsErrors for all observation types that are used in DA.
void save() const
Save files.
Options controlling the processing of observations from a single obs space.
oops::RequiredParameter< eckit::LocalConfiguration > obsSpace
Options used to configure the observation space.
oops::Parameter< ObsAuxControlParameters_ > obsBias
Options used to configure bias correction.
ObsAuxControl< OBS >::Parameters_ ObsAuxControlParameters_
ObserverParameters< OBS > observer
Options used to configure the observation operator, observation filters and GetValues.
oops::Parameter< eckit::LocalConfiguration > obsError
Options used to configure the observation error model.
void save(const std::string &) const
Save/read observations values.
void perturb(const ObsErrors_ &)
Perturbations.
Computes observation operator (from GeoVaLs), applies bias correction and runs QC filters.
void initialize(const Geometry_ &, const ObsAuxCtrls_ &, ObsErrors_ &, PostProc_ &, const eckit::Configuration &=eckit::LocalConfiguration())
Initializes variables, obs bias, obs filters (could be different for different iterations.
void finalize(Observations_ &)
Computes H(x) from the filled in GeoVaLs.
Control model post processing.
void enrollProcessor(PostBase_ *pp)
State class used in oops; subclass of interface class interface::State.
Handles writing-out of forecast fields.
const util::DateTime validTime() const
Accessor to the time of this State.
const eckit::mpi::Comm & myself()
Default communicator with each MPI task by itself.
const eckit::mpi::Comm & world()
Default communicator with all MPI tasks (ie MPI_COMM_WORLD)
The namespace for the main oops code.