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  ProfileDataHandler &profileDataHandler);
31 
32  /// Validate check results against OPS values.
33  void validate();
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  /// Profile data handler.
68 
69  /// Counters that are accumulated across profiles.
70  std::map <std::string, int> cumulativeCounters_;
71 
72  /// Number of mismatches between this code and OPS (separate for each profile).
74 
75  /// Integer values to compare.
76  std::set <std::string> valuesToCompare_int_;
77 
78  /// Float values to compare.
79  std::set <std::string> valuesToCompare_float_;
80 
81  /// Values for which there is an offset between this code and OPS due to
82  /// array indices starting at 0 in C++ and 1 in Fortran.
83  std::map <std::string, int> comparison_offsets_;
84  };
85 } // namespace ufo
86 
87 #endif // UFO_PROFILE_PROFILECHECKVALIDATOR_H_
ufo::ProfileCheckValidator::profileDataHandler_
ProfileDataHandler & profileDataHandler_
Profile data handler.
Definition: ProfileCheckValidator.h:67
ufo::ProfileDataHandler
Retrieve and store data for individual profiles. To do this, first the vector of values in the entire...
Definition: ProfileDataHandler.h:40
ufo::ProfileCheckValidator::cumulativeCounters_
std::map< std::string, int > cumulativeCounters_
Counters that are accumulated across profiles.
Definition: ProfileCheckValidator.h:70
ufo::ProfileCheckValidator::nMismatches_
int nMismatches_
Number of mismatches between this code and OPS (separate for each profile).
Definition: ProfileCheckValidator.h:73
ufo::ProfileCheckValidator::differenceWithinTol
bool differenceWithinTol(const T A, const T B, const float tol=1e-10) const
Determine difference between two values within a certain tolerance.
Definition: ProfileCheckValidator.h:59
ufo::ProfileCheckValidator::ProfileCheckValidator
ProfileCheckValidator(const ProfileConsistencyCheckParameters &options, ProfileDataHandler &profileDataHandler)
Definition: ProfileCheckValidator.cc:23
ufo::ProfileCheckValidator::options_
const ProfileConsistencyCheckParameters & options_
Configurable parameters.
Definition: ProfileCheckValidator.h:64
ufo::ProfileCheckValidator
Profile QC check validator.
Definition: ProfileCheckValidator.h:27
ProfileConsistencyCheckParameters.h
ufo::ProfileCheckValidator::valuesToCompare_float_
std::set< std::string > valuesToCompare_float_
Float values to compare.
Definition: ProfileCheckValidator.h:79
ufo::ProfileCheckValidator::compareOutput
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.
Definition: ProfileCheckValidator.cc:156
ufo
Definition: RunCRTM.h:27
ProfileDataHandler.h
ufo::ProfileCheckValidator::comparison_offsets_
std::map< std::string, int > comparison_offsets_
Definition: ProfileCheckValidator.h:83
ufo::ProfileCheckValidator::valuesToCompare_int_
std::set< std::string > valuesToCompare_int_
Integer values to compare.
Definition: ProfileCheckValidator.h:76
ufo::ProfileConsistencyCheckParameters
Options controlling the operation of the ProfileConsistencyChecks filter.
Definition: ProfileConsistencyCheckParameters.h:33
ufo::ProfileCheckValidator::validate
void validate()
Validate check results against OPS values.
Definition: ProfileCheckValidator.cc:200
VariableNames.h
ufo::ProfileCheckValidator::getMismatches
int getMismatches() const
Get number of mismatches between values produced in this code and the OPS equivalents.
Definition: ProfileCheckValidator.h:36