UFO
GaussianThinningParameters.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_GAUSSIANTHINNINGPARAMETERS_H_
9 #define UFO_FILTERS_GAUSSIANTHINNINGPARAMETERS_H_
10 
11 #include <string>
12 #include <utility>
13 
14 #include "eckit/exception/Exceptions.h"
15 #include "oops/util/parameters/OptionalParameter.h"
16 #include "oops/util/parameters/Parameter.h"
17 #include "oops/util/parameters/Parameters.h"
18 #include "ufo/utils/Constants.h"
20 
21 namespace eckit {
22  class Configuration;
23 }
24 
25 namespace ufo {
26 
27 enum class DistanceNorm {
29 };
30 
33  static constexpr char enumTypeName[] = "DistanceNorm";
34  static constexpr util::NamedEnumerator<DistanceNorm> namedValues[] = {
35  { DistanceNorm::GEODESIC, "geodesic" },
36  { DistanceNorm::MAXIMUM, "maximum" }
37  };
38 };
39 
40 } // namespace ufo
41 
42 namespace oops {
43 
44 template <>
45 struct ParameterTraits<ufo::DistanceNorm> :
46  public EnumParameterTraits<ufo::DistanceNormParameterTraitsHelper>
47 {};
48 
49 } // namespace oops
50 
51 namespace ufo {
52 
53 /// \brief Options controlling the operation of the Gaussian_Thinning filter.
54 class GaussianThinningParameters : public oops::Parameters {
55  OOPS_CONCRETE_PARAMETERS(GaussianThinningParameters, Parameters)
56 
57  public:
58  // Horizontal grid
59 
60  /// Cell size (in km) along the meridians. Thinning in the horizontal direction is disabled if
61  /// this parameter is negative.
62  // FIXME(wsmigaj): for consistency with vertical thinning, I think it would be better to
63  // interpret absence of the horizontal_mesh setting as "don't do horizontal thinning"
64  // rather than using an arbitrary default grid size. Leaving things as they are for backward
65  // compatibility, for now.
66  oops::Parameter<float> horizontalMesh{"horizontal_mesh", defaultHorizontalMesh(), this};
67  /// True to use a reduced grid, with fewer cells at high latitudes.
68  /// False to use a regular grid, with the same number of cells at all latitudes.
69  oops::Parameter<bool> useReducedHorizontalGrid{"use_reduced_horizontal_grid", true, this};
70  /// True to set the number of zonal bands so that the band width is as close as possible to
71  /// \c horizontal_mesh, and the number of bins in each zonal band so that the bin width in the
72  /// zonal direction is as close as possible to that in the meridional direction.
73  /// False to set the number of zonal bands so that the band width is as small as possible, but
74  /// no smaller than \c horizontal_mesh, and the bin width in the zonal direction is as small as
75  /// possible, but no smaller than in the meridional direction.
76  oops::Parameter<bool> roundHorizontalBinCountToNearest{
77  "round_horizontal_bin_count_to_nearest", false, this};
78 
79  // Vertical grid
80 
81  /// Cell size (in Pa) in the vertical direction. Thinning in the vertical direction is disabled
82  /// if this parameter is not specified or negative.
83  oops::Parameter<float> verticalMesh{"vertical_mesh", -1.0f, this};
84  /// Lower bound of the pressure interval split into cells of size \c vertical_mesh.
85  oops::Parameter<float> verticalMin{"vertical_min", 100.0f, this};
86  /// Upper bound of the pressure interval split into cells of size \c vertical_mesh.
87  /// This parameter is rounded upwards to the nearest multiple of \c vertical_mesh starting from
88  /// \c vertical_min.
89  oops::Parameter<float> verticalMax{"vertical_max", 110000.0f, this};
90 
91  // Temporal grid
92 
93  /// Cell size in the temporal direction. Temporal thinning is disabled if this this parameter is
94  /// not specified or set to 0.
95  oops::OptionalParameter<util::Duration> timeMesh{"time_mesh", this};
96  /// Lower bound of the time interval split into cells of size \c time_mesh. Temporal thinning is
97  /// disabled if this parameter is not specified.
98  oops::OptionalParameter<util::DateTime> timeMin{"time_min", this};
99  /// Upper bound of the time interval split into cells of size \c time_mesh.
100  /// This parameter is rounded upwards to the nearest multiple of \c time_mesh starting from
101  /// \c time_min. Temporal thinning is disabled if this parameter is not specified.
102  oops::OptionalParameter<util::DateTime> timeMax{"time_max", this};
103 
104  // Observation categories
105 
106  /// Variable storing integer-valued IDs associated with observations. Observations belonging
107  /// to different categories are thinned separately.
108  oops::OptionalParameter<Variable> categoryVariable{"category_variable", this};
109 
110  // Selection of observations to retain
111 
112  /// Variable storing observation priorities. Among all observations in a cell, only those with
113  /// the highest priority are considered as candidates for retaining. If not specified, all
114  /// observations are assumed to have equal priority.
115  oops::OptionalParameter<Variable> priorityVariable{"priority_variable", this};
116 
117  /// Determines which of the highest-priority observations lying in a cell is retained.
118  /// Allowed values:
119  /// - \c geodesic: retain the observation closest to the cell centre in the horizontal direction
120  /// (air pressure and time are ignored)
121  /// - \c maximum: retain the observation lying furthest from the cell's bounding box in the
122  /// system of coordinates in which the cell is a unit cube (all dimensions along which thinning
123  /// is enabled are taken into account).
124  oops::Parameter<DistanceNorm> distanceNorm{"distance_norm", DistanceNorm::GEODESIC, this};
125 
126  private:
127  static float defaultHorizontalMesh() {
128  return static_cast<float>(2 * M_PI * Constants::mean_earth_rad / 360.0);
129  }
130 };
131 
132 } // namespace ufo
133 
134 #endif // UFO_FILTERS_GAUSSIANTHINNINGPARAMETERS_H_
oops
Definition: GaussianThinningParameters.h:42
ufo::GaussianThinningParameters::distanceNorm
oops::Parameter< DistanceNorm > distanceNorm
Definition: GaussianThinningParameters.h:124
ufo::GaussianThinningParameters::verticalMax
oops::Parameter< float > verticalMax
Definition: GaussianThinningParameters.h:89
ufo::GaussianThinningParameters::defaultHorizontalMesh
static float defaultHorizontalMesh()
Definition: GaussianThinningParameters.h:127
ufo::GaussianThinningParameters::roundHorizontalBinCountToNearest
oops::Parameter< bool > roundHorizontalBinCountToNearest
Definition: GaussianThinningParameters.h:76
ufo::GaussianThinningParameters::verticalMin
oops::Parameter< float > verticalMin
Lower bound of the pressure interval split into cells of size vertical_mesh.
Definition: GaussianThinningParameters.h:85
ufo
Definition: RunCRTM.h:27
ufo::GaussianThinningParameters::categoryVariable
oops::OptionalParameter< Variable > categoryVariable
Definition: GaussianThinningParameters.h:108
ufo::DistanceNormParameterTraitsHelper::enumTypeName
static constexpr char enumTypeName[]
Definition: GaussianThinningParameters.h:33
ufo::DistanceNorm::MAXIMUM
@ MAXIMUM
ufo::GaussianThinningParameters::useReducedHorizontalGrid
oops::Parameter< bool > useReducedHorizontalGrid
Definition: GaussianThinningParameters.h:69
ufo::Constants::mean_earth_rad
static constexpr double mean_earth_rad
Definition: Constants.h:39
ufo::GaussianThinningParameters::horizontalMesh
oops::Parameter< float > horizontalMesh
Definition: GaussianThinningParameters.h:66
ufo::DistanceNorm
DistanceNorm
Definition: GaussianThinningParameters.h:27
eckit
Forward declarations.
Definition: ObsAtmSfcInterp.h:20
ufo::GaussianThinningParameters::priorityVariable
oops::OptionalParameter< Variable > priorityVariable
Definition: GaussianThinningParameters.h:115
ufo::GaussianThinningParameters
Options controlling the operation of the Gaussian_Thinning filter.
Definition: GaussianThinningParameters.h:54
ufo::DistanceNormParameterTraitsHelper::namedValues
static constexpr util::NamedEnumerator< DistanceNorm > namedValues[]
Definition: GaussianThinningParameters.h:34
ufo::GaussianThinningParameters::verticalMesh
oops::Parameter< float > verticalMesh
Definition: GaussianThinningParameters.h:83
ufo::GaussianThinningParameters::timeMin
oops::OptionalParameter< util::DateTime > timeMin
Definition: GaussianThinningParameters.h:98
ufo::GaussianThinningParameters::timeMax
oops::OptionalParameter< util::DateTime > timeMax
Definition: GaussianThinningParameters.h:102
ufo::DistanceNorm::GEODESIC
@ GEODESIC
ufo::DistanceNormParameterTraitsHelper
Definition: GaussianThinningParameters.h:31
Constants.h
ufo::DistanceNormParameterTraitsHelper::EnumType
DistanceNorm EnumType
Definition: GaussianThinningParameters.h:32
ufo::GaussianThinningParameters::timeMesh
oops::OptionalParameter< util::Duration > timeMesh
Definition: GaussianThinningParameters.h:95
ParameterTraitsVariable.h