OOPS
ObsVec1D.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2009-2016 ECMWF.
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  * In applying this licence, ECMWF does not waive the privileges and immunities
7  * granted to it by virtue of its status as an intergovernmental organisation nor
8  * does it submit to any jurisdiction.
9  */
10 
11 #ifndef LORENZ95_OBSVEC1D_H_
12 #define LORENZ95_OBSVEC1D_H_
13 
14 #include <Eigen/Dense>
15 #include <ostream>
16 #include <string>
17 #include <vector>
18 
19 #include "oops/util/ObjectCounter.h"
20 #include "oops/util/Printable.h"
21 
22 namespace lorenz95 {
23  class ObsTable;
24  template <typename DATATYPE> class ObsData1D;
25 
26 // -----------------------------------------------------------------------------
27 /// Vector in observation space
28 /*!
29  * ObsVec1D is implemented as an STL vector
30  */
31 
32 class ObsVec1D : public util::Printable,
33  private util::ObjectCounter<ObsVec1D> {
34  public:
35  static const std::string classname() {return "lorenz95::ObsVec1D";}
36 
37  explicit ObsVec1D(const ObsTable &, const std::string & name = "");
38  ObsVec1D(const ObsVec1D &);
39  ~ObsVec1D() = default;
40 
41  ObsVec1D & operator= (const ObsVec1D &);
42  ObsVec1D & operator*= (const double &);
43  ObsVec1D & operator+= (const ObsVec1D &);
44  ObsVec1D & operator-= (const ObsVec1D &);
45  ObsVec1D & operator*= (const ObsVec1D &);
46  ObsVec1D & operator/= (const ObsVec1D &);
47 
48  Eigen::VectorXd packEigen(const ObsVec1D &) const;
49  size_t packEigenSize(const ObsVec1D &) const;
50 
51  size_t size() const {return data_.size();}
52  const double & operator[](const std::size_t ii) const {return data_.at(ii);}
53  double & operator[](const std::size_t ii) {return data_.at(ii);}
54 
55  void zero();
56  /// set all values to ones (for tests)
57  void ones();
58 
59  void axpy(const double &, const ObsVec1D &);
60  void invert();
61  void random();
62  double dot_product_with(const ObsVec1D &) const;
63  double rms() const;
64  void mask(const ObsData1D<int> &);
65  void mask(const ObsVec1D &);
67 
68  unsigned int nobs() const;
69  const ObsTable & obsdb() const {return obsdb_;}
70 
71 // I/O
72  void save(const std::string &) const;
73  void read(const std::string &);
74 
75  const double & missing() const {return missing_;}
76 
77  private:
78  void print(std::ostream &) const;
79 
80  const ObsTable & obsdb_;
81  std::vector<double> data_;
82  const double missing_;
83 };
84 //-----------------------------------------------------------------------------
85 } // namespace lorenz95
86 #endif // LORENZ95_OBSVEC1D_H_
Data in observation space.
Definition: ObsData1D.h:35
A Simple Observation Data Handler.
Definition: ObsTable.h:67
Vector in observation space.
Definition: ObsVec1D.h:33
unsigned int nobs() const
Definition: ObsVec1D.cc:155
void mask(const ObsData1D< int > &)
Definition: ObsVec1D.cc:159
std::vector< double > data_
Definition: ObsVec1D.h:81
const ObsTable & obsdb_
Definition: ObsVec1D.h:80
size_t packEigenSize(const ObsVec1D &) const
Definition: ObsVec1D.cc:198
void axpy(const double &, const ObsVec1D &)
Definition: ObsVec1D.cc:116
const double & operator[](const std::size_t ii) const
Definition: ObsVec1D.h:52
size_t size() const
Definition: ObsVec1D.h:51
const ObsTable & obsdb() const
Definition: ObsVec1D.h:69
double rms() const
Definition: ObsVec1D.cc:142
const double & missing() const
Definition: ObsVec1D.h:75
void ones()
set all values to ones (for tests)
Definition: ObsVec1D.cc:106
Eigen::VectorXd packEigen(const ObsVec1D &) const
Definition: ObsVec1D.cc:187
ObsVec1D & operator=(const ObsVec1D &)
Definition: ObsVec1D.cc:40
ObsVec1D & operator*=(const double &)
Definition: ObsVec1D.cc:47
const double missing_
Definition: ObsVec1D.h:82
void print(std::ostream &) const
Definition: ObsVec1D.cc:212
double dot_product_with(const ObsVec1D &) const
Definition: ObsVec1D.cc:131
double & operator[](const std::size_t ii)
Definition: ObsVec1D.h:53
void read(const std::string &)
Definition: ObsVec1D.cc:208
static const std::string classname()
Definition: ObsVec1D.h:35
ObsVec1D & operator-=(const ObsVec1D &)
Definition: ObsVec1D.cc:66
ObsVec1D & operator/=(const ObsVec1D &)
Definition: ObsVec1D.cc:90
void save(const std::string &) const
Definition: ObsVec1D.cc:183
ObsVec1D & operator+=(const ObsVec1D &)
Definition: ObsVec1D.cc:54
ObsVec1D(const ObsTable &, const std::string &name="")
Definition: ObsVec1D.cc:26
The namespace for the L95 model.