31 #ifndef RADAR_ACCUMULATOR_H
32 #define RADAR_ACCUMULATOR_H
38 #include "drain/image/Sampler.h"
40 #include "drain/image/AccumulatorGeo.h"
41 #include "data/ODIM.h"
42 #include "data/ODIMPath.h"
43 #include "data/Data.h"
44 #include "data/DataSelector.h"
45 #include "data/DataCoder.h"
46 #include "data/QuantityMap.h"
48 #include "product/ProductOp.h"
60 template <
class AC,
class OD>
126 targetEncoding = encoding;
127 if (
odim.quantity.empty()){
130 m.link(
"what:quantity",
odim.quantity);
138 void consumeTargetEncoding(std::string & encoding){
139 if (!encoding.empty()){
140 targetEncoding = encoding;
141 if (
odim.quantity.empty()){
144 m.link(
"what:quantity",
odim.quantity);
154 const std::string & getTargetEncoding(){
155 return targetEncoding;
159 std::ostream & toStream(std::ostream & ostr)
const {
162 this->AC::toStream(ostr);
176 std::string targetEncoding;
181 template <
class AC,
class OD>
186 if (!srcQuality.data.isEmpty()){
187 mout.info(
"Quality data available with input; using quality as weights in compositing.");
188 DataCoder converter(srcData.odim, srcQuality.odim);
190 AC::addData(srcData.data, srcQuality.data, converter, weight, i0, j0);
193 mout.info(
"No quality data available with input, ok." );
197 DataCoder converter(srcData.odim, qualityOdim);
199 AC::addData(srcData.data, converter, weight, i0, j0);
202 odim.updateLenient(srcData.odim);
203 counter += std::max(1L, srcData.odim.ACCnum);
211 template <
class AC,
class OD>
216 DataCoder converter(srcData.odim, srcQuality.odim);
217 AC::addData(srcData.data, srcQuality.data, srcCount.data, converter);
219 odim.updateLenient(srcData.odim);
220 counter = std::max(1L, srcData.odim.ACCnum);
225 template <
class AC,
class OD>
236 const double p = wavgParams.
get(
"p", 1.0);
237 const double p2 = p/2.0;
238 mout.info(rule ,
", min=", dataODIM.
getMin() );
240 if ((p2 - floor(p2)) == 0.0){
241 mout.info(
"WAVG with p=" , p ,
" = 2N, positive pow() results" );
244 const double bias = wavgParams.
get(
"bias", 0.0);
246 mout.
warn(
"WAVG with p=" , p ,
" = 2N, undetectValue=" , q.
undetectValue ,
" < bias=", bias );
262 template <
class AC,
class OD>
271 typedef enum {DATA,QUALITY} datatype;
275 odimData.scaling.scale = 0.0;
284 bool DATA_SPECIFIC_QUALITY =
false;
287 for (
size_t i = 0; i < fields.length(); ++i) {
294 datatype type = DATA;
295 char field = fields.at(i);
298 DATA_SPECIFIC_QUALITY =
true;
304 mout.
warn() <<
"non-standard layer code; use 'd' for 'data' instead" << mout.endl;
333 mout.
warn(
"experimental: quality [QIND] type copied from data [" , odimOut.quantity ,
']' );
344 odimQuality = odimOut;
346 if (qm.hasQuantity(odimQuality.
quantity)){
348 mout.
accept<LOG_NOTICE>(
"found quantyConf[", odimQuality.
quantity,
"], type=", odimQuality.
type);
351 mout.
special(
"Quality: ", odimQuality);
354 odimQuality.scaling.
scale *= 20.0;
356 odimQuality.scaling.
offset = round(drain::Type::call<drain::typeMin, double>(t) + drain::Type::call<drain::typeMax, double>(t))/2.0;
358 mout.
warn(
"quantyConf[" , odimQuality.
quantity ,
"] not found, using somewhat arbitary scaling:" );
363 mout.
error(
"Unsupported field code: '", field,
"'");
367 mout.
debug(
"extracting field ", field);
370 mout.experimental(
"Applying cropping: bbox=", crop,
" [pix]");
376 else if (type == QUALITY){
380 if (odimData.quantity.empty()){
381 odimData.quantity =
"UNKNOWN";
382 mout.
note(
"quantity=", odimData.quantity);
386 mout.
debug(
"searching dstData... DATA=", (type == DATA));
392 DataCoder dataCoder(odimData, odimQuality);
393 mout.
debug(
"dataCoder: ", dataCoder);
394 mout.
debug2(
"dataCoder: data: ", dataCoder.dataODIM);
395 mout.
debug2(
"dataCoder: qind: ", dataCoder.qualityODIM);
398 mout.
unimplemented(
"crop ", crop,
", dstData.data resize + Accumulator::extractField ");
402 mout.
debug(
"DATA/" , field,
" [", odimData.quantity,
']');
404 pdata_dst_t & dstData = dstProduct.getData(odimData.quantity);
405 dstData.odim.importMap(odimData);
406 dstData.data.setType(odimData.type);
407 mout.debug3(
"dstData: " , dstData );
412 mout.
debug(
"QUALITY/" , field ,
" [", odimQuality.
quantity,
']');
415 q_data_t & qualityOwner = (DATA_SPECIFIC_QUALITY) ? (q_data_t &) dstProduct.getData(odimData.quantity) : (q_data_t &) dstProduct;
417 dstData.odim.updateFromMap(odimQuality);
418 mout.debug3(
"dstData: " , dstData );
virtual const std::string & getName() const
Return the name of an instance.
Definition: BeanLike.h:69
LogSourc e is the means for a function or any program segment to "connect" to a Log.
Definition: Log.h:308
Logger & error(const TT &... args)
Echoes.
Definition: Log.h:412
Logger & accept(const TT &... args)
Some input has been accepted, for example by a syntax.
Definition: Log.h:578
Logger & special(const TT &... args)
Other useful information.
Definition: Log.h:527
Logger & unimplemented(const TT &... args)
Feature to be done. Special type of Logger::note().
Definition: Log.h:507
Logger & note(const TT &... args)
For top-level information.
Definition: Log.h:485
Logger & warn(const TT &... args)
Possible error, but execution can continue.
Definition: Log.h:426
Logger & debug(const TT &... args)
Public, yet typically used "internally", when TIMING=true.
Definition: Log.h:676
Logger & debug2(const TT &... args)
Debug information.
Definition: Log.h:686
Definition: ReferenceMap.h:207
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
std::string get(const std::string &key, const std::string &defaultValue) const
Retrieves a value, or default value if value is unset.
Definition: SmartMap.h:127
static const std::type_info & getTypeInfo(char t)
Returns the base type associated with a character key.
Definition: Type.h:134
double & scale
Multiplicative coefficient \i a in: y = ax + b.
Definition: ValueScaling.h:68
double & offset
Additive coefficient \i b in: y = ax + b.
Definition: ValueScaling.h:71
Function for accumulating data: maximum, average, weighted average etc.
Definition: AccumulationMethods.h:64
void extractField(char field, const AccumulationConverter &converter, Image &dst, const drain::Rectangle< int > &crop) const
Extracts the accumulated quantity or secondary quantities like weight and standard deviation.
Definition: Accumulator.cpp:209
Converts ODIM encoded data (with markers) to natural values and backwards.
Definition: DataCoder.h:61
Tool for selecting datasets based on paths, quantities and min/max elevations.
Definition: DataSelector.h:112
A map of radar data, indexed by quantity code (DBZH, VRAD, etc).
Definition: Data.h:1213
Structure for data storage type, scaling and marker codes. Does not contain quantity.
Definition: EncodingODIM.h:75
void addShortKeys()
Creates a short alias (attrib) for each (group):(attrib). Example: "gain" => "what:gain".
Definition: EncodingODIM.h:286
std::string type
This is non-standard (not in ODIM), but a practical means of handling storage type of datasets.
Definition: EncodingODIM.h:146
double getMin() const
Returns the minimum physical value that can be returned using current storage type,...
Definition: EncodingODIM.cpp:375
Definition: ODIMPath.h:82
ODIM metadata (quantity, gain, offset, undetect, nodata, date, time)
Definition: ODIM.h:79
std::string quantity
dataX/what (obligatory)
Definition: ODIM.h:181
Essential class for storing radar data.
Definition: Data.h:302
Base class providing quality support for Dataand DataSet
Definition: Data.h:1032
Definition: QuantityMap.h:50
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
Structure for defining.
Definition: Quantity.h:53
double undetectValue
A physical value corresponding a very small (unmeasurable) value has been defined.
Definition: Quantity.h:71
bool hasUndetectValue() const
True, if a value corresponding a very small (unmeasurable) value has been defined.
Definition: Quantity.h:140
Data array for creating composites and accumulated polar products (Surface rain fall or cluttermaps)
Definition: RadarAccumulator.h:61
OD odim
For storing the scaling and encoding of (1st) input or user-defined values. Also for bookkeeping of d...
Definition: RadarAccumulator.h:111
void addData(const pdata_src_t &srcData, const pdata_src_t &srcQuality, double weight, int i0, int j0)
Adds data that is in the same coordinate system as the accumulator. Weighted with quality.
Definition: RadarAccumulator.h:182
size_t counter
Book-keeping for new data. Finally, in extraction phase, added to odim.ACCnum .
Definition: RadarAccumulator.h:120
DataSelector dataSelector
Input data selector.
Definition: RadarAccumulator.h:102
void extractOLD(const OD &odimOut, DataSet< DstType< OD > > &dstProduct, const std::string &fields, const drain::Rectangle< int > &crop={0, 0, 0, 0}) const
Definition: RadarAccumulator.h:263
RadarAccumulator()
Default constructor.
Definition: RadarAccumulator.h:70
void addData(const pdata_src_t &srcData, const pdata_src_t &srcQuality, const pdata_src_t &srcCount)
Adds data that is in the same coordinate system as the accumulator.
Definition: RadarAccumulator.h:212
PlainData< SrcType< OD const > > pdata_src_t
Input data type.
Definition: RadarAccumulator.h:66
bool checkCompositingMethod(const ODIM &srcODIM) const
Warns if data scaling involves risks in using WAVG (weighted averaging)
Definition: RadarAccumulator.h:226
void setTargetEncoding(const std::string &encoding)
Not critical. If set, needed to warn if input data does not match the expected / potential targetEnco...
Definition: RadarAccumulator.h:125
double defaultQuality
If source data has no quality field, this value is applied for (detected) data.
Definition: RadarAccumulator.h:114
Definition: DataSelector.cpp:44
Rectange defined through lower left and upper right coordinates.
Definition: Rectangle.h:65
bool empty() const
Return true if the area is zero.
Definition: Rectangle.h:111
Writable data type.
Definition: Data.h:122