FV3 Bundle
ObsEnsemble.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2018 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 OOPS_BASE_OBSENSEMBLE_H_
9 #define OOPS_BASE_OBSENSEMBLE_H_
10 
11 #include <boost/ptr_container/ptr_vector.hpp>
12 
13 #include "oops/base/Observations.h"
14 #include "oops/base/ObsSpaces.h"
15 #include "oops/util/Logger.h"
16 
17 namespace oops {
18 
19 // -----------------------------------------------------------------------------
20 
21 /// Ensemble
22 
23 template<typename MODEL> class ObsEnsemble {
26 
27  public:
28 /// Constructor
29  ObsEnsemble(const ObsSpace_ &, const int &);
30 
31 /// Destructor
32  virtual ~ObsEnsemble() {}
33 
34  /// Accessors
35  unsigned int size() const {
36  return rank_;
37  }
38  Observations_ & operator[](const int ii) {
39  return ensemblePerturbs_[ii];
40  }
41  const Observations_ & operator[](const int ii) const {
42  return ensemblePerturbs_[ii];
43  }
44 
45  private:
46  unsigned int rank_;
47  boost::ptr_vector<Observations_> ensemblePerturbs_;
48 };
49 
50 // ====================================================================================
51 
52 template<typename MODEL>
53 ObsEnsemble<MODEL>::ObsEnsemble(const ObsSpace_ & os, const int & rank)
54  : rank_(rank),
55  ensemblePerturbs_()
56 {
57  for (unsigned i = 0; i < rank_; ++i) {
58  Observations_ * y = new Observations_(os);
59  ensemblePerturbs_.push_back(y);
60  }
61  Log::trace() << "ObsEnsemble:contructor done" << std::endl;
62 }
63 
64 // -----------------------------------------------------------------------------
65 
66 } // namespace oops
67 
68 #endif // OOPS_BASE_OBSENSEMBLE_H_
l_size ! loop over number of fields ke do je do i
ObsSpaces< MODEL > ObsSpace_
Definition: ObsEnsemble.h:25
virtual ~ObsEnsemble()
Destructor.
Definition: ObsEnsemble.h:32
unsigned int rank_
Definition: ObsEnsemble.h:46
unsigned int size() const
Accessors.
Definition: ObsEnsemble.h:35
Observations Class.
Definition: Observations.h:36
The namespace for the main oops code.
const Observations_ & operator[](const int ii) const
Definition: ObsEnsemble.h:41
Observations< MODEL > Observations_
Definition: ObsEnsemble.h:24
Observations_ & operator[](const int ii)
Definition: ObsEnsemble.h:38
boost::ptr_vector< Observations_ > ensemblePerturbs_
Definition: ObsEnsemble.h:47
ObsEnsemble(const ObsSpace_ &, const int &)
Constructor.
Definition: ObsEnsemble.h:53
Ensemble.
Definition: ObsEnsemble.h:23