UFO
ProfileCheckValidator.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_PROFILECHECKVALIDATOR_H_
9 #define UFO_PROFILE_PROFILECHECKVALIDATOR_H_
10 
11 #include <map>
12 #include <set>
13 #include <string>
14 #include <vector>
15 
17 
20 
21 namespace ufo {
22 
23  /// \brief Profile QC check validator.
24  ///
25  /// Compares various values produced in this code to
26  /// the equivalent values produced in the OPS code.
28  public:
30 
31  /// Validate check results against OPS values.
32  void validate(ProfileDataHandler &profileDataHandler,
33  size_t commSize);
34 
35  /// Get number of mismatches between values produced in this code and the OPS equivalents.
36  int getMismatches() const {return nMismatches_;}
37 
38  private: // functions
39  /// Compare values with specified offset and tolerance.
40  template <typename T>
41  void compareOutput(const std::string &desc,
42  const T val1,
43  const T val2,
44  const int offset,
45  const float tol,
46  int &n);
47 
48  /// Compare vectors of values with specified offset and tolerance.
49  template <typename T>
50  void compareOutput(const std::string &desc,
51  const std::vector <T> &vec1,
52  const std::vector <T> &vec2,
53  const int offset,
54  const float tol,
55  int &n);
56 
57  /// Determine difference between two values within a certain tolerance.
58  template <typename T>
59  bool differenceWithinTol(const T A, const T B, const float tol = 1e-10) const
60  {return (std::fabs(A - B) <= tol);}
61 
62  private: // variables
63  /// Configurable parameters.
65 
66  /// Counters that are accumulated across profiles.
67  std::map <std::string, int> cumulativeCounters_;
68 
69  /// Number of mismatches between this code and OPS (separate for each profile).
71 
72  /// Integer values to compare.
73  std::set <std::string> valuesToCompare_int_;
74 
75  /// Float values to compare.
76  std::set <std::string> valuesToCompare_float_;
77 
78  /// Values for which there is an offset between this code and OPS due to
79  /// array indices starting at 0 in C++ and 1 in Fortran.
80  std::map <std::string, int> comparison_offsets_;
81  };
82 } // namespace ufo
83 
84 #endif // UFO_PROFILE_PROFILECHECKVALIDATOR_H_
Options controlling the operation of the ConventionalProfileProcessing filter.
Profile QC check validator.
std::map< std::string, int > comparison_offsets_
std::set< std::string > valuesToCompare_int_
Integer values to compare.
const ConventionalProfileProcessingParameters & options_
Configurable parameters.
ProfileCheckValidator(const ConventionalProfileProcessingParameters &options)
int nMismatches_
Number of mismatches between this code and OPS (separate for each profile).
std::map< std::string, int > cumulativeCounters_
Counters that are accumulated across profiles.
std::set< std::string > valuesToCompare_float_
Float values to compare.
void validate(ProfileDataHandler &profileDataHandler, size_t commSize)
Validate check results against OPS values.
bool differenceWithinTol(const T A, const T B, const float tol=1e-10) const
Determine difference between two values within a certain tolerance.
int getMismatches() const
Get number of mismatches between values produced in this code and the OPS equivalents.
void compareOutput(const std::string &desc, const T val1, const T val2, const int offset, const float tol, int &n)
Compare values with specified offset and tolerance.
Retrieve and store data for individual profiles. To do this, first the vector of values in the entire...
Definition: RunCRTM.h:27