IODA Bundle
ObsSpaceQG.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2009-2016 ECMWF.
3  * (C) Copyright 2017-2020 UCAR.
4  *
5  * This software is licensed under the terms of the Apache Licence Version 2.0
6  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
7  * In applying this licence, ECMWF does not waive the privileges and immunities
8  * granted to it by virtue of its status as an intergovernmental organisation nor
9  * does it submit to any jurisdiction.
10  */
11 
12 #ifndef QG_MODEL_OBSSPACEQG_H_
13 #define QG_MODEL_OBSSPACEQG_H_
14 
15 #include <map>
16 #include <memory>
17 #include <ostream>
18 #include <string>
19 #include <vector>
20 
21 #include "eckit/geometry/Point2.h"
22 #include "eckit/mpi/Comm.h"
23 
24 #include "oops/base/ObsSpaceBase.h"
25 #include "oops/base/Variables.h"
26 #include "oops/util/DateTime.h"
27 
28 #include "oops/qg/LocationsQG.h"
29 #include "oops/qg/ObsIteratorQG.h"
30 #include "oops/qg/QgFortran.h"
31 
32 namespace eckit {
33  class Configuration;
34 }
35 
36 namespace qg {
37  class ObsIteratorQG;
38 
39 /// \brief ObsSpace for QG model
40 // \details ObsSpaceQG is created for each obs type. The underlying Fortran
41 // structure (key_) is created for each matching input-output filename pair
42 // (i.e. different obstypes can be stored in the same Fortran structure).
43 // For mapping between ObsSpaceQG and Fortran structures,
44 // ObsSpaceQG::theObsFileRegister_ map is used
46  public:
47  /// create full ObsSpace (read or generate data)
48  ObsSpaceQG(const eckit::Configuration &, const eckit::mpi::Comm &,
49  const util::DateTime &, const util::DateTime &, const eckit::mpi::Comm &);
50  ~ObsSpaceQG();
51 
52  /// save and close file
53  void save() const;
54 
55  /// read data or metadata
56  void getdb(const std::string &, int &) const;
57  /// save data or metadata
58  void putdb(const std::string &, const int &) const;
59 
60  /// create locations for the whole time window
61  std::unique_ptr<LocationsQG> locations() const;
62 
63  /// return number of observations (unique locations)
64  int nobs() const;
65 
66  /// return variables simulated by ObsOperators
67  const oops::Variables & obsvariables() const { return obsvars_; }
68 
69  /// observation type
70  const std::string & obsname() const {return obsname_;}
71 
72  /// iterator to the first observation
73  ObsIteratorQG begin() const;
74  /// iterator to the observation past-the-last
75  ObsIteratorQG end() const;
76 
77  /// interface with Fortran
78  const F90odb & toFortran() const {return key_;}
79 
80  private:
81  void print(std::ostream &) const;
82 
83  mutable F90odb key_; // pointer to Fortran structure
84  const std::string obsname_; // corresponds with obstype
85  const util::DateTime winbgn_; // window for the observations
86  const util::DateTime winend_;
87  oops::Variables obsvars_; // variables simulated by ObsOperators
88 
89  // defines mapping for Fortran structures
90  static std::map < std::string, F90odb > theObsFileRegister_;
91  static int theObsFileCount_; // number of files used
92 };
93 
94 } // namespace qg
95 
96 #endif // QG_MODEL_OBSSPACEQG_H_
Base class for observation spaces.
Definition: ObsSpaceBase.h:31
Iterator over all observations.
Definition: ObsIteratorQG.h:28
ObsSpace for QG model.
Definition: ObsSpaceQG.h:45
const F90odb & toFortran() const
interface with Fortran
Definition: ObsSpaceQG.h:78
void print(std::ostream &) const
Definition: ObsSpaceQG.cc:165
oops::Variables obsvars_
Definition: ObsSpaceQG.h:87
const std::string obsname_
Definition: ObsSpaceQG.h:84
const std::string & obsname() const
observation type
Definition: ObsSpaceQG.h:70
ObsSpaceQG(const eckit::Configuration &, const eckit::mpi::Comm &, const util::DateTime &, const util::DateTime &, const eckit::mpi::Comm &)
create full ObsSpace (read or generate data)
Definition: ObsSpaceQG.cc:39
const util::DateTime winend_
Definition: ObsSpaceQG.h:86
const util::DateTime winbgn_
Definition: ObsSpaceQG.h:85
void getdb(const std::string &, int &) const
read data or metadata
Definition: ObsSpaceQG.cc:127
const oops::Variables & obsvariables() const
return variables simulated by ObsOperators
Definition: ObsSpaceQG.h:67
static int theObsFileCount_
Definition: ObsSpaceQG.h:91
std::unique_ptr< LocationsQG > locations() const
create locations for the whole time window
Definition: ObsSpaceQG.cc:139
ObsIteratorQG end() const
iterator to the observation past-the-last
Definition: ObsSpaceQG.cc:160
void putdb(const std::string &, const int &) const
save data or metadata
Definition: ObsSpaceQG.cc:133
void save() const
save and close file
Definition: ObsSpaceQG.cc:116
ObsIteratorQG begin() const
iterator to the first observation
Definition: ObsSpaceQG.cc:156
static std::map< std::string, F90odb > theObsFileRegister_
Definition: ObsSpaceQG.h:90
int nobs() const
return number of observations (unique locations)
Definition: ObsSpaceQG.cc:148
The namespace for the qg model.
int F90odb
Definition: QgFortran.h:55