UFO
ObsLocParameters.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 2020-2021 UCAR
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_OBSLOCALIZATION_OBSLOCPARAMETERS_H_
9 #define UFO_OBSLOCALIZATION_OBSLOCPARAMETERS_H_
10 
11 #include <string>
12 #include <utility>
13 
14 #include "eckit/exception/Exceptions.h"
15 #include "eckit/geometry/KPoint.h"
16 #include "eckit/geometry/Point2.h"
17 #include "eckit/geometry/UnitSphere.h"
18 
19 #include "oops/util/parameters/OptionalParameter.h"
20 #include "oops/util/parameters/Parameter.h"
21 #include "oops/util/parameters/Parameters.h"
22 #include "oops/util/parameters/RequiredParameter.h"
23 
24 namespace eckit {
25  class Configuration;
26 }
27 
28 namespace ufo {
29 
30 enum class DistanceType {
32 };
33 
34 enum class SearchMethod {
36 };
37 
40  static constexpr char enumTypeName[] = "DistanceType";
41  static constexpr util::NamedEnumerator<DistanceType> namedValues[] = {
42  { DistanceType::GEODESIC, "geodesic" },
43  { DistanceType::CARTESIAN, "cartesian" }
44  };
45 };
46 
49  static constexpr char enumTypeName[] = "SearchMethod";
50  static constexpr util::NamedEnumerator<SearchMethod> namedValues[] = {
51  { SearchMethod::BRUTEFORCE, "brute_force" },
52  { SearchMethod::KDTREE, "kd_tree" }
53  };
54 };
55 
56 } // namespace ufo
57 
58 namespace oops {
59 
60 /// Extraction of DistanceType parameters from config
61 template <>
62 struct ParameterTraits<ufo::DistanceType> :
63  public EnumParameterTraits<ufo::DistanceTypeParameterTraitsHelper>
64 {};
65 
66 
67 /// Extraction of SearchMethod parameters from config
68 template <>
69 struct ParameterTraits<ufo::SearchMethod> :
70  public EnumParameterTraits<ufo::SearchMethodParameterTraitsHelper>
71 {};
72 
73 } // namespace oops
74 
75 namespace ufo {
76 
77 /// \brief Options controlling local observations subsetting
78 class ObsLocParameters : public oops::Parameters {
79  OOPS_CONCRETE_PARAMETERS(ObsLocParameters, Parameters)
80 
81  public:
82  /// Localization lengthscale (find all obs within the distance from reference point)
83  oops::RequiredParameter<double> lengthscale{"lengthscale", this};
84 
85  /// Method for searching for nearest points: brute force or KD-tree
86  oops::Parameter<SearchMethod> searchMethod{"search method", SearchMethod::BRUTEFORCE, this};
87 
88  /// Maximum number of obs
89  oops::OptionalParameter<int> maxnobs{"max nobs", this};
90 
91  /// Distance calculation type: geodesic (on sphere) or cartesian (euclidian)
92  /// Default: geodesic
93  oops::Parameter<DistanceType> distanceType{"distance type", DistanceType::GEODESIC, this};
94 
95  /// returns distance between points \p p1 and \p p2, depending on the
96  /// distance calculation type distanceType
97  double distance(const eckit::geometry::Point2 & p1, const eckit::geometry::Point2 & p2) const {
100  } else {
102  return p1.distance(p2);
103  }
104  }
105 
106  // Earth radius in m
107  static constexpr double radius_earth = 6.371e6;
108 };
109 
110 } // namespace ufo
111 
112 #endif // UFO_OBSLOCALIZATION_OBSLOCPARAMETERS_H_
Options controlling local observations subsetting.
static constexpr double radius_earth
oops::OptionalParameter< int > maxnobs
Maximum number of obs.
oops::RequiredParameter< double > lengthscale
Localization lengthscale (find all obs within the distance from reference point)
oops::Parameter< DistanceType > distanceType
double distance(const eckit::geometry::Point2 &p1, const eckit::geometry::Point2 &p2) const
oops::Parameter< SearchMethod > searchMethod
Method for searching for nearest points: brute force or KD-tree.
Forward declarations.
Definition: ObsAodExt.h:21
float distance(const Point &a, const Point &b)
Returns the distance between the two cartesian-mapped Point arguments
Definition: RunCRTM.h:27
static constexpr util::NamedEnumerator< DistanceType > namedValues[]
static constexpr util::NamedEnumerator< SearchMethod > namedValues[]