UFO
RunCRTM.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2017 UCAR
3  *
4  * This software is licensed under the terms of the Apache Licence Version 2.0
5  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6  */
7 
8 #ifndef MAINS_RUNCRTM_H_
9 #define MAINS_RUNCRTM_H_
10 
11 #include <string>
12 #include <vector>
13 
14 #include "eckit/config/LocalConfiguration.h"
15 
16 #include "oops/base/Observations.h"
17 #include "oops/base/ObsSpaces.h"
18 #include "oops/interface/ObsAuxControl.h"
19 #include "oops/interface/ObsOperator.h"
20 #include "oops/interface/ObsVector.h"
21 #include "oops/mpi/mpi.h"
22 #include "oops/runs/Application.h"
23 #include "oops/util/DateTime.h"
24 #include "oops/util/Duration.h"
25 #include "oops/util/Logger.h"
26 
27 namespace ufo {
28 
29 template <typename MODEL> class RunCRTM : public oops::Application {
30  typedef oops::GeoVaLs<MODEL> GeoVaLs_;
31  typedef oops::ObsAuxControl<MODEL> ObsAuxCtrl_;
32  typedef oops::ObsDiagnostics<MODEL> ObsDiags_;
33  typedef oops::Observations<MODEL> Observations_;
34  typedef oops::ObsOperator<MODEL> ObsOperator_;
35  typedef oops::ObsSpaces<MODEL> ObsSpaces_;
36  typedef oops::ObsVector<MODEL> ObsVector_;
37 
38  public:
39 // -----------------------------------------------------------------------------
40  explicit RunCRTM(const eckit::mpi::Comm & comm = oops::mpi::world()) : Application(comm) {}
41 // -----------------------------------------------------------------------------
42  virtual ~RunCRTM() {}
43 // -----------------------------------------------------------------------------
44  int execute(const eckit::Configuration & fullConfig) const {
45 // Setup observation window
46  const util::DateTime winbgn(fullConfig.getString("window begin"));
47  const util::Duration winlen(fullConfig.getString("window length"));
48  const util::DateTime winend(winbgn + winlen);
49 
50 // Setup observations
51  ObsSpaces_ obsdb(fullConfig, this->getComm(), winbgn, winend);
52 
53  oops::Variables diagvars;
54 
55  std::vector<eckit::LocalConfiguration> conf;
56  fullConfig.get("observations", conf);
57 
58  for (std::size_t jj = 0; jj < obsdb.size(); ++jj) {
59  eckit::LocalConfiguration obsopconf(conf[jj], "obs operator");
60  typename ObsOperator_::Parameters_ obsopparams;
61  obsopparams.validateAndDeserialize(obsopconf);
62  ObsOperator_ hop(obsdb[jj], obsopparams);
63 
64  const eckit::LocalConfiguration gconf(conf[jj], "geovals");
65  const GeoVaLs_ gval(gconf, obsdb[jj], hop.requiredVars());
66 
67  eckit::LocalConfiguration biasconf = conf[jj].getSubConfiguration("obs bias");
68  typename ObsAuxCtrl_::Parameters_ biasparams;
69  biasparams.validateAndDeserialize(biasconf);
70  const ObsAuxCtrl_ ybias(obsdb[jj], biasparams);
71 
72  ObsVector_ hofx(obsdb[jj]);
73  ObsVector_ bias(obsdb[jj]);
74  bias.zero();
75  ObsDiags_ diag(obsdb[jj], hop.locations(), diagvars);
76 
77  hop.simulateObs(gval, hofx, ybias, bias, diag);
78 
79  const double zz = hofx.rms();
80  const double xx = conf[jj].getDouble("rms ref");
81  const double tol = conf[jj].getDouble("tolerance");
82 // BOOST_CHECK_CLOSE(xx, zz, tol);
83  }
84 
85  return 0;
86  }
87 // -----------------------------------------------------------------------------
88  private:
89  std::string appname() const {
90  return "oops::RunCRTM<" + MODEL::name() + ">";
91  }
92 // -----------------------------------------------------------------------------
93 };
94 
95 } // namespace ufo
96 
97 #endif // MAINS_RUNCRTM_H_
int execute(const eckit::Configuration &fullConfig) const
Definition: RunCRTM.h:44
oops::Observations< MODEL > Observations_
Definition: RunCRTM.h:33
std::string appname() const
Definition: RunCRTM.h:89
oops::ObsOperator< MODEL > ObsOperator_
Definition: RunCRTM.h:34
oops::ObsVector< MODEL > ObsVector_
Definition: RunCRTM.h:36
oops::GeoVaLs< MODEL > GeoVaLs_
Definition: RunCRTM.h:30
RunCRTM(const eckit::mpi::Comm &comm=oops::mpi::world())
Definition: RunCRTM.h:40
oops::ObsAuxControl< MODEL > ObsAuxCtrl_
Definition: RunCRTM.h:31
oops::ObsSpaces< MODEL > ObsSpaces_
Definition: RunCRTM.h:35
oops::ObsDiagnostics< MODEL > ObsDiags_
Definition: RunCRTM.h:32
virtual ~RunCRTM()
Definition: RunCRTM.h:42
Definition: RunCRTM.h:27