UFO
TrackCheckUtils.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_TRACKCHECKUTILS_H_
9 #define UFO_FILTERS_TRACKCHECKUTILS_H_
10 
11 #include <array>
12 #include <memory>
13 #include <vector>
14 
15 #include <boost/optional.hpp>
16 
17 #include "eckit/config/Configuration.h"
18 #include "oops/util/DateTime.h"
19 #include "oops/util/Duration.h"
20 #include "ufo/filters/Variable.h"
21 
22 namespace eckit {
23 class Configuration;
24 }
25 
26 namespace ioda {
27 template <typename DATATYPE> class ObsDataVector;
28 class ObsSpace;
29 }
30 
31 namespace ufo {
32 
33 inline util::Duration abs(const util::Duration &duration) {
34  return duration.toSeconds() >= 0 ? duration : -duration;
35 }
36 
37 class ObsAccessor;
38 class RecursiveSplitter;
39 
40 namespace TrackCheckUtils {
41 typedef std::array<float, 3> Point;
42 float distance(const Point &a, const Point &b);
43 
44 enum class CheckResult : char
45 {
46  FAILED = false,
47  PASSED = true,
48  SKIPPED
49 };
50 
52 
53 /// \brief Locations/times of all observations processed by the track checking filter.
55  public:
56  std::vector<float> latitudes;
57  std::vector<float> longitudes;
58  std::vector<util::DateTime> datetimes;
59 };
60 
62  public:
63  ObsLocationTime(float latitude, float longitude,
64  const util::DateTime &time);
65  const Point &location() const { return location_; }
66  const util::DateTime &time() const { return time_; }
67  private:
69  util::DateTime time_;
70 };
71 
72 class CheckCounter {
73  public:
74  CheckCounter();
75 
76  float failedChecksFraction() const;
77  void registerCheckResult(const CheckResult &result);
78  void unregisterCheckResult(const CheckResult &result);
79  private:
82 };
83 
84 /// \brief Create an ObsAccessor object providing access to observations that need to be checked
85 /// by the current MPI task.
86 ///
87 /// The composition of this set of observations depends on the value of \p stationIdVariable.
88 ///
89 /// If \p stationIdVariable is empty, observations are assumed to be grouped into tracks by the
90 /// record ID. Each MPI rank is guaranteed to hold either all or no observations from a given
91 /// record. Thus the returned ObsAccessor gives access to all observations from the records held on
92 /// the current MPI rank.
93 ///
94 /// Otherwise, observations are assumed to be grouped into tracks by the variable \p
95 /// *stationIdVariable. If this variable was also used to group observations into records, the
96 /// returned ObsAccessor is constructed as if \p stationIdVariable was empty; otherwise, it gives
97 /// access to observations held on all MPI ranks.
98 ObsAccessor createObsAccessor(const boost::optional<Variable> &stationIdVariable,
99  const ioda::ObsSpace &obsdb);
100 
101 void sortTracksChronologically(const std::vector<size_t> &validObsIds,
102  const ObsAccessor &obsAccessor,
103  RecursiveSplitter &splitter);
104 
106 
107 } // namespace TrackCheckUtils
108 
109 } // namespace ufo
110 
111 #endif // UFO_FILTERS_TRACKCHECKUTILS_H_
This class provides access to observations that may be held on multiple MPI ranks.
Definition: ObsAccessor.h:56
Partitions an array into groups of elements equivalent according to certain criteria.
void registerCheckResult(const CheckResult &result)
void unregisterCheckResult(const CheckResult &result)
Locations/times of all observations processed by the track checking filter.
std::vector< util::DateTime > datetimes
ObsLocationTime(float latitude, float longitude, const util::DateTime &time)
const util::DateTime & time() const
Forward declarations.
Definition: ObsAodExt.h:21
Forward declarations.
Definition: ObsAodExt.h:25
ObsGroupLocationTimes collectObservationsLocations(const ObsAccessor &obsAccessor)
ObsAccessor createObsAccessor(const boost::optional< Variable > &stationIdVariable, const ioda::ObsSpace &obsdb)
Create an ObsAccessor object providing access to observations that need to be checked by the current ...
void sortTracksChronologically(const std::vector< size_t > &validObsIds, const ObsAccessor &obsAccessor, RecursiveSplitter &splitter)
float distance(const Point &a, const Point &b)
Returns the distance between the two cartesian-mapped Point arguments
std::array< float, 3 > Point
Definition: RunCRTM.h:27
util::Duration abs(const util::Duration &duration)