UFO
MetOfficeBuddyCheckParameters.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_METOFFICEBUDDYCHECKPARAMETERS_H_
9 #define UFO_FILTERS_METOFFICEBUDDYCHECKPARAMETERS_H_
10 
11 #include <map>
12 #include <string>
13 #include <vector>
14 
15 #include "eckit/exception/Exceptions.h"
16 #include "oops/util/parameters/OptionalParameter.h"
17 #include "oops/util/parameters/Parameter.h"
18 #include "oops/util/parameters/Parameters.h"
20 #include "ufo/utils/Constants.h"
22 
23 namespace ufo {
24 
25 /// \brief A box covering a specified (closed) interval of latitudes and longitudes.
26 class LatLonBoxParameters : public oops::Parameters {
27  OOPS_CONCRETE_PARAMETERS(LatLonBoxParameters, Parameters)
28 
29  public:
30  bool contains(float latitude, float longitude) const {
31  return minLatitude <= latitude && latitude <= maxLatitude &&
32  minLongitude <= longitude && longitude <= maxLongitude;
33  }
34 
35  oops::Parameter<float> minLatitude{"min_latitude", -90, this};
36  oops::Parameter<float> maxLatitude{"max_latitude", 90, this};
37  oops::Parameter<float> minLongitude{"min_longitude", -180, this};
38  oops::Parameter<float> maxLongitude{"max_longitude", 180, this};
39 };
40 
41 /// \brief Options controlling the operation of the MetOfficeBuddyCheck filter.
43  OOPS_CONCRETE_PARAMETERS(MetOfficeBuddyCheckParameters, FilterParametersBase)
44 
45  public:
46  /// \name Parameters controlling buddy pair identification
47  /// @{
48 
49  oops::OptionalParameter<int> numLevels{"num_levels", this};
50 
51  /// Maximum distance between two observations that may be classified as buddies, in km.
52  oops::Parameter<float> searchRadius{"search_radius", 100, this};
53 
54  /// Variable storing string-valued or integer-valued station IDs.
55  ///
56  /// If not set and observations were grouped into records when the observation space was
57  /// constructed, each record is assumed to consist of observations taken by a separate
58  /// station. If not set and observations were not grouped into records, all observations are
59  /// assumed to have been taken by a single station.
60  ///
61  /// Note: the variable used to group observations into records can be set with the
62  /// \c obs space.obsdatain.obsgrouping.groupvariable YAML option.
63  oops::OptionalParameter<Variable> stationIdVariable{"station_id_variable", this};
64 
65  /// Number of zonal bands to split the Earth's surface into when building a search data structure.
66  ///
67  /// Apart from the impact on the speed of buddy identification, this parameter also affects the
68  /// order in which observations are processed and thus the final estimates of gross error
69  /// probabilities, since the probability updates made when checking individual observation pairs
70  /// are not commutative.
71  oops::Parameter<int> numZonalBands{"num_zonal_bands", 24, this};
72 
73  /// Whether to include pressure in the sorting criteria used when building a search data
74  /// structure, in addition to longitude, latitude and time.
75  ///
76  /// This parameter affects the order in which observations are processed and thus the final
77  /// estimates of gross error probabilities, since the probability updates made when checking
78  /// individual observation pairs are not commutative.
79  oops::Parameter<bool> sortByPressure{"sort_by_pressure", false, this};
80 
81  /// Maximum total number of buddies of any observation.
82  ///
83  /// \note In the context of this parameter as well as the \c max_num_buddies_from_single_band
84  /// \c max_num_buddies_with_same_station_id parameters, the number of buddies of any observation O
85  /// is understood as the number of buddy pairs (O, O') where O' != O. This definition facilitates
86  /// the buddy check implementation, but is an underestimate of the true number of buddies, since
87  /// it doesn't take into account pairs of the form (O', O).
88  oops::Parameter<int> maxTotalNumBuddies{"max_total_num_buddies", 15, this};
89 
90  /// Maximum number of buddies of any observation belonging to a single zonal band.
91  ///
92  /// See the note next to maxTotalNumBuddies.
93  oops::Parameter<int> maxNumBuddiesFromSingleBand{"max_num_buddies_from_single_band", 10, this};
94 
95  /// Maximum number of buddies of any observation sharing that observation's station ID.
96  ///
97  /// See the note next to maxTotalNumBuddies.
98  oops::Parameter<int> maxNumBuddiesWithSameStationId{
99  "max_num_buddies_with_same_station_id", 5, this};
100 
101  /// Set to true to identify pairs of buddy observations using an algorithm reproducing exactly
102  /// the algorithm used in Met Office's OPS system, but potentially skipping some valid buddy
103  /// pairs.
104  oops::Parameter<bool> useLegacyBuddyCollector{"use_legacy_buddy_collector", false, this};
105 
106  /// @}
107  /// \name Parameters controlling gross error probability updates
108  /// @{
109 
110  /// Encoding of the function mapping the latitude (in degrees) to the horizontal correlation scale
111  /// (in km).
112  ///
113  /// The function is taken to be a linear interpolation of a series of (latitude, scale) points.
114  /// The latitudes and scales at these points should be specified as keys and values of a
115  /// JSON-style map. Owing to a bug in the eckit YAML parser, the keys must be enclosed in quotes.
116  /// For example,
117  ///
118  /// horizontal_correlation_scale: { "-90": 200, "90": 100 }
119  ///
120  /// encodes a function varying linearly from 200 km at the south pole to 100 km at the north pole.
121  oops::Parameter<std::map<float, float>> horizontalCorrelationScaleInterpolationPoints{
122  "horizontal_correlation_scale", {{-90.0f, 100.f}, {90.0f, 100.f}}, this};
123 
124  /// Temporal correlation scale.
125  oops::Parameter<util::Duration> temporalCorrelationScale{"temporal_correlation_scale",
126  util::Duration("PT6H"), this};
127 
128  /// Vertical correlation scale (relates to the ratio of pressures).
129  oops::Parameter<double> verticalCorrelationScale{"vertical_correlation_scale", 6, this};
130 
131  /// Parameter used to "damp" gross error probability updates using method 1 described in section
132  /// 3.8 of the OPS Scientific Documentation Paper 2 to make the buddy check
133  /// better-behaved in data-dense areas. See the reference above for the full description.
134  oops::Parameter<double> dampingFactor1{"damping_factor_1", 1.0, this};
135 
136  /// Parameter used to "damp" gross error probability updates using method 2 described in section
137  /// 3.8 of the OPS Scientific Documentation Paper 2 to make the buddy check
138  /// better-behaved in data-dense areas. See the reference above for the full description.
139  oops::Parameter<double> dampingFactor2{"damping_factor_2", 1.0, this};
140 
141  /// Non-divergence constraint. Used only for vector variables.
142  oops::Parameter<double> nonDivergenceConstraint{"non_divergence_constraint", 1.0, this};
143 
144  /// @}
145  /// \name Miscellaneous parameters
146  /// @{
147 
148  /// Observations will be rejected if the gross error probability lies at or above this threshold.
149  oops::Parameter<float> rejectionThreshold{"rejection_threshold", 0.5, this};
150 
151  /// Tracing information will be output for observations lying within any of the specified boxes.
152  oops::Parameter<std::vector<LatLonBoxParameters>> tracedBoxes{"traced_boxes", {}, this};
153 
154  /// @}
155 };
156 
157 } // namespace ufo
158 
159 #endif // UFO_FILTERS_METOFFICEBUDDYCHECKPARAMETERS_H_
Parameters shared by all filters having a default action (typically "reject").
A box covering a specified (closed) interval of latitudes and longitudes.
oops::Parameter< float > maxLatitude
oops::Parameter< float > maxLongitude
bool contains(float latitude, float longitude) const
oops::Parameter< float > minLatitude
oops::Parameter< float > minLongitude
Options controlling the operation of the MetOfficeBuddyCheck filter.
oops::Parameter< double > verticalCorrelationScale
Vertical correlation scale (relates to the ratio of pressures).
oops::Parameter< float > searchRadius
Maximum distance between two observations that may be classified as buddies, in km.
oops::Parameter< util::Duration > temporalCorrelationScale
Temporal correlation scale.
oops::Parameter< std::map< float, float > > horizontalCorrelationScaleInterpolationPoints
oops::Parameter< double > nonDivergenceConstraint
Non-divergence constraint. Used only for vector variables.
oops::OptionalParameter< Variable > stationIdVariable
oops::Parameter< float > rejectionThreshold
Observations will be rejected if the gross error probability lies at or above this threshold.
oops::Parameter< std::vector< LatLonBoxParameters > > tracedBoxes
Tracing information will be output for observations lying within any of the specified boxes.
Definition: RunCRTM.h:27