8 #ifndef SABER_OOPS_PARAMETERSBUMP_H_
9 #define SABER_OOPS_PARAMETERSBUMP_H_
17 #include "eckit/config/Configuration.h"
19 #include "oops/base/IncrementEnsemble.h"
20 #include "oops/base/Variables.h"
21 #include "oops/interface/State.h"
22 #include "oops/util/DateTime.h"
23 #include "oops/util/Duration.h"
24 #include "oops/util/Logger.h"
25 #include "oops/util/missingValues.h"
42 template<
typename MODEL>
48 typedef std::shared_ptr<oops::IncrementEnsemble<MODEL>>
EnsemblePtr_;
51 static const std::string
classname() {
return "oops::ParametersBUMP";}
53 const oops::Variables &,
54 const util::DateTime &,
55 const eckit::Configuration &,
67 const eckit::LocalConfiguration
conf_;
73 template<
typename MODEL>
75 const oops::Variables & vars,
76 const util::DateTime & time,
77 const eckit::Configuration & conf,
80 : resol_(resol), vars_(vars), time_(time), conf_(conf), ooBump_()
82 oops::Log::trace() <<
"ParametersBUMP<MODEL>::ParametersBUMP construction starting" << std::endl;
83 util::Timer timer(
classname(),
"ParametersBUMP");
86 eckit::LocalConfiguration BUMPConf(
conf_,
"bump");
90 if (ens1) ens1_ne = ens1->size();
91 BUMPConf.set(
"ens1_ne", ens1_ne);
92 if (!BUMPConf.has(
"ens1_nsub")) BUMPConf.set(
"ens1_nsub", 1);
96 if (ens2) ens2_ne = ens2->size();
97 BUMPConf.set(
"ens2_ne", ens2_ne);
98 if (!BUMPConf.has(
"ens2_nsub")) BUMPConf.set(
"ens2_nsub", 1);
101 const double msvalr = util::missingValue(msvalr);
102 BUMPConf.set(
"msvalr", msvalr);
105 oops::Log::info() <<
"Create BUMP" << std::endl;
110 oops::Log::info() <<
"--- Add members of ensemble 1" << std::endl;
111 for (
int ie = 0; ie < ens1_ne; ++ie) {
112 oops::Log::info() <<
" Member " << ie+1 <<
" / " << ens1_ne << std::endl;
113 ooBump_->addMember((*ens1)[ie].atlas(), ie, 1);
119 oops::Log::info() <<
"--- Add members of ensemble 2" << std::endl;
120 for (
int ie = 0; ie < ens2_ne; ++ie) {
121 oops::Log::info() <<
" Member " << ie+1 <<
" / " << ens2_ne << std::endl;
122 ooBump_->addMember((*ens2)[ie].atlas(), ie, 2);
127 oops::Log::info() <<
" Read data from files" << std::endl;
128 if (
conf_.has(
"input")) {
130 std::vector<eckit::LocalConfiguration> inputConfs;
131 conf_.get(
"input", inputConfs);
133 for (
const auto & inputConf : inputConfs) {
135 const util::DateTime date(inputConf.getString(
"date"));
142 std::string param = inputConf.getString(
"parameter");
143 ooBump_->setParameter(param, dx);
150 oops::Log::trace() <<
"ParametersBUMP:ParametersBUMP constructed" << std::endl;
155 template<
typename MODEL>
157 oops::Log::trace() <<
"ParametersBUMP<MODEL>::~ParametersBUMP destruction starting" << std::endl;
158 util::Timer timer(classname(),
"~ParametersBUMP");
159 oops::Log::trace() <<
"ParametersBUMP:~ParametersBUMP destructed" << std::endl;
164 template<
typename MODEL>
166 oops::Log::trace() <<
"ParametersBUMP::write starting" << std::endl;
167 util::Timer timer(classname(),
"write");
171 "-------------------------------------------------------------------" << std::endl;
172 oops::Log::info() <<
"--- Write parameters" << std::endl;
174 std::vector<eckit::LocalConfiguration> outputConfs;
175 conf_.get(
"output", outputConfs);
176 for (
const auto & outputConf : outputConfs) {
182 std::string param = outputConf.getString(
"parameter");
183 ooBump_->getParameter(param, dx);
186 const util::DateTime date(outputConf.getString(
"date"));
187 dx.write(outputConf);
188 oops::Log::test() <<
"Norm of " << param <<
" at " << date <<
": " << std::scientific
189 << std::setprecision(3) << dx.norm() << std::endl;
192 "-------------------------------------------------------------------" << std::endl;
193 oops::Log::trace() <<
"ParametersBUMP::write done" << std::endl;
200 #endif // SABER_OOPS_PARAMETERSBUMP_H_