Loading...
Searching...
No Matches
Analysis.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_ANALYSIS_H
32#define RACK_ANALYSIS_H
33
34#include <math.h>
35#include <drain/util/Fuzzy.h>
36
37
38//#include <drain/image/FuzzyOp.h>
39
40#include <drain/util/Functor.h>
41#include <drain/util/FunctorBank.h>
42//#include <drain/image/Window.h>
43#include <drain/image/SegmentProber.h>
44// #include <drain/image/SlidingWindow.h>
45//#include <drain/image/GaussianWindow.h>
46#include <drain/imageops/FunctorOp.h>
47//#include <drain/imageops/GaussianAverageOp.h>
48
49//#include <drain/image/SequentialImageOp.h>
50
51#include "data/PolarODIM.h"
52// #include "VolumeOp.h"
53
54
55
56// using namespace drain::image;
57
58// file RadarFunctorOp?
59
60namespace rack {
61
63
66// NOTE may be bad, because UnaryFunctorOp pre-scales etc.
67template <class F>
68class RadarDataFunctor : public F {
69 public: //re
70 PolarODIM odimSrc;
71
72 double nodataValue;
73 double undetectValue;
74
75 RadarDataFunctor(double nodataValue = 0.0, double undetectValue = 0.0) : nodataValue(nodataValue),undetectValue(undetectValue) {
76 }
77
78 virtual
79 inline
80 double operator()(double src) const {
81 if (src == odimSrc.nodata)
82 return nodataValue;
83 else if (src == odimSrc.undetect)
84 return undetectValue;
85 else
86 return F::operator()(odimSrc.scaleForward(src));
87 };
88
89};
90
92
95/*
96template <class F>
97class NaturalRadarDataFunctor : public RadarDataFunctor<F> {
98 public: //re
99 const Quantity & q;
100 const PolarODIM & odimStd;
101
102
103 NaturalRadarDataFunctor(const std::string & quantity, char type='C') : q(getQuantityMap().get(quantity)), odimStd(q[type]){
104 }
105
106
107 virtual
108 inline
109 double operator()(double src) const {
110 if ((src != this->odimSrc.nodata) && (src != this->odimSrc.undetect))
111 return F::operator()(this->odimSrc.scaleForward(src));
112 else
113 return q.undetectValue;
114 };
115
116
117
118};
119*/
120
121
123public:
124
125 PolarODIM odimSrc;
126 //bool LIMIT;
127 double nodataValue;
128 double undetectValue;
129
130 RadarFunctorBase() : nodataValue(0.0), undetectValue(0.0) {
131 //if (adaptParameters)
132 //LIMIT = limit;
133 };
134
135 virtual inline
137 };
138
139
140 void apply(const drain::image::Channel &src, drain::image::Channel & dst, const drain::UnaryFunctor & ftor, bool LIMIT = true) const;
141
142 virtual inline
143 double fuzzify(double x){
144 return x;
145 }
146 // operator T() const
147 //drain::image::ImageOp getImageOp() = 0;
148
149
150};
151
153public:
154
155
156 virtual inline
157 operator drain::image::ImageOp & () = 0;
158
159protected:
160
162
163 virtual
165
166};
168template <class F>
170public:
171
172 /*
173 PolarODIM odimSrc;
174 bool LIMIT;
175 double nodataValue;
176 double undetectValue;
177
178 RadarFunctorOp(bool limit = true) : LIMIT(limit), nodataValue(0.0), undetectValue(0.0) {
179 //if (adaptParameters)
180 this->getParameters().append(this->functor.getParameters());
181 };
182 */
183 inline
185 this->LIMIT = true;
186 };
187
188
189
190 virtual inline
191 ~RadarFunctorOp(){};
192
194
196 virtual
198 apply(src, dst, this->functor, this->LIMIT);
199 }
200
201 virtual inline
202 double fuzzify(double x){
203 return this->functor(x);
204 // return x;
205 }
206
207
208 virtual inline
209 operator drain::image::ImageOp & () {
210 return *this;
211 };
212
214
223
270};
271
272
273
274// file RadWinOp?
275
276
277
279
306class PolarSegmentProber : public drain::image::SizeProber { // SegmentProber<int,int>
307public:
308
309 // PolarSegmentProber(const Image & src, Image & dst) : SizeProber(src.getChannel(0), dst.getChannel(0)){};
310
312
314 virtual inline
315 void update(int i, int j){
316 size += i;
317 }
318
319};
320
321
322
323
324
325
326} // rack::
327
328
329
330
331#endif
332
333// Rack
Image with static geometry.
Definition ImageChannel.h:58
Base class for image processing functions.
Definition ImageOp.h:49
Definition SegmentProber.h:521
Class for using simple function objects (like std::functor) for sequential pixel iteration.
Definition FunctorOp.h:135
double scaleForward(double x) const
Converts a quantity from storage scale: y = offset + gain*y .
Definition EncodingODIM.h:241
Metadata structure for single-radar data (polar scans, volumes and products).
Definition PolarODIM.h:45
Computes in polar coordinates.
Definition Analysis.h:306
virtual void update(int i, int j)
Operation performed in each segment location (i,j). A function to be redefined in derived classes.
Definition Analysis.h:315
Checks nodata and undetect before calling the functor.
Definition Analysis.h:68
Definition Analysis.h:152
Definition Analysis.h:122
Convenience (abbreviation)
Definition Analysis.h:169
virtual void traverseChannel(const drain::image::Channel &src, drain::image::Channel &dst) const
Process the image.
Definition Analysis.h:197
Definition DataSelector.cpp:44
Definition Functor.h:116