Loading...
Searching...
No Matches
FuzzyDetectorOp.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_FUZZY_DUALPOL_OP
32#define RACK_FUZZY_DUALPOL_OP
33
34#include <string>
35
36#include <drain/util/Cloner.h>
37
38#include <drain/image/Image.h>
39#include <drain/image/Window.h>
40#include <drain/imageops/ImageOp.h>
41
42#include "radar/Analysis.h"
43#include "DetectorOp.h"
44
45namespace rack {
46
47/*
48 class LocalFunctorBank {
49
50 template <class T>
51 static
52 drain::Cloner<drain::UnaryFunctor,T> & getCloner(){
53 static drain::Cloner<drain::UnaryFunctor,T> cloner; // = Static::get<Cloner<T,D>, bank_id>();
54 return cloner;
55 }
56
57};
58*/
59
61/*
62 * \see drain::Cloner
63 * \see drain::FunctorBank
64 */
66
67public:
68
69 template <class T>
70 T & clone(){
71 return getCloner<T>().getClonedSrc();
72 }
73
74
75protected:
76
77 template <class T>
80 // cloner.drop(1);
81 return cloner;
82 }
83
84};
85
87
91
92protected:
93
94 inline
95 FuzzyDetectorOp(const std::string & name, const std::string & description, const std::string & classCode) :
96 DetectorOp(name, description, classCode) {
97 // dataSelector.setQuantities("DBZ:VRAD:RHOHV:ZDR");
98 dataSelector.setQuantities("DBZH:VRADH:RHOHV:ZDR"); // must add this, at least DBZH to start
99 //dataSelector.setQuantities("");
100 };
101
102
103 inline
104 FuzzyDetectorOp(const FuzzyDetectorOp & op) : DetectorOp(op) {
105 this->parameters.copyStruct(op.getParameters(), op, *this);
106 };
107
108 virtual inline
110
111 drain::Range<double> dbzParam = {-5.0,+5.0}; // Peak(span) or threshold(area), hence called generally "parameter".
112 double vradDevThreshold = 2.0;
113 //double rhoHVthreshold = 0.95;
114 drain::Range<double> rhoHVthreshold = {0.85,0.95};
115 double zdrAbsThreshold = 2.0;
117 // RadarWindowConfig windowConf;
118 double gammaAdjustment = 1.0; // neutral value, post-processing
119
120 virtual inline
121 const QuantitySelector & getSelectorDBZ() const {
122 return selectorEmpty; // return selectorDBZ;
123 };
124
125 virtual inline
126 const QuantitySelector & getSelectorVRAD() const {
127 return selectorEmpty; // return selectorVRAD;
128 };
129
130 virtual inline
131 const QuantitySelector & getSelectorZDR() const {
132 return selectorEmpty; // return selectorZDR;
133 };
134
135 virtual inline
136 const QuantitySelector & getSelectorRHOHV() const {
137 return selectorEmpty; //return selectorRHOHV;
138 };
139
140 virtual
141 void runDetection(const DataSet<PolarSrc> & src, PlainData<PolarDst> & dstProb, DataSet<PolarDst> & dstAux) const;
142
143
144protected:
145
146 static const QuantitySelector selectorEmpty;
147 static const QuantitySelector selectorDBZ;
148 static const QuantitySelector selectorVRAD;
149 static const QuantitySelector selectorZDR;
150 static const QuantitySelector selectorRHOHV;
151
152 static drain::FuzzyIdentity<double> dummy;
153
154public:
155
156 //virtual
157 //const RadarFunctorBase & getDBZFuzzifier(const ODIM & srcODIM) const = 0;
158 //const drain::Fuzzifier<double> & getDBZFuzzifier() const = 0;
159
160 /*
161 virtual inline
162 RadarFunctorBaseOp & getDBZFuzzifier() const {
163 return dummyFunctorOp;
164 }
165
166 virtual inline
167 RadarFunctorBaseOp & getVRADFuzzifier() const {
168 return dummyFunctorOp;
169 }
170 */
171
172 virtual inline
173 drain::Fuzzifier<double> & getFuzzifierDBZ(LocalFunctorBank & bank) const {
174 return dummy;
175 }
176
177 virtual inline
178 drain::Fuzzifier<double> & getFuzzifierVRAD(LocalFunctorBank & bank) const {
179 return dummy;
180 }
181
182 virtual inline
183 drain::Fuzzifier<double> & getFuzzifierZDR(LocalFunctorBank & bank) const {
184 return dummy; // or 1.0
185 }
186
187 virtual inline
188 drain::Fuzzifier<double> & getFuzzifierRHOHV(LocalFunctorBank & bank) const {
189 return dummy;
190 }
191
192
193 /*
194 virtual inline
195 RadarFunctorBaseOp & getZDRFuzzifier() const {
196 return dummyFunctorOp;
197 }
198
199 virtual inline
200 RadarFunctorBaseOp & getRHOHVFuzzifier() const {
201 return dummyFunctorOp;
202 }
203 */
204
205
206 // virtual
207 // void computeFuzzy(RadarFunctorBaseOp & fuzzifier, const PlainData<PolarSrc> & src, PlainData<PolarDst> & dstData, DataSet<PolarDst> & dstProduct) const; // = 0;
208
209 virtual
210 void computeFuzzy(const drain::Fuzzifier<double> & fuzzifier, const PlainData<PolarSrc> & src, PlainData<PolarDst> & dstData, DataSet<PolarDst> & dstProduct) const; // = 0;
211
212 virtual
213 void computeFuzzyVRAD(const drain::Fuzzifier<double> & fuzzifier, const PlainData<PolarSrc> & src, PlainData<PolarDst> & dstData, DataSet<PolarDst> & dstProduct) const; // = 0;
214
215 /*
216 virtual
217 void computeFuzzyDBZ(const PlainData<PolarSrc> & src, PlainData<PolarDst> & dstData, DataSet<PolarDst> & dstProduct) const; // = 0;
218
219 virtual
220 void computeFuzzyVRAD(const PlainData<PolarSrc> & src, PlainData<PolarDst> & dstData, DataSet<PolarDst> & dstProduct) const; // = 0;
221
222 virtual
223 void computeFuzzyZDR(const PlainData<PolarSrc> & src, PlainData<PolarDst> & dstData, DataSet<PolarDst> & dstProduct) const; // = 0;
224
225 virtual
226 void computeFuzzyRHOHV(const PlainData<PolarSrc> & src, PlainData<PolarDst> & dstData, DataSet<PolarDst> & dstProduct) const; // = 0;
227 */
228
230
237 void applyOperator(const ImageOp & op, const PlainData<PolarSrc> & src, PlainData<PolarDst> & dstData, DataSet<PolarDst> & dstProductAux) const;
238
240 static
241 void getGammaLookUpTable(double p, std::vector<unsigned char> & lookUpTable);
242
243 mutable
245};
246
247
248}
249
250#endif
251
252// Rack
A base class for fuzzy functions; also an unary functor.
Definition Fuzzy.h:55
Identity function - returns the input value.
Definition Fuzzy.h:117
Definition Range.h:52
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
Base class for image processing functions.
Definition ImageOp.h:49
Base class for configurations applied in image processing windows, e.g. for operators of type WindowO...
Definition Window.h:56
void setQuantities(const std::string &s)
Sets basic quantities and quality quantities. These sets are separated by '/'.
Definition DataSelector.cpp:282
A map of radar data, indexed by quantity code (DBZH, VRAD, etc).
Definition Data.h:1215
Base class for anomaly detectors.
Definition DetectorOp.h:49
Base class for BirdOp and InsectOp.
Definition FuzzyDetectorOp.h:90
void applyOperator(const ImageOp &op, const PlainData< PolarSrc > &src, PlainData< PolarDst > &dstData, DataSet< PolarDst > &dstProductAux) const
Convenience function for "accumulating" detection results.
Definition FuzzyDetectorOp.cpp:138
virtual void runDetection(const DataSet< PolarSrc > &src, PlainData< PolarDst > &dstProb, DataSet< PolarDst > &dstAux) const
Process as sweep (data in one elevation angle)
Definition FuzzyDetectorOp.cpp:219
static void getGammaLookUpTable(double p, std::vector< unsigned char > &lookUpTable)
Returns a 256-element map of Gamma corrected values, scaled by 256.
Definition FuzzyDetectorOp.cpp:120
Definition FuzzyDetectorOp.h:65
Essential class for storing radar data.
Definition Data.h:300
Convenience (abbreviation)
Definition Analysis.h:173
Definition DataSelector.cpp:44
Wrapper for derived class S, returning base class T.
Definition Cloner.h:117