UFO
MetOfficeBuddyCollector.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2020 Met Office UK
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_FILTERS_METOFFICEBUDDYCOLLECTOR_H_
9 #define UFO_FILTERS_METOFFICEBUDDYCOLLECTOR_H_
10 
11 #include <cassert>
12 #include <vector>
13 
15 
16 namespace ufo {
17 
18 struct MetOfficeBuddyPair;
19 
20 /// \brief Interface of classes used by MetOfficeBuddyPairFinder to select observations used as
21 /// buddies of other observations during the buddy check.
23  public:
24  /// \brief Constructor.
25  ///
26  /// \param options
27  /// Buddy check parameters.
28  /// \param latitudes
29  /// Observation latitudes.
30  /// \param longitudes
31  /// Observation longitudes.
32  /// \param stationIds
33  /// IDs of stations that have collected the observations.
35  const std::vector<float> &latitudes,
36  const std::vector<float> &longitudes,
37  const std::vector<int> &stationIds);
38 
39  virtual ~MetOfficeBuddyCollector() = default;
40  // This class is expected to be used polymorphically -- via a pointer or reference --
41  // so there doesn't seem to be much need for a copy or move constructor. Delete them for now.
46 
47  /// \brief Prepare the object for examination of potential buddies of the observation with ID
48  /// \p obsIdA.
49  ///
50  /// \note This function must be called before any calls to other member functions.
51  virtual void reset(int obsIdA) = 0;
52 
53  /// \brief Check if the observation with ID \p obsIdB can be selected as a buddy of obsIdB. If
54  /// so, record its ID internally.
55  virtual void examinePotentialBuddy(int obsIdB) = 0;
56 
57  /// \brief Called to indicate that observations passed to subsequent calls to
58  /// examinePotentialBuddy() will belong to a new zonal band.
60 
61  /// \brief Returns true if the number of observations selected as buddies of the observation
62  /// passed to reset() since the last call to startProcessingNextBand() has reached the
63  /// limit set by the \c max_num_buddies_from_single_band parameter.
65 
66  /// \brief Returns true if the number of observations selected as buddies of the observation
67  /// passed to reset() since the last call to startProcessingNextBand() has reached the
68  /// limit set by the \c max_total_num_buddies parameter.
69  bool foundEnoughBuddies() const;
70 
71  /// \brief Extend \p buddyPairs with MetOfficeBuddyPair objects storing the properies of all buddy
72  /// pairs found since the last call to reset().
73  virtual void appendBuddyPairsTo(std::vector<MetOfficeBuddyPair> &buddyPairs) const = 0;
74 
75  protected:
76  void calcDeltaLatLonAndDistanceTo(int obsIdB,
77  double &deltaLatInRad, double &deltaLonInRad,
78  double &distanceInKm) const;
79 
81  double deltaLatInRad, double deltaLonInRad,
82  double distanceInKm) const;
83 
84  protected:
86  const std::vector<float> &latitudes_;
87  const std::vector<float> &longitudes_;
88  const std::vector<int> &stationIds_;
90  int obsIdA_ = 0;
94 };
95 
96 
99 }
100 
104 }
105 
109 }
110 
111 inline void MetOfficeBuddyCollector::reset(int obsIdA) {
112  obsIdA_ = obsIdA;
115  totalNumBuddies_ = 0;
116 }
117 
118 } // namespace ufo
119 
120 #endif // UFO_FILTERS_METOFFICEBUDDYCOLLECTOR_H_
Options controlling the operation of the MetOfficeBuddyCheck filter.
Interface of classes used by MetOfficeBuddyPairFinder to select observations used as buddies of other...
bool foundEnoughBuddies() const
Returns true if the number of observations selected as buddies of the observation passed to reset() s...
const std::vector< float > & latitudes_
MetOfficeBuddyCollector(MetOfficeBuddyCollector &&)=delete
virtual void examinePotentialBuddy(int obsIdB)=0
Check if the observation with ID obsIdB can be selected as a buddy of obsIdB. If so,...
const std::vector< int > & stationIds_
MetOfficeBuddyPair createBuddyPair(int obsIdB, double deltaLatInRad, double deltaLonInRad, double distanceInKm) const
virtual void appendBuddyPairsTo(std::vector< MetOfficeBuddyPair > &buddyPairs) const =0
Extend buddyPairs with MetOfficeBuddyPair objects storing the properies of all buddy pairs found sinc...
MetOfficeBuddyCollector(const MetOfficeBuddyCollector &)=delete
virtual void reset(int obsIdA)=0
Prepare the object for examination of potential buddies of the observation with ID obsIdA.
bool foundEnoughBuddiesInCurrentBand() const
Returns true if the number of observations selected as buddies of the observation passed to reset() s...
const MetOfficeBuddyCheckParameters & options_
void startProcessingNextBand()
Called to indicate that observations passed to subsequent calls to examinePotentialBuddy() will belon...
virtual ~MetOfficeBuddyCollector()=default
MetOfficeBuddyCollector & operator=(const MetOfficeBuddyCollector &)=delete
MetOfficeBuddyCollector & operator=(MetOfficeBuddyCollector &&)=delete
void calcDeltaLatLonAndDistanceTo(int obsIdB, double &deltaLatInRad, double &deltaLonInRad, double &distanceInKm) const
const std::vector< float > & longitudes_
MetOfficeBuddyCollector(const MetOfficeBuddyCheckParameters &options, const std::vector< float > &latitudes, const std::vector< float > &longitudes, const std::vector< int > &stationIds)
Constructor.
Definition: RunCRTM.h:27
Properties of a pair of observations checked against each other during buddy check.