OOPS
IncrementEnsemble4D.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2009-2016 ECMWF.
3  * (C) Copyright 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 OOPS_BASE_INCREMENTENSEMBLE4D_H_
13 #define OOPS_BASE_INCREMENTENSEMBLE4D_H_
14 
15 #include <string>
16 #include <vector>
17 
18 #include "eckit/config/LocalConfiguration.h"
19 #include "oops/base/Geometry.h"
20 #include "oops/base/Increment4D.h"
21 #include "oops/base/State4D.h"
23 #include "oops/base/Variables.h"
24 #include "oops/util/DateTime.h"
25 #include "oops/util/Logger.h"
26 
27 namespace oops {
28 
29 // -----------------------------------------------------------------------------
30 
31 /// \brief Ensemble of 4D increments
32 template<typename MODEL> class IncrementEnsemble4D {
37 
38  public:
39  /// Constructor
40  IncrementEnsemble4D(const Geometry_ & resol,
41  const Variables & vars,
42  const std::vector<util::DateTime> &,
43  const int rank);
44  /// \brief construct ensemble of perturbations as \p ens - \p mean; holding
45  // \p vars variables
46  IncrementEnsemble4D(const StateEnsemble4D_ & ens, const State4D_ & mean,
47  const Variables & vars);
48 
49  /// Accessors
50  size_t size() const {return ensemblePerturbs_.size();}
51  Increment4D_ & operator[](const size_t ii) {return ensemblePerturbs_[ii];}
52  const Increment4D_ & operator[](const size_t ii) const {return ensemblePerturbs_[ii];}
53 
54  private:
55  std::vector<Increment4D_> ensemblePerturbs_;
56 };
57 
58 // ====================================================================================
59 
60 template<typename MODEL>
62  const std::vector<util::DateTime> & timeslots,
63  const int rank)
64  : ensemblePerturbs_()
65 {
66  ensemblePerturbs_.reserve(rank);
67  for (int m = 0; m < rank; ++m) {
68  ensemblePerturbs_.emplace_back(resol, vars, timeslots);
69  }
70  Log::trace() << "IncrementEnsemble4D:contructor done" << std::endl;
71 }
72 
73 // ====================================================================================
74 
75 template<typename MODEL>
77  const State4D_ & mean, const Variables & vars)
78  : ensemblePerturbs_()
79 {
80  ensemblePerturbs_.reserve(ensemble.size());
81  for (size_t ii = 0; ii < ensemble.size(); ++ii) {
82  ensemblePerturbs_.emplace_back(ensemble[ii].geometry(), vars,
83  ensemble[ii].validTimes());
84  ensemblePerturbs_[ii].diff(ensemble[ii], mean);
85  }
86  Log::trace() << "IncrementEnsemble4D:contructor(StateEnsemble4D) done" << std::endl;
87 }
88 
89 // -----------------------------------------------------------------------------
90 
91 } // namespace oops
92 
93 #endif // OOPS_BASE_INCREMENTENSEMBLE4D_H_
Geometry class used in oops; subclass of interface class interface::Geometry.
4D model state Increment (vector of 3D Increments)
Definition: Increment4D.h:32
Ensemble of 4D increments.
size_t size() const
Accessors.
Increment4D< MODEL > Increment4D_
IncrementEnsemble4D(const Geometry_ &resol, const Variables &vars, const std::vector< util::DateTime > &, const int rank)
Constructor.
Increment4D_ & operator[](const size_t ii)
std::vector< Increment4D_ > ensemblePerturbs_
StateEnsemble4D< MODEL > StateEnsemble4D_
const Increment4D_ & operator[](const size_t ii) const
Four dimensional state (vector of 3D States)
Definition: State4D.h:29
Ensemble of 4D states.
unsigned int size() const
Accessors.
The namespace for the main oops code.