Loading...
Searching...
No Matches
PolarSlidingWindowOp.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 RACK_POLAR_SLIDING_WINDOW_OP
33#define RACK_POLAR_SLIDING_WINDOW_OP
34
35#include <drain/imageops/SlidingWindowOp.h>
36
37//#include "radar/Analysis.h" // temp
38#include "radar/RadarWindows.h" // temp
39#include "PolarProductOp.h"
40
41namespace rack {
42
44
47template <class W>
49
50public:
51
52
53 typename W::conf_t conf;
54
55 PolarSlidingWindowOp(const std::string & name = __FUNCTION__, const std::string &description = "") : PolarProductOp(name,description) {
56
57 parameters.link("width", this->conf.widthM = 1500, "metres");
58 parameters.link("height", this->conf.heightD = 3.0, "deg");
59 parameters.link("threshold", this->conf.contributionThreshold = 0.5, "percentage");
60 parameters.link("invertPolar", this->conf.invertPolar = false, "cart/polar");
61
62 dataSelector.setQuantities("^DBZH$");
63 dataSelector.setMaxCount(1);
64
65 };
66
67
68 virtual
69 void processData(const Data<src_t > & srcData, Data<dst_t > & dstData) const {
70 drain::Logger mout(__FILE__, __FUNCTION__);
71 if (srcData.hasQuality()){
72 mout.warn("quality found, weighted operation" );
73 processDataWeighted(srcData, dstData);
74 }
75 else {
76 mout.warn("no quality, unweighted operation" );
77 mout.warn(dstData.data.getScaling() );
78 processPlainData(srcData, dstData);
79 }
80 };
81
82 virtual
83 void processPlainData(const PlainData<src_t> & srcData, PlainData<dst_t > & dstData) const {
84
85 drain::Logger mout(__FILE__, __FUNCTION__);
86
87 if (srcData.odim.getGeometry().empty()){
88 mout.warn("srcData.odim: empty geometry");
90 }
91
92 mout.special("srcData.odim: " , srcData.odim );
94
95 typename W::conf_t pixelConf;
96
97 this->conf.setPixelConf(pixelConf, srcData.odim);
98
99 SlidingWindowOp<W> op(pixelConf);
100
101 mout.warn(op );
102 mout.special("provided functor: " , op.conf.getFunctorName() , '|' , op.conf.functorParameters );
103 //mout.debug("provided functor: " , op.conf.ftor );
104 mout.debug("pixelConf.contributionThreshold " , pixelConf.contributionThreshold );
105 mout.debug("op.conf.contributionThreshold " , op.conf.contributionThreshold );
106 //dstData.data.setGeometry(vradSrc.data.getGeometry()); // setDst() handles
107 //op.process(vradSrc.data, dstData.data);
108 //op.traverseChannel(vradSrc.data.getChannel(0), dstData.data.getChannel(0));
109 //srcData.data.properties.updateFromMap(srcData.odim);
110 op.process(srcData.data, dstData.data);
111 // op.traverseChannel(srcData.data, dstData.data);
112
113 dstData.odim.prodpar = this->parameters.getValues();
114
115 };
116
118 virtual
119 void processDataWeighted(const Data<src_t > & srcData, Data<dst_t > & dstData) const {
120 drain::Logger mout(__FILE__, __FUNCTION__);
121 mout.warn("not implemented, calling for plain data" );
122
123 processPlainData(srcData, dstData);
124
125 };
126
127
128
129protected:
130
132 /*
133 void setPixelConf(const PolarODIM & odim, typename W::conf_t & pixelConf) const {
134 conf.setPixelConf(pixelConf, odim);
135 }
136 */
137
138
139
140};
141
142/*
143template <class W>
144void PolarSlidingWindowOp<W>::setPixelConf(const PolarODIM & odim, typename W::conf_t & pixelConf) const {
145
146 drain::Logger mout(__FILE__, __FUNCTION__);
147
148 // pixelConf = this->conf; PROBLEM: ftor prevents op=
149 pixelConf.widthM = this->conf.widthM;
150 pixelConf.heightD = this->conf.heightD;
151 pixelConf.invertPolar = this->conf.invertPolar;
152 pixelConf.contributionThreshold = this->conf.contributionThreshold;
153 pixelConf.relativeScale = this->conf.relativeScale;
154
155
156 pixelConf.updatePixelSize(odim);
157
158 if (pixelConf.frame.width == 0){
159 mout.note(this->conf.frame.width );
160 mout.note(this->conf.widthM );
161 mout.note(*this );
162 mout.warn("Requested width (" , pixelConf.widthM , " meters), smaller than rscale (", odim.rscale ,"), setting window width=1 " );
163 pixelConf.frame.width = 1;
164 }
165
166 if (pixelConf.frame.height == 0){
167 mout.warn("Requested height (" , pixelConf.heightD , " degrees), smaller than 360/nrays (", (360.0/odim.geometry.height) ,"), setting window height=1 " );
168 pixelConf.frame.height = 1;
169 }
170
171
172}
173*/
174
175class PolarSlidingAvgOp : public PolarSlidingWindowOp<RadarWindowAvg<RadarWindowConfig> > {
176public:
177
178 inline
179 PolarSlidingAvgOp() : PolarSlidingWindowOp< RadarWindowAvg<RadarWindowConfig> >(__FUNCTION__, "Smoothen polar data"){
180 };
181
182};
183
184
185}
186
187#endif /* POLARSLIDINGDOPPLERWINDOW_H_ */
LogSourc e is the means for a function or any program segment to "connect" to a Log.
Definition Log.h:312
Logger & warn(const TT &... args)
Possible error, but execution can continue.
Definition Log.h:430
Logger & debug(const TT &... args)
Debug information.
Definition Log.h:666
Logger & special(const TT &... args)
Other useful information.
Definition Log.h:531
void getValues(std::ostream &ostr) const
Dumps the values.
Definition SmartMap.h:353
virtual void process(const ImageFrame &src, Image &dst) const
Main interface. Typically splits processing to each channel.
Definition ImageOp.cpp:126
Template for operators applying pipeline-like sliding window.
Definition SlidingWindowOp.h:59
void setQuantities(const std::string &s)
Sets basic quantities and quality quantities. These sets are separated by '/'.
Definition DataSelector.cpp:282
Data structure consisting of plain data and an optional quality data.
Definition Data.h:1146
Essential class for storing radar data.
Definition Data.h:300
Base class for flat (2D) products computed in the polar coordinate system. Volume is used as input.
Definition PolarProductOp.h:59
Definition PolarSlidingWindowOp.h:175
Window operator with support.
Definition PolarSlidingWindowOp.h:48
virtual void processDataWeighted(const Data< src_t > &srcData, Data< dst_t > &dstData) const
Quality-weighted prosessing of data.
Definition PolarSlidingWindowOp.h:119
Definition DataSelector.cpp:44
Definition Type.h:542