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
63
64public:
65
67 inline
68 DualPolBioMetOp(const std::string & name, const std::string & description, const std::string & classCode) : FuzzyDetectorOp(name, description, classCode){
69 }
70
72 inline
75
76 virtual inline
77 const QuantitySelector & getSelectorDBZ() const override {
78 return selectorDBZ;
79 };
80
81 virtual inline
82 const QuantitySelector & getSelectorVRAD() const override {
83 return selectorVRAD;
84 };
85
86 virtual inline
87 const QuantitySelector & getSelectorZDR() const override {
88 return selectorZDR;
89 };
90
91 virtual inline
92 const QuantitySelector & getSelectorRHOHV() const override {
93 return selectorRHOHV;
94 };
95
96
98 virtual inline
101 ftor_t & functor = bank.clone<ftor_t>();
102 functor.set(::abs(zdrAbsThreshold), -::abs(zdrAbsThreshold), 0.0); // INVERSE
103 return functor;
104 }
105
107 virtual inline
110 ftor_t & functor = bank.clone<ftor_t>();
111 // Ensure INVERSE (decreasing step function)
112 if (rhoHVthreshold.min > rhoHVthreshold.max){
113 functor.set(rhoHVthreshold);
114 }
115 else if (rhoHVthreshold.min < rhoHVthreshold.max){
116 functor.set(rhoHVthreshold.max, rhoHVthreshold.min); // invert
117 }
118 else {
119 functor.set(rhoHVthreshold.max, 0.8 * rhoHVthreshold.max);
120 }
121 return functor;
122 }
123
124
125
126
127};
128
130
133class BirdOp: public DualPolBioMetOp {
134
135public:
136
147// BirdOp(double dbzPeak = -5.0, double vradDevMin = 5.0, double rhoHVmax = 0.7, double zdrAbsMin = 2.0, double windowWidth = 2500, double windowHeight = 5.0) :
148 BirdOp(double dbzPeak = -10.0, double vradDevMin = 1.0, double rhoHVmax = 0.99, double zdrAbsMin = 1.0, double windowWidth = 2500, double windowHeight = 5.0) :
149
150 DualPolBioMetOp(__FUNCTION__, "Estimates bird probability from DBZH, VRAD, RhoHV and ZDR.", "nonmet.biol.bird"){
151
152 init(dbzPeak, vradDevMin, rhoHVmax, zdrAbsMin, windowWidth, windowHeight);
153
154 };
155
157 inline
159 this->parameters.copyStruct(op.getParameters(), op, *this);
160 };
161
162 virtual inline
163 ~BirdOp(){};
164
165 virtual
166 void init(double dbzPeak, double vradDevMax, double rhoHVmax, double zdrDevMin, double windowWidth, double windowHeight);
167
168 virtual inline
169 drain::Fuzzifier<double> & getFuzzifierDBZ(LocalFunctorBank & bank) const override {
170
171 drain::Logger mout(__FUNCTION__, getName());
172 typedef drain::FuzzyBell2<double> ftor_t;
173 // typedef drain::FuzzyStep<double> ftor_t;
174 ftor_t & functor = bank.clone<ftor_t>();
175
176 if (dbzParam.min < dbzParam.max){
177 functor.set(dbzParam);
178 }
179 else if (dbzParam.min > dbzParam.max){ // INVERSE
180 functor.set(dbzParam.max, dbzParam.min);
181 }
182 else{
183 // span out
184 functor.set(dbzParam.min+15.0, dbzParam.max-15.0);
185 }
186
187 /*
188 typedef drain::FuzzyStep<double> ftor_t;
189 ftor_t & functor = bank.clone<ftor_t>();
190 if (dbzParam.min > dbzParam.max){ // INVERSE
191 // mout.warn("Ok, INVERSE:", dbzParam);
192 functor.set(dbzParam);
193 }
194 else if (dbzParam.min < dbzParam.max){
195 // mout.warn("Ok, reversing:", dbzParam.max, '-', dbzParam.min);
196 functor.set(dbzParam.max, dbzParam.min);
197 }
198 else {
199 // span out
200 functor.set(dbzParam.min+15.0, dbzParam.max-15.0);
201 }
202 */
203 return functor;
204 }
205
206 // Birds are expected to move independently and fast
207 virtual inline
208 drain::Fuzzifier<double> & getFuzzifierVRAD(LocalFunctorBank & bank) const override {
209 typedef drain::FuzzyStep<double> ftor_t;
210 ftor_t & functor = bank.clone<ftor_t>();
211 functor.set(vradDevThreshold-1.0, vradDevThreshold+1.0);
212 return functor;
213 }
214
215 /*
216 virtual inline
217 drain::Fuzzifier<double> & getFuzzifierVRAD(LocalFunctorBank & bank) const override {
218 typedef drain::FuzzyStep<double> ftor_t;
219 ftor_t & functor = bank.clone<ftor_t>();
220 functor.set(vradDevThreshold-1.0, vradDevThreshold+1.0);
221 return functor;
222 }
223 */
224
225};
226
227
230
231public:
232
233 // BIRD: double dbzPeak = -5.0, double vradDevMin = 5.0, double rhoHVmax = 0.7, double zdrAbsMin = 2.0, double windowWidth = 2500, double windowHeight = 5.0
234
243 // InsectOp(double dbzPeak = -10.0, double vradDevMax = +5.0, double rhoHVmax = 0.7, double zdrAbsMin = 3.0, double windowWidth = 2500, double windowHeight = 5.0) :
244 InsectOp(double dbzMax = 0.0, double vradDevMax = +5.0, double rhoHVmax = 0.99, double zdrAbsMin = 3.0, double windowWidth = 2500, double windowHeight = 5.0) :
245 DualPolBioMetOp(__FUNCTION__, "Probability of insects, based on DBZH, VRAD, RhoHV and ZDR.", "nonmet.biol.insect"){
246 init(dbzMax, vradDevMax, rhoHVmax, zdrAbsMin, windowWidth, windowHeight);
247 };
248
251 this->parameters.copyStruct(op.getParameters(), op, *this);
252 }
253
254 virtual
255 void init(double dbzMax, double vradDevMax, double rhoHVmax, double zdrDevMin, double windowWidth, double windowHeight);
256
257 virtual inline
258 drain::Fuzzifier<double> & getFuzzifierDBZ(LocalFunctorBank & bank) const override {
260 ftor_t & functor = bank.clone<ftor_t>();
261 if (dbzParam.min > dbzParam.max){ // INVERSE
262 functor.set(dbzParam);
263 }
264 else if (dbzParam.min < dbzParam.max){
265 functor.set(dbzParam.max, dbzParam.min);
266 }
267 else {
268 // span out
269 functor.set(dbzParam.min+5.0, dbzParam.max-5.0);
270 }
271 return functor;
272 }
273
274 // Insects are expected to float, mostly
275 virtual inline
276 drain::Fuzzifier<double> & getFuzzifierVRAD(LocalFunctorBank & bank) const override {
277 typedef drain::FuzzyStep<double> ftor_t;
278 ftor_t & functor = bank.clone<ftor_t>();
279 functor.set(vradDevThreshold+1.0, vradDevThreshold-1.0);
280 return functor;
281 }
282
283 /*
284 virtual inline
285 drain::Fuzzifier<double> & getFuzzifierVRAD(LocalFunctorBank & bank) const override {
286 typedef drain::FuzzyStep<double> ftor_t;
287 ftor_t & functor = bank.clone<ftor_t>();
288 functor.set(vradDevThreshold+1.0, vradDevThreshold-1.0); // INVERSE
289 return functor;
290 }
291 */
292
293};
294
295
296}
297
298#endif
299
300// Rack
const std::string description
Brief, human-readable description of this bean.
Definition BeanLike.h:309
map_t parameters
Parameters (name -> linked variable), typically linked to member variables of the derived class.
Definition BeanLike.h:313
virtual const std::string & getName() const
Return the name of an instance.
Definition BeanLike.h:89
const map_t & getParameters() const
Returns the parameter map (const access).
Definition BeanLike.h:116
const std::string name
Name of this bean, typically also the name of the (derived) class.
Definition BeanLike.h:306
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:326
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:412
DOC: Add class description.
Definition DualPolBioMetOp.h:133
BirdOp(const BirdOp &op)
Copy constructor.
Definition DualPolBioMetOp.h:158
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:148
virtual void init(double dbzPeak, double vradDevMax, double rhoHVmax, double zdrDevMin, double windowWidth, double windowHeight)
Definition DualPolBioMetOp.cpp:47
A map of radar data, indexed by quantity code (DBZH, VRAD, etc).
Definition Data.h:1293
DOC: Add class description.
Definition DualPolBioMetOp.h:62
DualPolBioMetOp(const std::string &name, const std::string &description, const std::string &classCode)
Constructor.
Definition DualPolBioMetOp.h:68
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:99
DualPolBioMetOp(const DualPolBioMetOp &op)
Copy constructor.
Definition DualPolBioMetOp.h:73
virtual drain::Fuzzifier< double > & getFuzzifierRHOHV(LocalFunctorBank &bank) const override
Fuzzifier of RHOHV shows response on values lower than 1.0.
Definition DualPolBioMetOp.h:108
Base class for BirdOp and InsectOp.
Definition FuzzyDetectorOp.h:79
DOC: Add class description.
Definition DualPolBioMetOp.h:229
InsectOp(const InsectOp &op)
Copy constructor.
Definition DualPolBioMetOp.h:250
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:244
DOC: Add class description.
Definition FuzzyDetectorOp.h:54
Namespace for images and image processing tools.
Definition AccumulationArray.cpp:45
Definition AltitudeOp.cpp:42