UFO
PoissonDiskThinningParameters.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2019 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_POISSONDISKTHINNINGPARAMETERS_H_
9 #define UFO_FILTERS_POISSONDISKTHINNINGPARAMETERS_H_
10 
11 #include <string>
12 #include <utility>
13 
14 #include "eckit/exception/Exceptions.h"
15 #include "oops/util/Duration.h"
16 #include "oops/util/parameters/OptionalParameter.h"
17 #include "oops/util/parameters/Parameter.h"
18 #include "oops/util/parameters/Parameters.h"
19 #include "oops/util/parameters/ParameterTraitsScalarOrMap.h"
22 
23 namespace eckit {
24  class Configuration;
25 }
26 
27 namespace ufo {
28 
31 };
32 
35  static constexpr char enumTypeName[] = "ExclusionVolumeShape";
36  static constexpr util::NamedEnumerator<ExclusionVolumeShape> namedValues[] = {
37  { ExclusionVolumeShape::CYLINDER, "cylinder" },
38  { ExclusionVolumeShape::ELLIPSOID, "ellipsoid" }
39  };
40 };
41 
42 } // namespace ufo
43 
44 namespace oops {
45 
46 template <>
47 struct ParameterTraits<ufo::ExclusionVolumeShape> :
48  public EnumParameterTraits<ufo::ExclusionVolumeShapeParameterTraitsHelper>
49 {};
50 
51 } // namespace oops
52 
53 namespace ufo {
54 
55 /// \brief Options controlling the operation of the PoissonDiskThinning filter.
56 ///
57 /// \note The descriptions of several options refer to the _exclusion volume_, which is a domain
58 /// surrounding the location of each observation. If an observation is retained, then no other
59 /// observations lying in the interior of its exclusion volume may be retained at the same time.
61  OOPS_CONCRETE_PARAMETERS(PoissonDiskThinningParameters, FilterParametersBase)
62 
63  public:
64  typedef int Priority;
65 
66  // Exclusion volume
67 
68  /// Size of the exclusion volume in the horizontal direction (in km).
69  ///
70  /// If the priority_variable parameter is not set and hence all observations have the same
71  /// priority, this parameter must be a floating-point constant. Otherwise it may also be a map
72  /// assigning an exclusion volume size to each observation priority. Exclusion volumes of
73  /// lower-priority observations must be at least as large as those of higher-priority ones.
74  /// If this parameter is not set, horizontal position is ignored during thinning.
75  ///
76  /// \note Owing to a bug in the eckit YAML parser, maps need to be written in the JSON style,
77  /// with keys quoted. Example:
78  ///
79  /// min_horizontal_spacing: {"1": 123, "2": 321}
80  ///
81  /// This will not work:
82  ///
83  /// min_horizontal_spacing: {1: 123, 2: 321}
84  ///
85  /// and neither will this:
86  ///
87  /// min_horizontal_spacing:
88  /// 1: 123
89  /// 2: 321
90  ///
91  /// or this:
92  ///
93  /// min_horizontal_spacing:
94  /// "1": 123
95  /// "2": 321
96  oops::OptionalParameter<util::ScalarOrMap<Priority, float>> minHorizontalSpacing{
97  "min_horizontal_spacing", this};
98 
99  /// Size of the exclusion volume in the vertical direction (in Pa).
100  ///
101  /// Like min_horizontal_spacing, this can be either a constant or a map.
102  oops::OptionalParameter<util::ScalarOrMap<Priority, float>> minVerticalSpacing{
103  "min_vertical_spacing", this};
104 
105  /// Size of the exclusion volume in the temporal direction.
106  ///
107  /// Like min_horizontal_spacing, this can be either a constant or a map.
108  oops::OptionalParameter<util::ScalarOrMap<Priority, util::Duration>> minTimeSpacing{
109  "min_time_spacing", this};
110 
111  /// Shape of the exclusion volume surrounding each observation.
112  ///
113  /// Allowed values:
114  /// - \c cylinder: the exclusion volume of an observation taken at latitude lat, longitude lon,
115  /// pressure p and time t is the set of all locations (lat', lon', p', t') for which all of
116  /// the following conditions are met:
117  /// * the geodesic distance between (lat, lon) and (lat', lon') is smaller than
118  /// min_horizontal_spacing
119  /// * |p - p'| < min_vertical_spacing
120  /// * |t - t'| < min_time_spacing.
121  /// - \c ellipsoid: the exclusion volume of an observation taken at latitude lat, longitude lon,
122  /// pressure p and time t is the set of all locations (lat', lon', p', t') for which
123  /// the following condition is met:
124  /// * geodesic_distance((lat, lon), (lat', lon'))^2 / min_horizontal_spacing^2 +
125  /// (p - p')^2 / min_vertical_spacing^2 + (t - t')^2 / min_time_spacing^2 < 1.
126  oops::Parameter<ExclusionVolumeShape> exclusionVolumeShape{"exclusion_volume_shape",
128 
129  // Observation categories
130 
131  /// A string-valued or integer-valued variable. Observations with different values of that
132  /// variable will be thinned separately.
133  ///
134  /// If not set and observations were grouped into records when the observation space was
135  /// constructed, observations from each record will be thinned separately. If not set and
136  /// observations were not grouped into records, all observations will be thinned together.
137  ///
138  /// Note: the variable used to group observations into records can be set with the
139  /// \c obs space.obsdatain.obsgrouping.group variable YAML option.
140  oops::OptionalParameter<Variable> categoryVariable{"category_variable", this};
141 
142  // Selection of observations to retain
143 
144  /// Variable storing observation priorities. An observation will not be retained if it lies
145  /// within the exclusion volume of an observation with a higher priority.
146  ///
147  /// As noted in the documentation of min_horizontal_spacing, the exclusion volume size must be a
148  /// (weakly) monotonically decreasing function of observation priority, i.e. the exclusion volumes
149  /// of all observations with the same priority must have the same size, and the exclusion volumes
150  /// of lower-priority observations must be at least as large as those of higher-priority ones.
151  ///
152  /// If this parameter is not set, all observations are assumed to have equal priority.
153  oops::OptionalParameter<Variable> priorityVariable{"priority_variable", this};
154 
155  /// If true, observations will be randomly shuffled before being inspected as candidates
156  /// for retaining.
157  ///
158  /// \note It is recommended to leave shuffling enabled in production code, since the performance
159  /// of the spatial point index (kd-tree) used in the filter's implementation may be degraded if
160  /// observation locations are ordered largely monotonically (and random shuffling essentially
161  /// prevents that from happening).
162  oops::Parameter<bool> shuffle{"shuffle", true, this};
163 
164  /// Seed with which to initialize the random number generator used to shuffle the observations
165  /// if \p shuffle is set to true.
166  ///
167  /// If omitted, a seed will be generated based on the current (calendar) time.
168  oops::OptionalParameter<int> randomSeed{"random_seed", this};
169 };
170 
171 } // namespace ufo
172 
173 #endif // UFO_FILTERS_POISSONDISKTHINNINGPARAMETERS_H_
Parameters shared by all filters having a default action (typically "reject").
Options controlling the operation of the PoissonDiskThinning filter.
oops::OptionalParameter< util::ScalarOrMap< Priority, util::Duration > > minTimeSpacing
oops::OptionalParameter< Variable > categoryVariable
oops::OptionalParameter< util::ScalarOrMap< Priority, float > > minVerticalSpacing
oops::OptionalParameter< Variable > priorityVariable
oops::OptionalParameter< util::ScalarOrMap< Priority, float > > minHorizontalSpacing
oops::Parameter< ExclusionVolumeShape > exclusionVolumeShape
Forward declarations.
Definition: ObsAodExt.h:21
Definition: RunCRTM.h:27
static constexpr util::NamedEnumerator< ExclusionVolumeShape > namedValues[]