33 #ifndef DOPPLER_WIN_OP_H_
34 #define DOPPLER_WIN_OP_H_
38 #include <drain/Log.h>
39 #include <drain/Type.h>
40 #include <drain/TypeUtils.h>
41 #include "data/Data.h"
42 #include "data/DataSelector.h"
43 #include "data/PolarODIM.h"
44 #include "data/QuantityMap.h"
49 #include "drain/image/Geometry.h"
50 #include "drain/image/Image.h"
51 #include "drain/image/ImageChannel.h"
52 #include "drain/image/Window.h"
53 #include "drain/imageops/SlidingWindowOp.h"
54 #include "product/ProductOp.h"
55 #include "radar/Doppler.h"
56 #include "drain/util/Fuzzy.h"
57 #include "drain/util/SmartMap.h"
58 #include "DopplerOp.h"
77 typename W::conf_t conf;
99 DopplerWindowOp(
const std::string & name,
const std::string & description,
int widthM,
double heightD) :
102 parameters.link(
"width", this->conf.widthM = widthM,
"metres");
103 parameters.link(
"height", this->conf.heightD = heightD,
"deg");
105 parameters.link(
"threshold", this->conf.contributionThreshold = 0.5,
"percentage");
106 parameters.link(
"compensate", this->conf.invertPolar =
false,
"cart/polar[0|1]");
110 dataSelector.setMaxCount(1);
111 allowedEncoding.clear();
112 allowedEncoding.link(
"type", odim.type);
113 allowedEncoding.link(
"gain", odim.scaling.scale);
122 double getTypicalMin(
const PolarODIM & srcODIM)
const = 0;
125 double getTypicalMax(
const PolarODIM & srcODIM)
const = 0;
139 void DopplerWindowOp<W>::setEncoding(
const ODIM & inputODIM, PlainData<PolarDst> & dst)
const {
143 dst.odim.quantity = odim.quantity;
146 typeRef.link(
"type", dst.odim.type = odim.type);
148 dst.data.setType(dst.odim.type);
150 if (odim.scaling.scale != 0.0){
151 mout.warn(
"Init with ODIM: " , EncodingODIM(odim) );
153 applyODIM(dst.odim, odim);
157 if (drain::Type::call<drain::typeIsSmallInt>(dst.data.getType())){
158 dst.setPhysicalRange(getTypicalMin(inputODIM), getTypicalMax(inputODIM));
160 mout.debug(
"small int: " , EncodingODIM(dst.odim) );
161 mout.debug2(
"small int: " , dst.data );
165 if (drain::Type::call<drain::typeIsInteger>(dst.data.getType()))
166 mout.warn(
"large int" );
168 dst.odim.distinguishNodata();
174 dst.data.setScaling(dst.odim.scaling);
176 mout.debug(
"final dst: " , dst.data );
181 void DopplerWindowOp<W>::processDataSet(
const DataSet<PolarSrc> & srcSweep, DataSet<PolarDst> & dstProduct)
const {
187 const Data<PolarSrc> & vradSrc = srcSweep.getData(dataSelector.getQuantitySelector());
189 if (vradSrc.data.isEmpty()){
190 mout.warn(
"VRAD missing" );
194 if (vradSrc.odim.getNyquist() == 0) {
195 mout.warn(
"VRAD unusable, vradSrc.odim.getNyquist() == 0" );
199 Data<PolarDst> & dstData = dstProduct.getData(odim.quantity);
201 dstData.odim.updateLenient(vradSrc.odim);
203 initDst(vradSrc.odim, dstData);
205 dstData.data.fill(dstData.odim.undetect);
207 processData(vradSrc, dstData);
248 void DopplerWindowOp<W>::processData(
const Data<PolarSrc> & vradSrc, Data<PolarDst> & dstData)
const {
255 typename W::conf_t pixelConf;
256 this->conf.setPixelConf(pixelConf, vradSrc.odim);
261 mout.special(
"provided functor: " , op.conf.getFunctorName() ,
'|' , op.conf.functorParameters );
262 mout.debug(
"pixelConf.contributionThreshold " , pixelConf.contributionThreshold );
263 mout.debug(
"op.conf.contributionThreshold " , op.conf.contributionThreshold );
267 op.traverseChannel(vradSrc.data, dstData.data);
269 dstData.odim.prodpar = this->parameters.getValues();
315 parameters.link(
"relativeScale", this->conf.relativeScale =
false,
"false|true");
316 odim.quantity =
"VRAD";
322 void processData(
const Data<PolarSrc> & vradSrc, Data<PolarDst> & dstData)
const {
326 DopplerAverageWindow2::conf_t pixelConf(deviationQuality);
328 this->conf.setPixelConf(pixelConf, vradSrc.odim);
330 mout.debug(
"radarConf: " , this->conf.widthM ,
'x' , this->conf.heightD );
331 mout.debug(
"pixelConf: " , pixelConf.frame.width ,
'x' , this->conf.frame.height );
336 mout.special(
"provided functor: " , op.conf.getFunctorName() ,
'|' , op.conf.functorParameters );
343 PlainData<PolarDst> & dstQuality = dstData.getQualityData(
"QIND");
345 dstQuality.setGeometry(g.getWidth(), g.getHeight());
347 op.traverseChannel(vradSrc.data, dummy, dstData.data, dstQuality.data);
349 dstData.odim.prodpar = this->parameters.
getValues();
355 double getTypicalMin(
const PolarODIM & srcODIM)
const {
356 return (this->conf.relativeScale) ? -1.0 : -srcODIM.getNyquist();
360 double getTypicalMax(
const PolarODIM & srcODIM)
const {
361 return (this->conf.relativeScale) ? +1.0 : +srcODIM.getNyquist();
381 odim.quantity =
"VRAD_DEV";
382 odim.scaling.scale = 1.0/200.0;
383 odim.scaling.offset = -odim.scaling.scale;
394 double getTypicalMin(
const PolarODIM & srcODIM)
const {
399 double getTypicalMax(
const PolarODIM & srcODIM)
const {
LogSourc e is the means for a function or any program segment to "connect" to a Log.
Definition: Log.h:308
Definition: ReferenceMap.h:207
void getValues(std::ostream &ostr) const
Dumps the values.
Definition: SmartMap.h:353
void updateValues(const std::string &entries, char assignmentSymbol='=', char separatorSymbol=0)
Sets applicable values ie. modifies existing entries only. In ordered maps, skips extra entries silen...
Definition: SmartMap.h:326
Definition: Geometry.h:145
Class for multi-channel digital images. Supports dynamic typing with base types (char,...
Definition: Image.h:184
Template for operators applying pipeline-like sliding window.
Definition: SlidingWindowOp.h:59
A map of radar data, indexed by quantity code (DBZH, VRAD, etc).
Definition: Data.h:1213
Data structure consisting of plain data and an optional quality data.
Definition: Data.h:1144
Smoothens Doppler field, providing quality computed as eccentricity.
Definition: Doppler.h:238
Simple op not producing quality field.
Definition: DopplerWindowOp.h:306
DopplerAvgOp(int width=1500, double height=3.0)
Definition: DopplerWindowOp.h:313
Definition: DopplerWindowOp.h:368
DopplerEccentricityOp(int widthM=1500, double heightD=3.0)
Definition: DopplerWindowOp.h:375
Computes eccentrity of Doppler speeds mapped on a Nyquist-normalized unit window.
Definition: Doppler.h:322
Base class for computing products using Doppler speed [VRAD] data.
Definition: DopplerOp.h:49
Base class for Doppler average and variance.
Definition: DopplerWindowOp.h:72
DopplerWindowOp(const std::string &name, const std::string &description, int widthM, double heightD)
Definition: DopplerWindowOp.h:99
ODIM metadata (quantity, gain, offset, undetect, nodata, date, time)
Definition: ODIM.h:79
Essential class for storing radar data.
Definition: Data.h:302
Metadata structure for single-radar data (polar scans, volumes and products).
Definition: PolarODIM.h:45
static void completeEncoding(ODIM &productODIM, const std::string &targetEncoding)
Modifies encoding. If type is changed, resets scaling first.
Definition: ProductBase.cpp:183
bool setQuantityDefaults(EncodingODIM &dst, const std::string &quantity, const std::string &values="") const
Sets default values of given quantity - but not the quantity itself. Optionally overrides with user v...
Definition: QuantityMap.cpp:398
Definition: DataSelector.cpp:44