Loading...
Searching...
No Matches
DopplerAvgExpOp.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
32#ifndef DOPPLER_AvgExpOP_H_
33#define DOPPLER_AvgExpOP_H_
34
35#include <drain/imageops/ImpulseResponseOp.h>
36#include <drain/imageops/ImpulseAvgOp.h>
37
38#include "data/DataCoder.h"
39#include "DopplerOp.h"
40
41
42
43namespace rack {
44
46
52class DopplerAvg : public drain::image::ImpulseBucket<ImpulseAvgConf> {
53
54public:
55
56
57 inline
58 DopplerAvg(){
59
60 };
61
62 inline
63 DopplerAvg(const ImpulseAvg & avg){
64 decays = avg.decays;
65 }
66
67 inline
68 DopplerAvg(const ImpulseAvgConf & conf){
69 decays = conf.decays;
70 }
71
72 virtual
73 void init(const Channel & src, bool horizontal);
74
75 virtual
76 void reset();
77
78 virtual
79 void addLeft(int i, double value, double weight);
80
81 virtual
82 void addRight(int i, double value, double weight);
83
84 virtual inline
85 void addDown(int i, double value, double weight){
86 addLeft(i, value, weight);
87 }
88
89 virtual inline
90 void addUp(int i, double value, double weight){
91 addRight(i, value, weight);
92 }
93
95 virtual
96 double get(int i);
97
99 virtual
100 double getWeight(int i);
101
102 PolarODIM odim;
103
104private:
105
107 struct entry {
108
109 double x;
110 double y;
111 double w;
112
113 inline void set(double x, double y, double w){
114 this->x = x;
115 this->y = y;
116 this->w = w;
117 }
118
119 };
120
121 /*
122 * \param xNew - value to be added
123 * \param wNew - weight of xNew
124 */
125 inline
126 void mix(entry & prev, const entry & current, double decay){
127
128 double w1 = decay*current.w;
129 double w2 = (1.0-decay);
130
131 if (decay < 1.0){
132 prev.x = (w1*current.x + w2*prev.x) / (w1 + w2);
133 prev.y = (w1*current.y + w2*prev.y) / (w1 + w2);
134 }
135 else {// decay==1 => w2=0 => denominator would be zero if w1==0 <=> current.w==0
136 prev.x = current.x;
137 prev.y = current.y;
138 }
139
140 prev.w = w1 + w2*prev.w;
141
142 }
143
144 typedef std::pair<entry,entry> entryPair;
145 typedef std::vector<entryPair> container;
146
147 container data;
148
149 entry e;
150 entryPair latest; // utility
151
152};
153
154
155
157public:
158
159 DopplerAvgExpOp() : PolarProductOp(__FUNCTION__, "Doppler field smoother with exponential decay weighting") {
160 parameters.append(conf.getParameters());
161 parameters.link("horzExtension", horzExt = 0, "pix");
162 parameters.link("vertExtension", vertExt = 0, "pix");
163 //parameters.link("decay", decay = 0.8, "[0.0,1.0]");
164 //parameters.link("smoothNess", smoothNess = 0.5, "[0.0,1.0]"); // neighbor weight
165 dataSelector.setMaxCount(1);
166
167 //dataSelector.setQuantity("VRAD[H]?");
168 //dataSelector.setQuantity("C");
169 }
170
171 virtual
172 void processData(const Data<PolarSrc> & srcData, Data<PolarDst> & dstData) const;
173
174 virtual
175 void processData1D(const Data<PolarSrc> & srcData, Data<PolarDst> & dstData) const;
176
178 int horzExt;
179 int vertExt;
180
181};
182
183} // rack::
184
185
186#endif
187
188
void append(ReferenceMap &rMap, bool replace=true)
Adopts the references of r. If replace==false, only new entries are appended.
Definition ReferenceMap.h:320
Image with static geometry.
Definition ImageChannel.h:60
Averaging operator. A simple example implementation of ImpulseBucket.
Definition ImpulseAvgOp.h:140
Definition ImpulseResponseOp.h:54
Data structure consisting of plain data and an optional quality data.
Definition Data.h:1146
Definition DopplerAvgExpOp.h:156
Averaging operator. A simple example implementation of ImpulseCumulator.
Definition DopplerAvgExpOp.h:52
virtual void init(const Channel &src, bool horizontal)
Adapt to input geometry, type, and scaling.
Definition DopplerAvgExpOp.cpp:39
virtual void addUp(int i, double value, double weight)
When traversing up or left, add a encoded value to bucket in position i.
Definition DopplerAvgExpOp.h:90
virtual void addDown(int i, double value, double weight)
When traversing down or right, add a encoded value to bucket in position i.
Definition DopplerAvgExpOp.h:85
virtual double getWeight(int i)
Returns the smoothed average of the input weights modulated with quality (non-centrity) of "radial" s...
Definition DopplerAvgExpOp.cpp:98
virtual void addRight(int i, double value, double weight)
When traversing down or right, add a encoded value to bucket in position i.
Definition DopplerAvgExpOp.cpp:78
virtual double get(int i)
Return natural (not encoded) value at position i.
Definition DopplerAvgExpOp.cpp:116
virtual void addLeft(int i, double value, double weight)
When traversing up or left, add a encoded value to bucket in position i.
Definition DopplerAvgExpOp.cpp:62
virtual void reset()
Clear statistics before traversing each row or column.
Definition DopplerAvgExpOp.cpp:49
Metadata structure for single-radar data (polar scans, volumes and products).
Definition PolarODIM.h:45
Base class for flat (2D) products computed in the polar coordinate system. Volume is used as input.
Definition PolarProductOp.h:59
Definition DataSelector.cpp:44
Definition ImpulseAvgOp.h:95