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_
ufo::MetOfficeBuddyCollector::totalNumBuddies_
int totalNumBuddies_
Definition: MetOfficeBuddyCollector.h:93
ufo::MetOfficeBuddyCollector::stationIds_
const std::vector< int > & stationIds_
Definition: MetOfficeBuddyCollector.h:88
ufo::MetOfficeBuddyCollector::obsIdA_
int obsIdA_
Definition: MetOfficeBuddyCollector.h:90
ufo::MetOfficeBuddyCollector::numBuddiesInCurrentBand_
int numBuddiesInCurrentBand_
Definition: MetOfficeBuddyCollector.h:91
ufo::MetOfficeBuddyCollector::MetOfficeBuddyCollector
MetOfficeBuddyCollector(const MetOfficeBuddyCollector &)=delete
ufo::MetOfficeBuddyCollector::calcDeltaLatLonAndDistanceTo
void calcDeltaLatLonAndDistanceTo(int obsIdB, double &deltaLatInRad, double &deltaLonInRad, double &distanceInKm) const
Definition: MetOfficeBuddyCollector.cc:30
ufo::MetOfficeBuddyCollector::foundEnoughBuddies
bool foundEnoughBuddies() const
Returns true if the number of observations selected as buddies of the observation passed to reset() s...
Definition: MetOfficeBuddyCollector.h:106
ufo::MetOfficeBuddyCollector::numBuddiesWithSameStationId_
int numBuddiesWithSameStationId_
Definition: MetOfficeBuddyCollector.h:92
ufo
Definition: RunCRTM.h:27
ufo::MetOfficeBuddyCollector::examinePotentialBuddy
virtual void examinePotentialBuddy(int obsIdB)=0
Check if the observation with ID obsIdB can be selected as a buddy of obsIdB. If so,...
ufo::MetOfficeBuddyCollector::maxLatDifferenceBetweenBuddiesInDeg_
double maxLatDifferenceBetweenBuddiesInDeg_
Definition: MetOfficeBuddyCollector.h:89
ufo::MetOfficeBuddyPair
Properties of a pair of observations checked against each other during buddy check.
Definition: MetOfficeBuddyPair.h:14
ufo::MetOfficeBuddyCollector
Interface of classes used by MetOfficeBuddyPairFinder to select observations used as buddies of other...
Definition: MetOfficeBuddyCollector.h:22
ufo::MetOfficeBuddyCheckParameters
Options controlling the operation of the MetOfficeBuddyCheck filter.
Definition: MetOfficeBuddyCheckParameters.h:41
ufo::MetOfficeBuddyCollector::options_
const MetOfficeBuddyCheckParameters & options_
Definition: MetOfficeBuddyCollector.h:85
ufo::MetOfficeBuddyCollector::~MetOfficeBuddyCollector
virtual ~MetOfficeBuddyCollector()=default
ufo::MetOfficeBuddyCheckParameters::maxTotalNumBuddies
oops::Parameter< int > maxTotalNumBuddies
Definition: MetOfficeBuddyCheckParameters.h:85
ufo::MetOfficeBuddyCollector::latitudes_
const std::vector< float > & latitudes_
Definition: MetOfficeBuddyCollector.h:86
ufo::MetOfficeBuddyCollector::reset
virtual void reset(int obsIdA)=0
Prepare the object for examination of potential buddies of the observation with ID obsIdA.
Definition: MetOfficeBuddyCollector.h:111
ufo::MetOfficeBuddyCollector::operator=
MetOfficeBuddyCollector & operator=(MetOfficeBuddyCollector &&)=delete
ufo::MetOfficeBuddyCollector::MetOfficeBuddyCollector
MetOfficeBuddyCollector(MetOfficeBuddyCollector &&)=delete
ufo::MetOfficeBuddyCollector::longitudes_
const std::vector< float > & longitudes_
Definition: MetOfficeBuddyCollector.h:87
ufo::MetOfficeBuddyCollector::MetOfficeBuddyCollector
MetOfficeBuddyCollector(const MetOfficeBuddyCheckParameters &options, const std::vector< float > &latitudes, const std::vector< float > &longitudes, const std::vector< int > &stationIds)
Constructor.
Definition: MetOfficeBuddyCollector.cc:19
ufo::MetOfficeBuddyCollector::appendBuddyPairsTo
virtual void appendBuddyPairsTo(std::vector< MetOfficeBuddyPair > &buddyPairs) const =0
Extend buddyPairs with MetOfficeBuddyPair objects storing the properies of all buddy pairs found sinc...
ufo::MetOfficeBuddyCollector::foundEnoughBuddiesInCurrentBand
bool foundEnoughBuddiesInCurrentBand() const
Returns true if the number of observations selected as buddies of the observation passed to reset() s...
Definition: MetOfficeBuddyCollector.h:101
ufo::MetOfficeBuddyCheckParameters::maxNumBuddiesFromSingleBand
oops::Parameter< int > maxNumBuddiesFromSingleBand
Definition: MetOfficeBuddyCheckParameters.h:90
MetOfficeBuddyCheckParameters.h
ufo::MetOfficeBuddyCollector::createBuddyPair
MetOfficeBuddyPair createBuddyPair(int obsIdB, double deltaLatInRad, double deltaLonInRad, double distanceInKm) const
Definition: MetOfficeBuddyCollector.cc:49
ufo::MetOfficeBuddyCollector::startProcessingNextBand
void startProcessingNextBand()
Called to indicate that observations passed to subsequent calls to examinePotentialBuddy() will belon...
Definition: MetOfficeBuddyCollector.h:97
ufo::MetOfficeBuddyCollector::operator=
MetOfficeBuddyCollector & operator=(const MetOfficeBuddyCollector &)=delete