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