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 <set>
15 #include <string>
16 #include <utility>
17 #include <vector>
18 
19 #include "ioda/ObsDataVector.h"
20 #include "ioda/ObsSpace.h"
21 
23 
24 namespace ioda {
25  class ObsSpace;
26 }
27 
28 namespace ufo {
29 
30  /// \brief Determine indices of observations making up individual profiles.
31  /// The indices are computed with respect to the entire sample of observations.
32  /// Used to extract relevant data and flags from the entire sample.
33  ///
34  /// It is important to distinguish between:
35  /// -# profile indices, which indicate the position of the profile's observations
36  /// in the entire sample of observations,
37  /// -# profile numbers, which are assigned to entire profiles
38  /// and only change when a new profile is reached.
39  ///
41  public:
42  ProfileIndices(ioda::ObsSpace &obsdb,
43  const DataHandlerParameters &options,
44  const std::vector <bool> &apply);
45 
46  /// Determine indices in entire sample for the next profile.
48 
49  /// Return indices for the current profile.
50  const std::vector <size_t> &getProfileIndices() const {return profileIndices_;}
51 
52  /// Return number of levels to which QC checks should be applied.
53  int getNumProfileLevels() const {return numProfileLevels_;}
54 
55  /// Get number of current profile, accounting for distribution across processors.
56  size_t getProfileNumCurrent() const;
57 
58  /// Reset profile indices to point to the beginning of the sample.
59  void reset();
60 
61  private: // functions
62  /// Ensure number of profiles is consistent with quantity reported by obsdb.
63  void validateTotalNumProf();
64 
65  private: // variables
66  /// Observation database.
67  ioda::ObsSpace &obsdb_;
68 
69  /// Configurable parameters.
71 
72  /// Observations to apply the filter to.
73  const std::vector <bool> &apply_;
74 
75  /// Profile numbers for the entire sample.
76  const std::vector <size_t> profileNums_;
77 
78  /// Unique profile numbers for the entire sample.
79  std::set <size_t> uniqueProfileNums_;
80 
81  /// Profile index map.
82  typedef std::map<std::size_t, std::vector<std::size_t>> ProfIdxMap;
83 
84  /// Profile index map iterator.
85  typedef ProfIdxMap::const_iterator ProfIdxIter;
86 
87  /// Iterator over profile indices (used for sorting).
89 
90  /// Iterator pointing to current profile index (initially points to beginning).
92 
93  /// Indices for this profile.
94  std::vector <size_t> profileIndices_;
95 
96  /// Number of profile levels to which QC checks should be applied.
98 
99  /// Current profile number in the sample.
101 
102  /// Next profile number to find in the sample.
104 
105  // Current index within the entire sample.
106  size_t profIndex_;
107  };
108 } // namespace ufo
109 
110 #endif // UFO_PROFILE_PROFILEINDICES_H_
Options controlling the operation of the EntireSampleDataHandler and ProfileDataHandler classes.
Determine indices of observations making up individual profiles. The indices are computed with respec...
size_t profileNumToFind_
Next profile number to find in the sample.
ProfileIndices(ioda::ObsSpace &obsdb, const DataHandlerParameters &options, const std::vector< bool > &apply)
const std::vector< bool > & apply_
Observations to apply the filter to.
int numProfileLevels_
Number of profile levels to which QC checks should be applied.
ProfIdxMap::const_iterator ProfIdxIter
Profile index map iterator.
ioda::ObsSpace & obsdb_
Observation database.
void validateTotalNumProf()
Ensure number of profiles is consistent with quantity reported by obsdb.
size_t profileNumCurrent_
Current profile number in the sample.
std::set< size_t > uniqueProfileNums_
Unique profile numbers for the entire sample.
ProfIdxIter profidx_current_
Iterator pointing to current profile index (initially points to beginning).
const std::vector< size_t > profileNums_
Profile numbers for the entire sample.
size_t getProfileNumCurrent() const
Get number of current profile, accounting for distribution across processors.
std::map< std::size_t, std::vector< std::size_t > > ProfIdxMap
Profile index map.
const DataHandlerParameters & options_
Configurable parameters.
const std::vector< size_t > & getProfileIndices() const
Return indices for the current profile.
void updateNextProfileIndices()
Determine indices in entire sample for the next profile.
void reset()
Reset profile indices to point to the beginning of the sample.
std::vector< size_t > profileIndices_
Indices for this profile.
ProfIdxMap profidx_
Iterator over profile indices (used for sorting).
int getNumProfileLevels() const
Return number of levels to which QC checks should be applied.
Forward declarations.
Definition: ObsAodExt.h:25
Definition: RunCRTM.h:27