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