IODA
timeIodaIO.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_TIMEIODAIO_H_
9 #define MAINS_TIMEIODAIO_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/mpi/mpi.h"
19 #include "oops/runs/Application.h"
20 #include "oops/util/DateTime.h"
21 #include "oops/util/Duration.h"
22 #include "oops/util/Logger.h"
23 
24 #include "ioda/core/IodaUtils.h"
25 #include "ioda/ObsSpace.h"
26 
27 namespace ioda {
28 
29 template <typename MODEL> class TimeIodaIO : public oops::Application {
30  typedef oops::ObsSpaces<MODEL> ObsSpaces_;
31 
32  public:
33 // -----------------------------------------------------------------------------
34  explicit TimeIodaIO(const eckit::mpi::Comm & comm = oops::mpi::world()) : Application(comm) {}
35 // -----------------------------------------------------------------------------
36  virtual ~TimeIodaIO() {}
37 // -----------------------------------------------------------------------------
38  int execute(const eckit::Configuration & fullConfig) const {
39 // Setup observation window
40  const util::DateTime winbgn(fullConfig.getString("window begin"));
41  const util::DateTime winend(fullConfig.getString("window end"));
42  oops::Log::info() << "Observation window begin:" << winbgn << std::endl;
43  oops::Log::info() << "Observation window end:" << winend << std::endl;
44 
45 // Setup observations
46  eckit::LocalConfiguration obsconf(fullConfig, "observations");
47  oops::Log::debug() << "Observations configuration is:" << obsconf << std::endl;
48  ObsSpaces_ obsdb(obsconf, this->getComm(), winbgn, winend);
49 
50  for (std::size_t jj = 0; jj < obsdb.size(); ++jj) {
51  oops::Log::info() << "ObsSpace: " << obsdb[jj].obsname() << std::endl;
52  oops::Log::info() << " Number of locations: " << obsdb[jj].obsspace().nlocs()
53  << std::endl;
54  oops::Log::info() << " Number of variables: " << obsdb[jj].obsspace().nvars()
55  << std::endl;
56  oops::Log::info() << " Number of records: " << obsdb[jj].obsspace().nrecs()
57  << std::endl;
58  }
59  return 0;
60  }
61 
62 // -----------------------------------------------------------------------------
63  private:
64  std::string appname() const {
65  return "oops::TimeIodaIO<" + MODEL::name() + ">";
66  }
67 // -----------------------------------------------------------------------------
68 };
69 
70 } // namespace ioda
71 
72 #endif // MAINS_TIMEIODAIO_H_
int execute(const eckit::Configuration &fullConfig) const
Definition: timeIodaIO.h:38
virtual ~TimeIodaIO()
Definition: timeIodaIO.h:36
std::string appname() const
Definition: timeIodaIO.h:64
TimeIodaIO(const eckit::mpi::Comm &comm=oops::mpi::world())
Definition: timeIodaIO.h:34
oops::ObsSpaces< MODEL > ObsSpaces_
Definition: timeIodaIO.h:30