BirdOp.h
1 /*
2 
3 MIT License
4 
5 Copyright (c) 2017 FMI Open Development / Markus Peura, first.last@fmi.fi
6 
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software and associated documentation files (the "Software"), to deal
9 in the Software without restriction, including without limitation the rights
10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 copies of the Software, and to permit persons to whom the Software is
12 furnished to do so, subject to the following conditions:
13 
14 The above copyright notice and this permission notice shall be included in all
15 copies or substantial portions of the Software.
16 
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 SOFTWARE.
24 
25 */
26 /*
27 Part of Rack development has been done in the BALTRAD projects part-financed
28 by the European Union (European Regional Development Fund and European
29 Neighbourhood Partnership Instrument, Baltic Sea Region Programme 2007-2013)
30 */
31 #ifndef BIRD_H_
32 #define BIRD_H_
33 
34 #include <andre/DetectorOp.h>
35 #include "data/Data.h"
36 #include "drain/image/Image.h"
37 #include "drain/image/Window.h"
38 #include "drain/imageops/ImageOp.h"
39 #include <string>
40 
41 using namespace drain::image;
42 
43 namespace rack {
44 
45 
47 
51 class GliderOp: public DetectorOp {
52 
53 protected:
54 
55  inline
56  GliderOp(const std::string & name, const std::string & description, const std::string & classCode) :
57  DetectorOp(name, description, classCode), dbzPeak(+5), VRAD_FLIP(false), zdrAbsMin(+2.0) {
58  //dataSelector.setQuantityRegExp("^(DBZH|VRAD|VRADH|RHOHV|ZDR)$");
59  dataSelector.setQuantities("DBZH:VRAD:VRADH:RHOHV:ZDR");
60  dataSelector.setMaxCount(1);
61  };
62 
81  inline
82  GliderOp(const GliderOp & op) : DetectorOp(op), dbzPeak(0.0), VRAD_FLIP(false), zdrAbsMin(+2.0) {
83  this->parameters.copyStruct(op.getParameters(), op, *this);
84  };
85 
86  virtual inline
87  ~GliderOp(){};
88 
89 
90  double dbzPeak;
91 
92  bool VRAD_FLIP;
93  drain::Range<double> vradDevRange;
94 
95  //double wradMin;
96 
97  drain::Range<double> rhoHVRange;
98 
99  double zdrAbsMin;
100 
102  //double windowWidth;
103  //double windowHeight;
104 
105 
106  virtual
107  //void processDataSet(const DataSet<PolarSrc> & src, PlainData<PolarDst> & dstProb, DataSet<PolarDst> & dstAux) const;
108  void runDetection(const DataSet<PolarSrc> & src, PlainData<PolarDst> & dstProb, DataSet<PolarDst> & dstAux) const;
109 
110 
111 protected:
112 
113 
115  // kludge
116  //void init(double dbzPeak = -5.0, double vradDevMin = 5.0, double rhoHVmax = 0.7, double zdrDevMin = 2.0, double windowWidth = 2500, double windowHeight = 5.0);
117 
119 
124  void applyOperator(const ImageOp & op, Image & tmp, const std::string & feature, const Data<PolarSrc> & src, PlainData<PolarDst> & dstData, DataSet<PolarDst> & dstProductAux) const;
125 
126 
127 };
128 
130 
134 class BirdOp: public GliderOp {
135 
136 public:
137 
148 // BirdOp(double dbzPeak = -5.0, double vradDevMin = 5.0, double rhoHVmax = 0.7, double zdrAbsMin = 2.0, double windowWidth = 2500, double windowHeight = 5.0) :
149  BirdOp(double dbzPeak = 0.0, double vradDevMin = 3.0, double rhoHVmax = 0.8, double zdrAbsMin = 1.0, double windowWidth = 2500, double windowHeight = 5.0) :
150 
151  GliderOp(__FUNCTION__, "Estimates bird probability from DBZH, VRAD, RhoHV and ZDR.", "nonmet.biol.bird"){ // Optional postprocessing: morphological closing.
152 
153  init(dbzPeak, vradDevMin, rhoHVmax, zdrAbsMin, windowWidth, windowHeight);
154 
155  };
156 
157  inline
158  BirdOp(const BirdOp & op) : GliderOp(op) {
159  this->parameters.copyStruct(op.getParameters(), op, *this);
160  };
161 
162  // virtual inline ~BirdOp(){};
163 
164 protected:
165 
167  void init(double dbzPeak = -5.0, double vradDevMin = 5.0, double rhoHVmax = 0.7, double zdrDevMin = 2.0, double windowWidth = 2500, double windowHeight = 5.0);
168 
169 };
170 
171 
172 class InsectOp: public GliderOp {
173 
174 public:
175 
176  // BIRD: double dbzPeak = -5.0, double vradDevMin = 5.0, double rhoHVmax = 0.7, double zdrAbsMin = 2.0, double windowWidth = 2500, double windowHeight = 5.0
177 
178  InsectOp(double dbzPeak = -10.0, double vradDevMax = +5.0, double rhoHVmax = 0.7, double zdrAbsMin = 3.0, double windowWidth = 2500, double windowHeight = 5.0) :
179  GliderOp(__FUNCTION__, "Estimates probability from DBZH, VRAD, RhoHV and ZDR.", "nonmet.biol.insect"){
180  init(dbzPeak, vradDevMax, rhoHVmax, zdrAbsMin, windowWidth, windowHeight);
181  // this->vradDev.max = 0.9 *vradDevMax;
182  //this->vradDev.min = 1.1 *vradDevMax;
183  };
184 
185  InsectOp(const InsectOp & op) : GliderOp(op) {
186  this->parameters.copyStruct(op.getParameters(), op, *this);
187  }
188 
189 protected:
190 
191  void init(double dbzPeak = -5.0, double vradDevMax = +5.0, double rhoHVmax = 0.7, double zdrDevMin = 2.0, double windowWidth = 2500, double windowHeight = 5.0);
192 
193 };
194 
195 
196 }
197 
198 #endif
199 
200 // Rack
Base class for image processing functions.
Definition: ImageOp.h:49
Class for multi-channel digital images. Supports dynamic typing with base types (char,...
Definition: Image.h:184
Base class for configurations applied in image processing windows, e.g. for operators of type WindowO...
Definition: Window.h:56
Definition: BirdOp.h:134
BirdOp(double dbzPeak=0.0, double vradDevMin=3.0, double rhoHVmax=0.8, double zdrAbsMin=1.0, double windowWidth=2500, double windowHeight=5.0)
Definition: BirdOp.h:149
Base class for anomaly detectors.
Definition: DetectorOp.h:49
Definition: BirdOp.h:51
GliderOp(const GliderOp &op)
Definition: BirdOp.h:82
Definition: BirdOp.h:172
Namespace for images and image processing tools.
Definition: AccumulationArray.cpp:45
Definition: DataSelector.cpp:44