Loading...
Searching...
No Matches
DualPolBioMetOp.h
1/*
2
3MIT License
4
5Copyright (c) 2017 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#ifndef RACK_GLIDER_OP
32#define RACK_GLIDER_OP
33
34#include <string>
35
36#include <drain/image/Image.h>
37#include <drain/image/Window.h>
38#include <drain/imageops/ImageOp.h>
39
40
41#include "FuzzyDetectorOp.h"
42
43// RAISED
44/*
45#include <drain/imageops/SlidingWindowOp.h>
46#include "radar/Analysis.h"
47#include "radar/Doppler.h"
48
49//#include "data/Data.h"
50#include "andre/DetectorOp.h"
51// #include <drain/util/FunctorPack.h>
52// #include <drain/util/Fuzzy.h>
53// RAISED
54*/
55
56
57
58namespace rack {
59
60using namespace drain::image;
61
62
64
65public:
66
67 inline
68 DualPolBioMetOp(const std::string & name, const std::string & description, const std::string & classCode) : FuzzyDetectorOp(name, description, classCode){
69 }
70
71 inline
73 }
74
75 virtual inline
76 const QuantitySelector & getSelectorDBZ() const override {
77 return selectorDBZ;
78 };
79
80 virtual inline
81 const QuantitySelector & getSelectorVRAD() const override {
82 return selectorVRAD;
83 };
84
85 virtual inline
86 const QuantitySelector & getSelectorZDR() const override {
87 return selectorZDR;
88 };
89
90 virtual inline
91 const QuantitySelector & getSelectorRHOHV() const override {
92 return selectorRHOHV;
93 };
94
95
97 virtual inline
99 typedef drain::FuzzyTriangle<double> ftor_t;
100 ftor_t & functor = bank.clone<ftor_t>();
101 functor.set(::abs(zdrAbsThreshold), -::abs(zdrAbsThreshold), 0.0); // INVERSE
102 return functor;
103 }
104
106 virtual inline
108 typedef drain::FuzzyStep<double> ftor_t;
109 ftor_t & functor = bank.clone<ftor_t>();
110 // Ensure INVERSE (decreasing step function)
111 if (rhoHVthreshold.min > rhoHVthreshold.max){
112 functor.set(rhoHVthreshold);
113 }
114 else if (rhoHVthreshold.min < rhoHVthreshold.max){
115 functor.set(rhoHVthreshold.max, rhoHVthreshold.min); // invert
116 }
117 else {
118 functor.set(rhoHVthreshold.max, 0.8 * rhoHVthreshold.max);
119 }
120 return functor;
121 }
122
123
124
125
126};
127
129
132class BirdOp: public DualPolBioMetOp {
133
134public:
135
146// BirdOp(double dbzPeak = -5.0, double vradDevMin = 5.0, double rhoHVmax = 0.7, double zdrAbsMin = 2.0, double windowWidth = 2500, double windowHeight = 5.0) :
147 BirdOp(double dbzPeak = -10.0, double vradDevMin = 1.0, double rhoHVmax = 0.99, double zdrAbsMin = 1.0, double windowWidth = 2500, double windowHeight = 5.0) :
148
149 DualPolBioMetOp(__FUNCTION__, "Estimates bird probability from DBZH, VRAD, RhoHV and ZDR.", "nonmet.biol.bird"){
150
151 init(dbzPeak, vradDevMin, rhoHVmax, zdrAbsMin, windowWidth, windowHeight);
152
153 };
154
155 inline
156 BirdOp(const BirdOp & op) : DualPolBioMetOp(op) {
157 this->parameters.copyStruct(op.getParameters(), op, *this);
158 };
159
160 virtual inline
161 ~BirdOp(){};
162
163 virtual
164 void init(double dbzPeak, double vradDevMax, double rhoHVmax, double zdrDevMin, double windowWidth, double windowHeight);
165
166 virtual inline
167 drain::Fuzzifier<double> & getFuzzifierDBZ(LocalFunctorBank & bank) const override {
168
169 drain::Logger mout(__FUNCTION__, getName());
170 typedef drain::FuzzyBell2<double> ftor_t;
171 // typedef drain::FuzzyStep<double> ftor_t;
172 ftor_t & functor = bank.clone<ftor_t>();
173
174 if (dbzParam.min < dbzParam.max){
175 functor.set(dbzParam);
176 }
177 else if (dbzParam.min > dbzParam.max){ // INVERSE
178 functor.set(dbzParam.max, dbzParam.min);
179 }
180 else{
181 // span out
182 functor.set(dbzParam.min+15.0, dbzParam.max-15.0);
183 }
184
185 /*
186 typedef drain::FuzzyStep<double> ftor_t;
187 ftor_t & functor = bank.clone<ftor_t>();
188 if (dbzParam.min > dbzParam.max){ // INVERSE
189 // mout.warn("Ok, INVERSE:", dbzParam);
190 functor.set(dbzParam);
191 }
192 else if (dbzParam.min < dbzParam.max){
193 // mout.warn("Ok, reversing:", dbzParam.max, '-', dbzParam.min);
194 functor.set(dbzParam.max, dbzParam.min);
195 }
196 else {
197 // span out
198 functor.set(dbzParam.min+15.0, dbzParam.max-15.0);
199 }
200 */
201 return functor;
202 }
203
204 // Birds are expected to move independently and fast
205 virtual inline
206 drain::Fuzzifier<double> & getFuzzifierVRAD(LocalFunctorBank & bank) const override {
207 typedef drain::FuzzyStep<double> ftor_t;
208 ftor_t & functor = bank.clone<ftor_t>();
209 functor.set(vradDevThreshold-1.0, vradDevThreshold+1.0);
210 return functor;
211 }
212
213 /*
214 virtual inline
215 drain::Fuzzifier<double> & getFuzzifierVRAD(LocalFunctorBank & bank) const override {
216 typedef drain::FuzzyStep<double> ftor_t;
217 ftor_t & functor = bank.clone<ftor_t>();
218 functor.set(vradDevThreshold-1.0, vradDevThreshold+1.0);
219 return functor;
220 }
221 */
222
223};
224
225
227
228public:
229
230 // BIRD: double dbzPeak = -5.0, double vradDevMin = 5.0, double rhoHVmax = 0.7, double zdrAbsMin = 2.0, double windowWidth = 2500, double windowHeight = 5.0
231
242 // InsectOp(double dbzPeak = -10.0, double vradDevMax = +5.0, double rhoHVmax = 0.7, double zdrAbsMin = 3.0, double windowWidth = 2500, double windowHeight = 5.0) :
243 InsectOp(double dbzMax = 0.0, double vradDevMax = +5.0, double rhoHVmax = 0.99, double zdrAbsMin = 3.0, double windowWidth = 2500, double windowHeight = 5.0) :
244 DualPolBioMetOp(__FUNCTION__, "Probability of insects, based on DBZH, VRAD, RhoHV and ZDR.", "nonmet.biol.insect"){
245 init(dbzMax, vradDevMax, rhoHVmax, zdrAbsMin, windowWidth, windowHeight);
246 };
247
248 InsectOp(const InsectOp & op) : DualPolBioMetOp(op) {
249 this->parameters.copyStruct(op.getParameters(), op, *this);
250 }
251
252 virtual
253 void init(double dbzMax, double vradDevMax, double rhoHVmax, double zdrDevMin, double windowWidth, double windowHeight);
254
255 virtual inline
256 drain::Fuzzifier<double> & getFuzzifierDBZ(LocalFunctorBank & bank) const override {
257 typedef drain::FuzzyStep<double> ftor_t;
258 ftor_t & functor = bank.clone<ftor_t>();
259 if (dbzParam.min > dbzParam.max){ // INVERSE
260 functor.set(dbzParam);
261 }
262 else if (dbzParam.min < dbzParam.max){
263 functor.set(dbzParam.max, dbzParam.min);
264 }
265 else {
266 // span out
267 functor.set(dbzParam.min+5.0, dbzParam.max-5.0);
268 }
269 return functor;
270 }
271
272 // Insects are expected to float, mostly
273 virtual inline
274 drain::Fuzzifier<double> & getFuzzifierVRAD(LocalFunctorBank & bank) const override {
275 typedef drain::FuzzyStep<double> ftor_t;
276 ftor_t & functor = bank.clone<ftor_t>();
277 functor.set(vradDevThreshold+1.0, vradDevThreshold-1.0);
278 return functor;
279 }
280
281 /*
282 virtual inline
283 drain::Fuzzifier<double> & getFuzzifierVRAD(LocalFunctorBank & bank) const override {
284 typedef drain::FuzzyStep<double> ftor_t;
285 ftor_t & functor = bank.clone<ftor_t>();
286 functor.set(vradDevThreshold+1.0, vradDevThreshold-1.0); // INVERSE
287 return functor;
288 }
289 */
290
291};
292
293
294}
295
296#endif
297
298// Rack
virtual const std::string & getName() const
Return the name of an instance.
Definition BeanLike.h:82
A base class for fuzzy functions; also an unary functor.
Definition Fuzzy.h:55
A smooth symmetric peak function that resembles the Gaussian bell curve. Diminishes quicker than Fuzz...
Definition Fuzzy.h:470
A basic, linear transition from 0 to scale between (start) and (end) .
Definition Fuzzy.h:154
A basic triangular peak function with linear around the peak.
Definition Fuzzy.h:262
LogSourc e is the means for a function or any program segment to "connect" to a Log.
Definition Log.h:312
void copyStruct(const ReferenceMap &m, const T &src, T &dst, extLinkPolicy policy=RESERVE)
Experimental. Copies references and values of a structure to another.
Definition ReferenceMap.h:407
Definition DualPolBioMetOp.h:132
BirdOp(double dbzPeak=-10.0, double vradDevMin=1.0, double rhoHVmax=0.99, double zdrAbsMin=1.0, double windowWidth=2500, double windowHeight=5.0)
Definition DualPolBioMetOp.h:147
virtual void init(double dbzPeak, double vradDevMax, double rhoHVmax, double zdrDevMin, double windowWidth, double windowHeight)
Definition DualPolBioMetOp.cpp:62
Definition DualPolBioMetOp.h:63
virtual drain::Fuzzifier< double > & getFuzzifierZDR(LocalFunctorBank &bank) const override
Fuzzifier of ZDR is designed to detect objects that have horizontal or vertical span.
Definition DualPolBioMetOp.h:98
virtual drain::Fuzzifier< double > & getFuzzifierRHOHV(LocalFunctorBank &bank) const override
Fuzzifier of RHOHV shows response on values lower than 1.0.
Definition DualPolBioMetOp.h:107
Base class for BirdOp and InsectOp.
Definition FuzzyDetectorOp.h:90
Definition DualPolBioMetOp.h:226
InsectOp(double dbzMax=0.0, double vradDevMax=+5.0, double rhoHVmax=0.99, double zdrAbsMin=3.0, double windowWidth=2500, double windowHeight=5.0)
Definition DualPolBioMetOp.h:243
Definition FuzzyDetectorOp.h:65
Namespace for images and image processing tools.
Definition AccumulationArray.cpp:45
Definition DataSelector.cpp:44