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 <drain/Log.h>
35#include <drain/TypeUtils.h>
36#include <math.h>
37
38#include <drain/util/Fuzzy.h>
39
40//#include <drain/image/FuzzyOp.h>
41
42#include <drain/util/Functor.h>
43#include <drain/util/FunctorBank.h>
44//#include <drain/image/Window.h>
45#include <drain/image/SegmentProber.h>
46// #include <drain/image/SlidingWindow.h>
47//#include <drain/image/GaussianWindow.h>
48#include <drain/imageops/FunctorOp.h>
49//#include <drain/imageops/GaussianAverageOp.h>
50
51//#include <drain/image/SequentialImageOp.h>
52
53#include "data/ODIM.h"
54#include "data/PolarODIM.h"
55#include "data/Quantity.h"
56// #include "VolumeOp.h"
57
58
59
60// using namespace drain::image;
61
62// file RadarFunctorOp?
63
64namespace rack {
65
67
70// NOTE may be bad, because UnaryFunctorOp pre-scales etc.
71template <class F>
72class RadarDataFunctor : public F {
73 public: //re
74 PolarODIM odimSrc;
75
76 double nodataValue;
77 double undetectValue;
78
79 RadarDataFunctor(double nodataValue = 0.0, double undetectValue = 0.0) : nodataValue(nodataValue),undetectValue(undetectValue) {
80 }
81
82 virtual
83 inline
84 double operator()(double src) const {
85 if (src == odimSrc.nodata)
86 return nodataValue;
87 else if (src == odimSrc.undetect)
88 return undetectValue;
89 else
90 return F::operator()(odimSrc.scaleForward(src));
91 };
92
93};
94
96
99/*
100template <class F>
101class NaturalRadarDataFunctor : public RadarDataFunctor<F> {
102 public: //re
103 const Quantity & q;
104 const PolarODIM & odimStd;
105
106
107 NaturalRadarDataFunctor(const std::string & quantity, char type='C') : q(getQuantityMap().get(quantity)), odimStd(q[type]){
108 }
109
110
111 virtual
112 inline
113 double operator()(double src) const {
114 if ((src != this->odimSrc.nodata) && (src != this->odimSrc.undetect))
115 return F::operator()(this->odimSrc.scaleForward(src));
116 else
117 return q.undetectValue;
118 };
119
120
121
122};
123*/
124
125
127public:
128
129 PolarODIM odimSrc;
130 //bool LIMIT;
131 double nodataValue;
132 double undetectValue;
133
134 RadarFunctorBase() : nodataValue(0.0), undetectValue(0.0) {
135 //if (adaptParameters)
136 //LIMIT = limit;
137 };
138
139 virtual inline
141 };
142
143
144 void apply(const drain::image::Channel &src, drain::image::Channel & dst, const drain::UnaryFunctor & ftor, bool LIMIT = true) const;
145
146 virtual inline
147 double fuzzify(double x){
148 return x;
149 }
150 // operator T() const
151 //drain::image::ImageOp getImageOp() = 0;
152
153
154};
155
157public:
158
159
160 virtual inline
161 operator drain::image::ImageOp & () = 0;
162
163protected:
164
166
167 virtual
169
170};
172template <class F>
174public:
175
176 /*
177 PolarODIM odimSrc;
178 bool LIMIT;
179 double nodataValue;
180 double undetectValue;
181
182 RadarFunctorOp(bool limit = true) : LIMIT(limit), nodataValue(0.0), undetectValue(0.0) {
183 //if (adaptParameters)
184 this->getParameters().append(this->functor.getParameters());
185 };
186 */
187 inline
189 this->LIMIT = true;
190 };
191
192
193
194 virtual inline
195 ~RadarFunctorOp(){};
196
198
200 virtual
202 apply(src, dst, this->functor, this->LIMIT);
203 }
204
205 virtual inline
206 double fuzzify(double x){
207 return this->functor(x);
208 // return x;
209 }
210
211
212 virtual inline
213 operator drain::image::ImageOp & () {
214 return *this;
215 };
216
218
227
274};
275
276
277
278// file RadWinOp?
279
280
281
283
310class PolarSegmentProber : public drain::image::SizeProber { // SegmentProber<int,int>
311public:
312
313 // PolarSegmentProber(const Image & src, Image & dst) : SizeProber(src.getChannel(0), dst.getChannel(0)){};
314
316
318 virtual inline
319 void update(int i, int j){
320 size += i;
321 }
322
323};
324
325
326
327
328
329
330} // rack::
331
332
333
334
335#endif
336
337// Rack
Image with static geometry.
Definition ImageChannel.h:60
Base class for image processing functions.
Definition ImageOp.h:49
Definition SegmentProber.h:523
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:239
double nodata
data[n]/what (obligatory)
Definition EncodingODIM.h:157
Metadata structure for single-radar data (polar scans, volumes and products).
Definition PolarODIM.h:45
Computes in polar coordinates.
Definition Analysis.h:310
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:319
Checks nodata and undetect before calling the functor.
Definition Analysis.h:72
Definition Analysis.h:156
Definition Analysis.h:126
Convenience (abbreviation)
Definition Analysis.h:173
virtual void traverseChannel(const drain::image::Channel &src, drain::image::Channel &dst) const
Process the image.
Definition Analysis.h:201
Definition DataSelector.cpp:44
Definition Functor.h:116