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
49/*
50 * \see drain::Cloner
51 * \see drain::FunctorBank
52 */
54
55public:
56
57 template <class T>
58 T & clone(){
59 return getCloner<T>().getClonedSrc();
60 }
61
62
63protected:
64
65 template <class T>
68 // cloner.drop(1);
69 return cloner;
70 }
71
72};
73
75
79
80protected:
81
82 inline
83 FuzzyDetectorOp(const std::string & name, const std::string & description, const std::string & classCode) :
84 DetectorOp(name, description, classCode) {
85 // dataSelector.setQuantities("DBZ:VRAD:RHOHV:ZDR");
86 dataSelector.setQuantities("DBZH:VRADH:RHOHV:ZDR"); // must add this, at least DBZH to start
87 //dataSelector.setQuantities("");
88 };
89
90
91 inline
93 this->parameters.copyStruct(op.getParameters(), op, *this);
94 };
95
96 virtual inline
98
99 drain::Range<double> dbzParam = {-5.0,+5.0}; // Peak(span) or threshold(area), hence called generally "parameter".
100 double vradDevThreshold = 2.0;
101 //double rhoHVthreshold = 0.95;
102 drain::Range<double> rhoHVthreshold = {0.85,0.95};
103 double zdrAbsThreshold = 2.0;
105 // RadarWindowConfig windowConf;
106 double gammaAdjustment = 1.0; // neutral value, post-processing
107
108 virtual inline
109 const QuantitySelector & getSelectorDBZ() const {
110 return selectorEmpty; // return selectorDBZ;
111 };
112
113 virtual inline
114 const QuantitySelector & getSelectorVRAD() const {
115 return selectorEmpty; // return selectorVRAD;
116 };
117
118 virtual inline
119 const QuantitySelector & getSelectorZDR() const {
120 return selectorEmpty; // return selectorZDR;
121 };
122
123 virtual inline
124 const QuantitySelector & getSelectorRHOHV() const {
125 return selectorEmpty; //return selectorRHOHV;
126 };
127
128 virtual
129 void runDetection(const DataSet<PolarSrc> & src, PlainData<PolarDst> & dstProb, DataSet<PolarDst> & dstAux) const;
130
131
132
133
134 virtual inline
135 drain::Fuzzifier<double> & getFuzzifierDBZ(LocalFunctorBank & bank) const {
136 return dummy;
137 }
138
139 virtual inline
140 drain::Fuzzifier<double> & getFuzzifierVRAD(LocalFunctorBank & bank) const {
141 return dummy;
142 }
143
144 virtual inline
145 drain::Fuzzifier<double> & getFuzzifierZDR(LocalFunctorBank & bank) const {
146 return dummy; // or 1.0
147 }
148
149 virtual inline
150 drain::Fuzzifier<double> & getFuzzifierRHOHV(LocalFunctorBank & bank) const {
151 return dummy;
152 }
153
154
155
156 virtual
157 void computeFuzzy(const drain::Fuzzifier<double> & fuzzifier, const PlainData<PolarSrc> & src, PlainData<PolarDst> & dstData, DataSet<PolarDst> & dstProduct) const; // = 0;
158
159 virtual
160 void computeFuzzyVRAD(const drain::Fuzzifier<double> & fuzzifier, const PlainData<PolarSrc> & src, PlainData<PolarDst> & dstData, DataSet<PolarDst> & dstProduct) const; // = 0;
161
162
164
171 void applyOperator(const ImageOp & op, const PlainData<PolarSrc> & src, PlainData<PolarDst> & dstData, DataSet<PolarDst> & dstProductAux) const;
172
174 static
175 void getGammaLookUpTable(double p, std::vector<unsigned char> & lookUpTable);
176
177protected:
178
179 static const QuantitySelector selectorEmpty;
180 static const QuantitySelector selectorDBZ;
181 static const QuantitySelector selectorVRAD;
182 static const QuantitySelector selectorZDR;
183 static const QuantitySelector selectorRHOHV;
184
185 static drain::FuzzyIdentity<double> dummy;
186
187public:
188
189 // mutable
190 // RadarFunctorOp<drain::IdentityFunctor> dummyFunctorOp;
191};
192
193
194}
195
196#endif
197
198// Rack
A base class for fuzzy functions; also an unary functor.
Definition Fuzzy.h:62
Identity function - returns the input value.
Definition Fuzzy.h:128
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:78
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:53
Essential class for storing radar data.
Definition Data.h:300
Definition DataSelector.cpp:44
Wrapper for derived class S, returning base class T.
Definition Cloner.h:118