OOPS
QCData.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2020 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 #ifndef OOPS_BASE_QCDATA_H_
8 #define OOPS_BASE_QCDATA_H_
9 
10 #include <memory>
11 #include <string>
12 #include <vector>
13 
14 #include "oops/base/ObsSpaces.h"
16 
17 namespace oops {
18 
19 // -----------------------------------------------------------------------------
20 
21 /// \brief container for QC-related things (flags & obserrors)
22 
23 template <typename OBS>
24 class QCData {
26  template <typename DATA> using ObsData_ = ObsDataVector<OBS, DATA>;
27  template <typename DATA> using ObsDataPtr_ = std::shared_ptr<ObsData_<DATA> >;
28 
29  public:
30 /// \brief Initializes QC data, optionally setting the variable names to read.
31  explicit QCData(const ObsSpaces_ &, const std::string qcName = "",
32  const std::string errName = "ObsError");
33 
34 /// \brief accessor to QC flag
35  const ObsDataPtr_<int> qcFlags(const size_t ii) const {return qcflags_[ii];}
36 /// \brief accessor to Obs errors
37  const ObsDataPtr_<float> obsErrors(const size_t ii) const {return obserr_[ii];}
38 
39  private:
40  std::vector<ObsDataPtr_<int> > qcflags_; // QC flags
41  std::vector<ObsDataPtr_<float> > obserr_; // Obs Errors
42 };
43 
44 
45 // -----------------------------------------------------------------------------
46 
47 template <typename OBS>
48 QCData<OBS>::QCData(const ObsSpaces_ & obspaces, const std::string qcName,
49  const std::string errName) {
50  qcflags_.reserve(obspaces.size());
51  obserr_.reserve(obspaces.size());
52  for (size_t jj = 0; jj < obspaces.size(); ++jj) {
53 // Allocate QC flags
54  qcflags_.emplace_back(std::shared_ptr<ObsData_<int>>(new ObsData_<int>(obspaces[jj],
55  obspaces[jj].obsvariables(), qcName)));
56 // Allocate and read initial obs error
57  obserr_.emplace_back(std::shared_ptr<ObsData_<float>>(new ObsData_<float>(obspaces[jj],
58  obspaces[jj].obsvariables(), errName)));
59  }
60 }
61 
62 } // namespace oops
63 
64 #endif // OOPS_BASE_QCDATA_H_
oops
The namespace for the main oops code.
Definition: ErrorCovarianceL95.cc:22
oops::QCData
container for QC-related things (flags & obserrors)
Definition: QCData.h:24
oops::QCData::obserr_
std::vector< ObsDataPtr_< float > > obserr_
Definition: QCData.h:41
ObsSpaces.h
oops::ObsSpaces::size
std::size_t size() const
Access.
Definition: ObsSpaces.h:57
oops::QCData::qcflags_
std::vector< ObsDataPtr_< int > > qcflags_
Definition: QCData.h:40
oops::QCData::QCData
QCData(const ObsSpaces_ &, const std::string qcName="", const std::string errName="ObsError")
Initializes QC data, optionally setting the variable names to read.
Definition: QCData.h:48
oops::ObsDataVector
Definition: ObsDataVector.h:28
oops::QCData::ObsDataPtr_
std::shared_ptr< ObsData_< DATA > > ObsDataPtr_
Definition: QCData.h:27
oops::QCData::ObsSpaces_
ObsSpaces< OBS > ObsSpaces_
Definition: QCData.h:25
oops::QCData::obsErrors
const ObsDataPtr_< float > obsErrors(const size_t ii) const
accessor to Obs errors
Definition: QCData.h:37
oops::ObsSpaces
Definition: ObsSpaces.h:41
ObsDataVector.h
oops::QCData::qcFlags
const ObsDataPtr_< int > qcFlags(const size_t ii) const
accessor to QC flag
Definition: QCData.h:35