UFO
MetOfficeBuddyCollectorV1.cc
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 
9 
11 
12 namespace ufo {
13 
15  const std::vector<float> &latitudes,
16  const std::vector<float> &longitudes,
17  const std::vector<int> &stationIds)
18  : MetOfficeBuddyCollector(options, latitudes, longitudes, stationIds)
19 {}
20 
22  if (stationIds_[obsIdA_] == stationIds_[obsIdB]) {
24  return;
25  // wsmigaj: This counter is incremented here in the original Fortran implementation,
26  // but it would be more logical to increment it only if observation B turns out
27  // to be a buddy of observation A.
29  }
30 
32  potentialBuddies_.push_back(obsIdB);
35  }
36 }
37 
39  std::vector<MetOfficeBuddyPair> &buddyPairs) const {
40  // Calculate horizontal distance between the two obs for each pair.
41  // Discard if > options_.searchRadius, otherwise calculate bearing of A from B
42  // and reciprocal bearing of B from A. Store the results in 'buddyPairs'.
43 
44  for (int obsIdB : potentialBuddies_) {
45  double deltaLatInRad, deltaLonInRad, distanceInKm;
46  calcDeltaLatLonAndDistanceTo(obsIdB, deltaLatInRad, deltaLonInRad, distanceInKm);
47 
48  // wsmigaj: This check is done here in the original Fortran implementation, but I think it
49  // would be better to do it already in examinePotentialBuddy(). That would ensure that the
50  // search for buddies is terminated only when enough *genuine* (rather than potential) buddies
51  // are found.
52  if (distanceInKm <= options_.searchRadius)
53  buddyPairs.push_back(createBuddyPair(obsIdB, deltaLatInRad, deltaLonInRad, distanceInKm));
54  }
55 }
56 
59  potentialBuddies_.clear();
60 }
61 
62 } // namespace ufo
Options controlling the operation of the MetOfficeBuddyCheck filter.
oops::Parameter< float > searchRadius
Maximum distance between two observations that may be classified as buddies, in km.
Interface of classes used by MetOfficeBuddyPairFinder to select observations used as buddies of other...
const std::vector< float > & latitudes_
const std::vector< int > & stationIds_
MetOfficeBuddyPair createBuddyPair(int obsIdB, double deltaLatInRad, double deltaLonInRad, double distanceInKm) const
virtual void reset(int obsIdA)=0
Prepare the object for examination of potential buddies of the observation with ID obsIdA.
const MetOfficeBuddyCheckParameters & options_
void calcDeltaLatLonAndDistanceTo(int obsIdB, double &deltaLatInRad, double &deltaLonInRad, double &distanceInKm) const
void appendBuddyPairsTo(std::vector< MetOfficeBuddyPair > &buddyPairs) const override
Extend buddyPairs with MetOfficeBuddyPair objects storing the properies of all buddy pairs found sinc...
void examinePotentialBuddy(int obsIdB) override
Check if the observation with ID obsIdB can be selected as a buddy of obsIdB. If so,...
void reset(int obsIdA) override
Prepare the object for examination of potential buddies of the observation with ID obsIdA.
MetOfficeBuddyCollectorV1(const MetOfficeBuddyCheckParameters &options, const std::vector< float > &latitudes, const std::vector< float > &longitudes, const std::vector< int > &stationIds)
Definition: RunCRTM.h:27
util::Duration abs(const util::Duration &duration)