Loading...
Searching...
No Matches
EchoTopOp.h
1/*
2
3MIT License
4
5Copyright (c) 2024 FMI Open Development / Markus Peura, first.last@fmi.fi
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software and associated documentation files (the "Software"), to deal
9in the Software without restriction, including without limitation the rights
10to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11copies of the Software, and to permit persons to whom the Software is
12furnished to do so, subject to the following conditions:
13
14The above copyright notice and this permission notice shall be included in all
15copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23SOFTWARE.
24
25*/
26/*
27Part of Rack development has been done in the BALTRAD projects part-financed
28by the European Union (European Regional Development Fund and European
29Neighbourhood Partnership Instrument, Baltic Sea Region Programme 2007-2013)
30*/
31
32#ifndef ECHO_TOP2_OP
33#define ECHO_TOP2_OP
34
35
36#include "radar/RadarWindows.h"
37
38#include "PolarProductOp.h"
39
40using namespace drain::image;
41
42namespace rack {
43
45
48struct Measurement : public drain::UniTuple<double,2> {
49
50 double & reflectivity;
51 double & height;
52
53 Measurement(double reflectivity=NAN, double height=0.0) : reflectivity(this->next()), height(this->next()){
54 this->set(reflectivity, height);
55 };
56
57 Measurement(const Measurement & p): reflectivity(this->next()), height(this->next()){
58 this->set(p);
59 };
60};
61
62/*
63struct Measurement {
64
66 const Data<src_t> * dataPtr = nullptr;
67
69 size_t binIndex = 0;
70
72 double height = 0;
73
75 double reflectivity = NAN;
76
78 // double quality = 0.0;
79};
80*/
81
85template <class T>
86struct MethodWeights : public drain::UniTuple<T,5> {
87
88 typedef T value_t;
89
92 T & interpolation_dry; // beam over Z < Z_thr
93 T & extrapolation_up; // truncated strong echo underShooting highest beam Z > Z_thr
94 T & extrapolation_down;
95 T & clear; // same as undetect, but needs a quality index value
96 T error = 0; // needs a quality index value (0)
97
98 MethodWeights() : interpolation(this->next()), interpolation_dry(this->next()), extrapolation_up(this->next()), extrapolation_down(this->next()), clear(this->next()){
99 };
100
101 template<typename ... TT>
102 MethodWeights(const TT &... args) : interpolation(this->next()), interpolation_dry(this->next()), extrapolation_up(this->next()), extrapolation_down(this->next()), clear(this->next()){
103 this->set(args...);
104 };
105
106 MethodWeights(const MethodWeights & p): drain::UniTuple<double,5>(p),
107 interpolation(this->next()), interpolation_dry(this->next()), extrapolation_up(this->next()), extrapolation_down(this->next()), clear(this->next()) {
108 };
109
110 /*
111 inline
112 bool useInterpolation() const {
113 return (interpolation > overShooting);
114 }
115 */
116
117
118};
119
120
121
123
127
128public:
129
130 EchoTopOp(double threshold = 20.0);
131
132 EchoTopOp(const EchoTopOp & op);
133
134
135 virtual inline
136 ~EchoTopOp(){};
137
138 // TEST
139 void computeSingleProduct(const DataSetMap<src_t> & srcSweeps, DataSet<dst_t> & dstProduct) const override;
140
142
146 static inline
147 double getSlope(const Measurement & m1, const Measurement & m2){
148 return (m1.height - m2.height) / (m1.reflectivity - m2.reflectivity);
149 }
150
151 /*
152 static inline
153 double getSlope(double heightStronger, double heightWeaker, double reflectivityStronger, double reflectivityWeaker){
154 return (heightStronger - heightWeaker) / (reflectivityStronger - reflectivityWeaker);
155 }
156 */
157
158
159protected:
160
161 // Main parameter: dBZ threshold.
162 double threshold = 0.0;
163
166
168 Measurement reference = {-50.0, 15000.0};
169
171 MethodWeights<double> weights = {1.0, 0.8, 0.6, 0.4, 0.2};
172
174 double weightDecay = 20.0;
175
177 RadarWindowGeom avgWindow; // = {0.0,0.0}; // check tuple init, + assignment
178
180 bool EXTENDED_OUTPUT = true;
181
183
184};
185
186} // rack::
187
189/*
190typedef enum {
191 / ** Unset (not processsed) * /
192 UNDEFINED=0,
193 / ** Internal error in the computation * /
194 ERROR=16,
195 / ** No echo found * /
196 CLEAR=64,
197 / ** The highest bin exceeds the threshold -> use reference point * /
198 UNDERSHOOTING=96,
199 / ** The bin exceeding the Z threshold has an \c undetect ("dry") bin above -> replace \c undetect with low Z (dB) * /
200 OVERSHOOTING=128,
201 WEAK=192, /// Echoes only below threshold detected
202 / ** The threshold value was passed between adjacent beams, hence can be interpolated * /
203 INTERPOLATION=250
204} Reliability;
205
206typedef drain::EnumFlagger<drain::SingleFlagger<Reliability> > reliabilityFlagger;
207*/
208
209
210#endif
Tuple of N elements of type T.
Definition UniTuple.h:65
Definition Data.h:1370
A map of radar data, indexed by quantity code (DBZH, VRAD, etc).
Definition Data.h:1215
Definition EchoTopOp.h:126
double undetectReflectivity
Unless NaN, use the value like a measured dBZ.
Definition EchoTopOp.h:165
double weightDecay
Span for linear decay of weights towards zero.
Definition EchoTopOp.h:174
void computeSingleProduct(const DataSetMap< src_t > &srcSweeps, DataSet< dst_t > &dstProduct) const override
Traverse the data applicable for this product and create new, processed data (volume or polar product...
Definition EchoTopOp.cpp:372
RadarWindowGeom avgWindow
Optional smoothin window. Width (metres) and height (degrees) (also used for reference)
Definition EchoTopOp.h:177
static double getSlope(const Measurement &m1, const Measurement &m2)
Definition EchoTopOp.h:147
Measurement reference
Virtual measurement high aloft, towards which reflectivity is expected to decrease.
Definition EchoTopOp.h:168
MethodWeights< double > weights
Quality weights for interpolative, dry-interpolative, max-limited, min-limited.
Definition EchoTopOp.h:171
Base class for flat (2D) products computed in the polar coordinate system. Volume is used as input.
Definition PolarProductOp.h:59
Like pixel window, but width is metres and height is degrees.
Definition RadarWindows.h:65
Namespace for images and image processing tools.
Definition AccumulationArray.cpp:45
Definition DataSelector.cpp:1277
Definition DataSelector.cpp:44
A single measurement (bin), with height coordinate and measurement value (reflectivity).
Definition EchoTopOp.h:48
Definition EchoTopOp.h:86
T & interpolation
Highest to lowest certainty.
Definition EchoTopOp.h:91