UFO
ProfileIndices.h
Go to the documentation of this file.
1 /*
2  * (C) Crown copyright 2020, Met Office
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 UFO_PROFILE_PROFILEINDICES_H_
9 #define UFO_PROFILE_PROFILEINDICES_H_
10 
11 #include <map>
12 #include <memory>
13 #include <ostream>
14 #include <string>
15 #include <utility>
16 #include <vector>
17 
18 #include "ioda/ObsDataVector.h"
19 #include "ioda/ObsSpace.h"
20 
22 
23 namespace ioda {
24  class ObsSpace;
25 }
26 
27 namespace ufo {
28 
29  /// \brief Determine indices of observations making up individual profiles.
30  /// The indices are computed with respect to the entire sample of observations.
31  /// Used to extract relevant data and flags from the entire sample.
32  ///
33  /// It is important to distinguish between:
34  /// -# profile indices, which indicate the position of the profile's observations
35  /// in the entire sample of observations,
36  /// -# profile numbers, which are assigned to entire profiles
37  /// and only change when a new profile is reached.
38  ///
40  public:
41  ProfileIndices(ioda::ObsSpace &obsdb,
42  const ProfileConsistencyCheckParameters &options,
43  const std::vector <bool> &apply);
44 
45  /// Determine indices in entire sample for this profile.
47 
48  /// Return indices for the current profile.
49  const std::vector <size_t> &getProfileIndices() const {return profileIndices_;}
50 
51  /// Return number of levels to which QC checks should be applied.
52  int getNumLevelsToCheck() const {return numLevelsToCheck_;}
53 
54  /// Get number of current profile.
55  size_t getProfileNumCurrent() const {return profileNumCurrent_;}
56 
57  /// Profile index map.
58  typedef std::map<std::size_t, std::vector<std::size_t>> ProfIdxMap;
59 
60  /// Profile index map iterator.
61  typedef ProfIdxMap::const_iterator ProfIdxIter;
62 
63  private: // functions
64  // Ensure number of profiles is consistent with quantity reported by obsdb.
65  void validateTotalNumProf();
66 
67  private: // variables
68  /// Observation database.
69  ioda::ObsSpace &obsdb_;
70 
71  /// Configurable parameters.
73 
74  /// Observations to apply the filter to.
75  const std::vector <bool> &apply_;
76 
77  /// Profile numbers for the entire sample.
78  const std::vector <size_t> profileNums_;
79 
80  /// Iterator over profile indices (used for sorting).
82 
83  /// Iterator pointing to current profile index (initially points to beginning).
85 
86  /// Indices for this profile.
87  std::vector <size_t> profileIndices_;
88 
89  /// Number of profile levels to which QC checks should be applied.
91 
92  /// Current profile number in the sample.
94 
95  /// Next profile number to find in the sample.
97 
98  // Current index within the entire sample.
99  size_t profIndex_;
100  };
101 } // namespace ufo
102 
103 #endif // UFO_PROFILE_PROFILEINDICES_H_
ufo::ProfileIndices::profileIndices_
std::vector< size_t > profileIndices_
Indices for this profile.
Definition: ProfileIndices.h:87
ufo::ProfileIndices::profidx_
ProfIdxMap profidx_
Iterator over profile indices (used for sorting).
Definition: ProfileIndices.h:81
ufo::ProfileIndices
Determine indices of observations making up individual profiles. The indices are computed with respec...
Definition: ProfileIndices.h:39
ufo::ProfileIndices::getNumLevelsToCheck
int getNumLevelsToCheck() const
Return number of levels to which QC checks should be applied.
Definition: ProfileIndices.h:52
ProfileConsistencyCheckParameters.h
ufo::ProfileIndices::profileNumCurrent_
size_t profileNumCurrent_
Current profile number in the sample.
Definition: ProfileIndices.h:93
ioda
Definition: ObsAtmSfcInterp.h:24
ufo
Definition: RunCRTM.h:27
ufo::ProfileIndices::options_
const ProfileConsistencyCheckParameters & options_
Configurable parameters.
Definition: ProfileIndices.h:72
ufo::ProfileIndices::getProfileIndices
const std::vector< size_t > & getProfileIndices() const
Return indices for the current profile.
Definition: ProfileIndices.h:49
ufo::ProfileIndices::profileNumToFind_
size_t profileNumToFind_
Next profile number to find in the sample.
Definition: ProfileIndices.h:96
ufo::ProfileIndices::getProfileNumCurrent
size_t getProfileNumCurrent() const
Get number of current profile.
Definition: ProfileIndices.h:55
ufo::ProfileIndices::determineProfileIndices
void determineProfileIndices()
Determine indices in entire sample for this profile.
Definition: ProfileIndices.cc:40
ufo::ProfileIndices::ProfIdxIter
ProfIdxMap::const_iterator ProfIdxIter
Profile index map iterator.
Definition: ProfileIndices.h:61
ufo::ProfileIndices::ProfIdxMap
std::map< std::size_t, std::vector< std::size_t > > ProfIdxMap
Profile index map.
Definition: ProfileIndices.h:58
ufo::ProfileConsistencyCheckParameters
Options controlling the operation of the ProfileConsistencyChecks filter.
Definition: ProfileConsistencyCheckParameters.h:33
ufo::ProfileIndices::obsdb_
ioda::ObsSpace & obsdb_
Observation database.
Definition: ProfileIndices.h:69
ufo::ProfileIndices::apply_
const std::vector< bool > & apply_
Observations to apply the filter to.
Definition: ProfileIndices.h:75
ufo::ProfileIndices::numLevelsToCheck_
int numLevelsToCheck_
Number of profile levels to which QC checks should be applied.
Definition: ProfileIndices.h:90
ufo::ProfileIndices::profIndex_
size_t profIndex_
Definition: ProfileIndices.h:99
ufo::ProfileIndices::profidx_current_
ProfIdxIter profidx_current_
Iterator pointing to current profile index (initially points to beginning).
Definition: ProfileIndices.h:84
ufo::ProfileIndices::ProfileIndices
ProfileIndices(ioda::ObsSpace &obsdb, const ProfileConsistencyCheckParameters &options, const std::vector< bool > &apply)
Definition: ProfileIndices.cc:14
ufo::ProfileIndices::profileNums_
const std::vector< size_t > profileNums_
Profile numbers for the entire sample.
Definition: ProfileIndices.h:78
ufo::ProfileIndices::validateTotalNumProf
void validateTotalNumProf()
Definition: ProfileIndices.cc:110