Loading...
Searching...
No Matches
RadarAccumulator.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 RADAR_ACCUMULATOR_H
32#define RADAR_ACCUMULATOR_H
33
34
35#include <sstream>
36
37// #include <drain/image/Sampler.h>drain::image::Accumulator::FieldType
38#include <drain/image/Accumulator.h> // ostream field...
39#include <drain/image/AccumulatorGeo.h>
40
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"
47// #include "product/RadarProductOp.h"
48#include "Geometry.h"
49
50
51namespace rack {
52
54/*
55 * with Cart / polar linkage
56 *
57 * getProperties("where:proj", comp.projDef)
58 * getProperties("where:xsize", comp.width ?)
59 * getProperties("where:nbins", comp.width ?)
60 *
61 */
62
64
65
66public:
67
68 inline
70
71 inline
73 defaultQuality(base.defaultQuality), counter(base.counter){};
74
76 const ODIM &srcODIM, const DataCoder & dataCoder,
78
80
84
85
86 typedef std::map<int,std::string> legend_t;
87 legend_t legend;
88
89
92
94
97 size_t counter;
98
99 inline
100 const std::string & getTargetEncoding(){
101 return targetEncoding;
102 }
103
104
105protected:
106
107 static
108 bool checkCompositingMethod(const AccumulationMethod & rule, const ODIM & dataODIM);
109
110 std::string targetEncoding;
111
112
113};
114
116
122template <class AC, class OD>
123//class RadarAccumulator : public AC { // deprecating AC!
124class RadarAccumulator : public RadarAccumulatorBase, public AC {
125
126public:
127
132
133
135 RadarAccumulator() { // , undetectValue(-52.0) {
136 odim.type.clear();
137 odim.ACCnum = 0; // NEW
138 }
139
140 virtual
142
144 /*
145 * Counter example: this method is \i not called when polar data is added to a Cartesian composite.
146 *
147 * \param i0 - offset in horizontal direction
148 * \param j0 - offset in vertical direction
149 */
150 void addData(const pdata_src_t & srcData, const pdata_src_t & srcQuality, double weight, int i0, int j0);
151
153 /*
154 *
155 * Counter example: this method is \i not called when polar data is added to a Cartesian composite.
156 */
158
159
164 // TODO: remove this (use the new ones)
165 void extractOLD(const OD & odimOut, DataSet<DstType<OD> > & dstProduct,
166 const std::string & fields, const drain::Rectangle<int> & crop = {0,0,0,0}) const;
167
168 inline
169 void extract(DataSet<DstType<OD> > & dstProduct, const std::string & fieldStr, const std::string & encoding="C", const drain::Rectangle<int> & cropArea={0,0}){
170 drain::image::Accumulator::FieldList fields;
171 drain::image::Accumulator::getFields(fieldStr, fields);
172 extract(dstProduct, fields, encoding, cropArea);
173 }
174
175 void extract(DataSet<DstType<OD> > & dstProduct, const drain::image::Accumulator::FieldList & fields, const std::string & encoding="C", const drain::Rectangle<int> & cropArea={0,0});
176
177 pdata_dst_t & extract(DataSet<DstType<OD> > & dstProduct, field_t field = field_t::DATA, const std::string & encoding="C", const drain::Rectangle<int> & cropArea={0,0});
178
179 // void extractDraft(ODIM & odim, drain::image::Image & dstData, field_t field, const std::string & encoding="", const drain::Rectangle<int> & cropArea={0,0});
180
181
183 /*
184 * Helps in warning if input data does not match the expected / potential targetEncoding
185 */
186 // Note: consider rack::ODIM. And perhaps ODIM to inherit FlexibleVariableMap.
188
189
190
192 void setTargetEncoding(const std::string & encoding);
193
194 inline
195 void consumeTargetEncoding(std::string & encoding){
196 setTargetEncoding(encoding);
197 encoding.clear();
198 }
199
200
201
202 virtual inline
203 std::ostream & toStream(std::ostream & ostr) const {
204
205 // std::cerr << __FILE__ << '@' << __LINE__ << std::endl;
206 this->AC::toStream(ostr);
207 ostr << ' ';
208 // std::cerr << __FILE__ << '@' << __LINE__ << std::endl;
209 odim.toStream(ostr);
210 // std::cerr << __FILE__ << '@' << __LINE__ << " (end)" << std::endl;
211 return ostr;
212 }
213
215 //bool checkCompositingMethod(const ODIM & srcODIM) const;
216 inline
217 bool checkCompositingMethod(const ODIM & dataODIM){
218 return RadarAccumulatorBase::checkCompositingMethod(this->getMethod(), dataODIM);
219 }
220
221
222
223};
224
225
226template <class AC, class OD>
227void RadarAccumulator<AC,OD>::setTargetEncoding(const std::string & encoding){
228
230
231 targetEncoding = encoding;
232
233 if (encoding.empty()){
234 return;
235 }
236
237 std::string quantityPrev = odim.quantity;
238 // if (odim.quantity.empty()){
239 /*
240 ODIM m;
241 m.link("what:quantity", odim.quantity); // appends
242 m.addShortKeys();
243 m.updateValues(encoding);
244 */
245 //}
246
247 //odim.link("what:quantity", odim.quantity);
248 //m.addShortKeys();
249 odim.addShortKeys();
250 odim.updateValues(encoding);
251
252
253 if (!quantityPrev.empty()){
254 if (odim.quantity != quantityPrev){
255 mout.warn("Quantity changed from [", quantityPrev, "] to [", odim.quantity, "]");
256 }
257 else {
258 mout.info("Confirming quantity [", odim.quantity, "] explicitly");
259 }
260 }
261
262 // mout.attention("Quantity: [", quantityPrev, "] -> [", odim.quantity, "]");
263 mout.attention<LOG_DEBUG>("Target encoding: [", encoding, "] odim: ", odim); //, "]");
264
265
266}
267
268template <class AC, class OD>
269void RadarAccumulator<AC,OD>::addData(const pdata_src_t & srcData, const pdata_src_t & srcQuality, double weight, int i0, int j0){
270
272
273 // mout.attention("START ", EncodingODIM(srcData.odim));
274
275 if (!srcQuality.data.isEmpty()){
276 mout.info("Quality data available with input; using quality as weights in compositing.");
278 // uses also DataCoder::undetectQualityCoeff
279 AC::addData(srcData.data, srcQuality.data, converter, weight, i0, j0);
280 }
281 else {
282 mout.info("No quality data available with input, ok.");
283 ODIM qualityOdim; // dummy
285
287 // uses also DataCoder::undetectQualityCoeff
288 AC::addData(srcData.data, converter, weight, i0, j0);
289 }
290
291 // mout.attention("END1 ", EncodingODIM(this->odim));
292 odim.updateLenient(srcData.odim); // Time, date, new
293 // mout.attention("END2 ", EncodingODIM(this->odim));
294
295 counter += std::max(1L, srcData.odim.ACCnum);
296 // odim.ACCnum += std::max(1L, srcData.odim.ACCnum); wrong
297 // odim.ACCnum = counter; // TODO remove counter?
298
299 //mout.note("after: " , this->odim );
300
301}
302
303template <class AC, class OD>
305
307 // mout.info("Quality data available with input; using quality as weights in compositing.");
309 AC::addData(srcData.data, srcQuality.data, srcCount.data, converter);
310
311 odim.updateLenient(srcData.odim); // Time, date, new
312 counter = std::max(1L, srcData.odim.ACCnum); // correct
313 // odim.ACCnum += std::max(1L, srcData.odim.ACCnum); // wrong
314}
315
316
317/*
318template <class AC, class OD>
319bool RadarAccumulator<AC,OD>::checkCompositingMethod(const ODIM & dataODIM) const {
320
321 drain::Logger mout(__FILE__, __FUNCTION__);
322
323 mout.debug("start, quantity=" , dataODIM.quantity );
324
325 const AccumulationMethod & rule = this->getMethod();
326 if (rule.getName() == "WAVG"){
327
328 const drain::ReferenceMap & wavgParams = rule.getParameters();
329 const double p = wavgParams.get("p", 1.0);
330 const double p2 = p/2.0;
331 mout.info(rule , ", min=", dataODIM.getMin() );
332
333 if ((p2 - floor(p2)) == 0.0){
334 mout.info("WAVG with p=" , p , " = 2N, positive pow() results" );
335 const Quantity & q = getQuantityMap().get(dataODIM.quantity);
336 if (q.hasUndetectValue()){
337 const double bias = wavgParams.get("bias", 0.0);
338 if (bias > q.undetectValue){
339 mout.warn("WAVG with p=" , p ," = 2N, undetectValue=" , q.undetectValue , " < bias=", bias );
340 mout.warn("consider adjusting bias(", bias ,") down to quantity (" , dataODIM.quantity , ") zero: " , q.undetectValue );
341 //rule.setParameter("bias", q.undetectValue);
342 return true;
343 }
344 }
345 }
346 }
347
348 return false;
349
350
351}
352*/
353template <class AC, class OD>
354void RadarAccumulator<AC,OD>::extract(DataSet<DstType<OD> > & dstProduct, const drain::image::Accumulator::FieldList & fields, const std::string & encoding, const drain::Rectangle<int> & cropArea) {
355
357
359
360 pdata_dst_t & dstData = extract(dstProduct, field, encoding, cropArea);
361
362 if (ODIM::versionFlagger.isSet(ODIM::RACK_EXTENSIONS) && !legend.empty()){
363 mout.experimental("Copying (moving) legend for ", field);
364 dstData.getWhat()["legend"] = drain::sprinter(legend, "|", ",", ":").str();
365 legend.clear();
366 }
367 }
368
369
370}
371
372
373template <class AC, class OD>
375 const std::string & encoding, const drain::Rectangle<int> & cropArea){
376
378
379 mout.debug("extracting FIELD: ", field);
380
381 char fieldChar = (char)(((int)field)&127);
382 if (fieldChar != drain::image::Accumulator::getFieldChar(field)){
383 mout.fail("program error: ", field, '=', fieldChar, "!=", drain::image::Accumulator::getFieldChar(field));
384 }
385
386 //const std::type_info & t = drain::Type::getTypeInfo('C'); // drain::Type::getTypeInfo(odimOut.type);
387 if (!cropArea.empty()){
388 mout.note("Cropping ", cropArea.getWidth(), "x", cropArea.getHeight(), " from original composite ", this->accArray.getGeometry()); // this->getFrameWidth(), 'x', this->getFrameHeight());
389 mout.info("Cropping window: (", cropArea.lowerLeft, ") (", cropArea.upperRight, ") from original composite ", this->accArray.getGeometry()); // this->getFrameWidth(), 'x', this->getFrameHeight());
390 }
391
392 const QuantityMap & qm = getQuantityMap();
393
399 //bool QUANTITY_SPECIFIC_QUALITY = false;
400 //mout.experimental<LOG_NOTICE>("EncodingODIM THIS = ", this->odim);
401
403 drain::SmartMapTools::updateValues(odimData, this->odim); // Note: copies, to support extraction with different encodings
404 // This should be unneeded... // odimData.quantity = this->odim.quantity;
406 // mout.experimental<LOG_NOTICE>("EncodingODIM SRC = ", EncodingODIM(odimData));
407
409
410 // TODO: clean confusing mixture of referring to dataCoder.dataODIM <==> odimData
411 DataCoder dataCoder(odimData, odimQuality); // (will use only either odim!)
412
413 //mout.debug("extracting field '", field, "' = ", static_cast<int>(field), " #", drain::Enum<drain::image::Accumulator::FieldType>::dict.getKey(field));
414 mout.debug("extracting field '", field, "' (", static_cast<int>(field), ")");
415
416 {
417
418 /*
419 if (odimData.quantity.empty()){
420 odimData.quantity = "UNKNOWN"; // ok; for example --cPlotFile carries no information on quantity
421 mout.note("quantity=", odimData.quantity);
422 }
423 */
424 mout.debug(DRAIN_LOG(dataCoder));
425 mout.debug2(DRAIN_LOG(dataCoder.dataODIM));
426 mout.debug2(DRAIN_LOG(dataCoder.qualityODIM));
427
429
430 // Note: encoding is used only for DATA to avoid ambiguous setting for multiple request of fields: DATA,WEIGHT,COUNT, ...
431 if (field == field_t::DATA){
432
433 //pdata_dst_t & dstData = dstProduct.getData(this->odim.quantity);
434
435 // TODO: clean confusing mixture of dataCoder.dataODIM <==> odimData
436
437
438 // Update 1/2: from initial values to this "instantaneous" extraction
439 drain::SmartMapTools::updateValues(odimData, this->odim); // lazy (qualityData does not need)
440
441 mout.debug("extracting DATA/" , field, " [", odimData.quantity, ']');
442
443 if (!encoding.empty()){
444 mout.accept("User-defined encoding for data [", odimData.quantity, "]: ", encoding);
445 //odimData.completeEncoding( encoding);
446 odimData.completeEncoding(encoding);
447 }
448 else if (!getTargetEncoding().empty()){
449 mout.ok<LOG_NOTICE>("Using initial/default encoding for data [", odimData.quantity, "]: ", getTargetEncoding());
450 // odimData.completeEncoding( getTargetEncoding());
451 odimData.completeEncoding(getTargetEncoding());
452 }
453
454 if (odimData.quantity.empty()){
455 mout.error("unspecified quantity");
456 }
457
458 pdata_dst_t & dstData = dstProduct.getData(odimData.quantity);
459
460 // Update 2/2: copy "instantaneous", maybe adjusted encoding to retrieved data
461 extractFinally(*this, field, odimData, dataCoder, dstData.odim, dstData.data, cropArea);
462 return dstData;
463 /*
464 drain::SmartMapTools::updateValues(dstData.odim, odimData);
465
466 if (dataCoder.dataODIM.isSet()){
467 dstData.data.setType(odimData.type);
468 mout.debug3("dstData: " , dstData );
469 this->Accumulator::extractField(field, dataCoder, dstData.data, cropArea);
470 return dstData;
471 }
472 else {
473 // Note: this is also checked by Accumulator, but better diagnostics (ODIM) here:
474 mout.error("Target encoding unset: gain=", dataCoder.dataODIM.scaling.scale, ", type=", dataCoder.dataODIM.type);
475 return dstData;
476 }
477 */
478
479 }
480 else {
481
482 switch (field){
483 case field_t::WEIGHT_GLOBAL:
484 case field_t::WEIGHT:
485 odimQuality.quantity = "QIND";
486 break;
487 case field_t::COUNT_GLOBAL:
488 case field_t::COUNT:
489 odimQuality.quantity = "COUNT";
490 break;
491 case field_t::DEVIATION:
492 odimQuality.quantity = this->odim.quantity + "DEV";
493 odimQuality.type = "f";
494 break;
495 default:
496 mout.error("Unsupported field marker: ", field, "='", fieldChar, "'");
497 //mout.error("Unsupported field marker: ", FieldFlagger::getKeysNEW2(field));
498 }
499
500 mout.debug("extracting QUALITY/" , field, " [", odimQuality.quantity, ']');
501
502 if (qm.hasQuantity(odimQuality.quantity)){
503 // NOT tested, consider DEV mout.revised("Storage type for quality: using qualityConf default");
504 // qm.setQuantityDefaults(odimQuality, odimQuality.quantity);
505 qm.setQuantityDefaults(odimQuality, odimQuality.quantity, odimQuality.type);
506 mout.accept<LOG_DEBUG>("found quantityConf[", odimQuality.quantity, "], type=", odimQuality.type);
507 mout.special<LOG_DEBUG>("Quality: ", EncodingODIM(odimQuality));
508 mout.special<LOG_DEBUG>("Quality: ", odimQuality);
509 }
510 else if (!encoding.empty()){
511 mout.accept<LOG_INFO>("User-defined encoding for quality [", odimQuality.quantity, "]: ", encoding);
512 odimQuality.completeEncoding(encoding);
513 mout.debug("User-defined encoding for QUALITY: -> ", odimQuality);
514 }
515 else {
516 // mout.experimental("No predefined scaling for ", odimQuality.quantity);
517 /*
518 const std::type_info & t = drain::Type::getTypeInfo(odimQuality.type);
519 odimQuality.scaling.scale *= 20.0; // ?
520 odimQuality.scaling.offset = round(drain::Type::call<drain::typeMin, double>(t) + drain::Type::call<drain::typeMax, double>(t))/2.0;
521 if (encoding.empty()){
522 mout.warn("quantyConf[" , odimQuality.quantity , "] not found, using somewhat arbitrary scaling:" );
523 mout.special("Quality: ", EncodingODIM(odimQuality));
524 }
525 */
526 odimQuality.setType(typeid(float));
527 mout.warn("quantyConf[" , odimQuality.quantity , "] not found, using float" );
528 mout.special("Quality: ", EncodingODIM(odimQuality));
529
530 }
531 // else auto-scale?
532
534
535 mout.attention(DRAIN_LOG(field), DRAIN_LOG(QUANTITY_SPECIFIC_QUALITY));
536 //mout.attention(DRAIN_LOG(QUANTITY_SPECIFIC_QUALITY));
537
541
542
543 // NOTE similarity... but fct still would need separating (dataCoder, odimData, odimQuality, odimNow, field, crop)
544 extractFinally(*this, field, odimQuality, dataCoder, dstQuality.odim, dstQuality.data, cropArea);
545 return dstQuality;
546 /*
547 drain::SmartMapTools::updateValues(dstQuality.odim, odimQuality);
548 // if (dataCoder.squalityODIM.isSet()){
549 if (dstQuality.odim.isSet()){
550 // dstQuality.data.setType(odimData.type); // <- this was probably wrong
551 dstQuality.data.setType(dstQuality.odim.type); // <- this was probably wrong
552 mout.debug3("dstData: " , dstQuality );
553 this->Accumulator::extractField(fieldChar, dataCoder, dstQuality.data, cropArea);
554 return dstQuality;
555 }
556 else {
557 // Note: this is also checked by Accumulator, but better diagnostics (ODIM) here:
558 mout.error("Target encoding unset: gain=", dstQuality.odim.scaling.scale, ", type=", dstQuality.odim.type);
559 //mout.error("Target encoding unset: gain=", dataCoder.qualityODIM.scaling.scale, ", type=", dataCoder.qualityODIM.type);
560 return dstQuality;
561 }
562 */
563
564 }
565
566 // mout.debug("updating local tree attributes");
567
568 }
569
570
571 // mout.debug("updating local tree attributes" );
572 // mout.debug("finished" );
573
574}
575
576// TODO: remove this (use the new ones)
577template <class AC, class OD>
579 const std::string & fields, const drain::Rectangle<int> & crop) const {
580 // , const drain::Rectangle<double> & bbox) const {
581
583
584 const std::type_info & t = drain::Type::getTypeInfo(odimOut.type);
585
586 typedef enum {DATA,QUALITY} datatype;
587
588 OD odimData;
589 odimData = odimOut;
590 odimData.scaling.scale = 0.0; // ?
591
592 const QuantityMap & qm = getQuantityMap();
593
594 // Determines if quality is stored in
595 // /dataset1/quality1/
596 // or
597 // /dataset1/data1/quality1/
598 //
599 bool QUANTITY_SPECIFIC_QUALITY = false;
600
601 // Consider redesign, with a map of objects {quantity, type,}
602 for (size_t i = 0; i < fields.length(); ++i) {
603
605 odimQuality.quantity = "QIND";
606
607 // std::stringstream dataPath;
608
609 datatype type = DATA;
610 char field = fields.at(i);
611 switch (field) {
612 case '/':
614 continue;
615 break; // unneeded?
616 case 'm': // ???
617 case 'D':
618 case 'p': // ???
619 mout.warn() << "non-standard layer code; use 'd' for 'data' instead" << mout.endl;
620 // no break TODO: CHECK
621 case 'd':
622 type = DATA;
623 odimData = odimOut; // consider update
624 qm.setQuantityDefaults(odimQuality, "QIND"); // ?
625 odimQuality.quantity = "QIND";
626 break;
627 case 'c':
628 type = QUALITY;
629 qm.setQuantityDefaults(odimQuality, "COUNT");
630 odimQuality.quantity = "COUNT";
631 break;
632 case 'C':
633 type = QUALITY;
634 qm.setQuantityDefaults(odimQuality, "COUNT", "d");
635 odimQuality.quantity = "COUNT";
636 break;
637 // case 'q': // consider
638 case 'w':
639 // no break
640 type = QUALITY;
641 odimData = odimOut; // (Because converter needs both data and weight to encode weight?)
642 qm.setQuantityDefaults(odimQuality, "QIND", "C");
643 odimQuality.quantity = "QIND";
644 //odimQuality.undetect = 256;
645 //odimQuality.nodata = -1; // this is good, because otherwise nearly-undetectValue-quality CAPPI areas become no-data.
646 break;
647 case 'W':
648 mout.warn("experimental: quality [QIND] type copied from data [" , odimOut.quantity , ']' );
649 // no break
650 type = QUALITY;
651 odimData = odimOut; // (Because converted needs both data and weight to encode weight?)
652 qm.setQuantityDefaults(odimQuality, "QIND", odimOut.type);
653 odimQuality.quantity = "QIND";
654 //odimQuality.undetect = 256;
655 //odimQuality.nodata = -1; // this is good, because otherwise nearly-undetectValue-quality CAPPI areas become no-data.
656 break;
657 case 's':
658 type = QUALITY;
659 odimQuality = odimOut;
660 odimQuality.quantity += "DEV";
661 if (qm.hasQuantity(odimQuality.quantity)){
662 qm.setQuantityDefaults(odimQuality, odimQuality.quantity, odimQuality.type);
663 mout.accept<LOG_NOTICE>("found quantyConf[", odimQuality.quantity, "], type=", odimQuality.type);
664 //mout.special("Quality: ", EncodingODIM(odimQuality));
665 mout.special("Quality: ", EncodingODIM(odimQuality));
666 mout.special("Quality: ", odimQuality);
667 }
668 else {
669 odimQuality.scaling.scale *= 20.0; // ?
670 //const std::type_info & t = Type::getType(odimFinal.type);
671 odimQuality.scaling.offset = round(drain::Type::call<drain::typeMin, double>(t) + drain::Type::call<drain::typeMax, double>(t))/2.0;
672 //odimQuality.offset = round(drain::Type::call<drain::typeMax,double>(t) + drain::Type::getMin<double>(t))/2.0; // same as data!
673 mout.warn("quantyConf[" , odimQuality.quantity , "] not found, using somewhat arbitary scaling:" );
674 mout.special("Quality: ", EncodingODIM(odimQuality));
675 }
676 break;
677 default:
678 mout.error("Unsupported field code: '", field, "'");
679 break;
680 }
681
682 mout.debug("extracting field ", field);
683
684 if (!crop.empty()){
685 mout.experimental("Applying cropping: bbox=", crop, " [pix]");
686 }
687
688 if (type == DATA){
689 mout.debug("target: " , EncodingODIM(odimData) );
690 }
691 else if (type == QUALITY){
692 mout.debug("target: " , EncodingODIM(odimQuality) );
693 }
694
695 if (odimData.quantity.empty()){
696 odimData.quantity = "UNKNOWN"; // ok; for example --cPlotFile carries no information on quantity
697 mout.note("quantity=", odimData.quantity);
698 }
699
700 //PlainData<DstType<OD> >
701 mout.debug("searching dstData... DATA=", (type == DATA));
702 //pdata_dst_t & dstData = (type == DATA) ? dstProduct.getData(odimFinal.quantity) : dstProduct.getQualityData(odimQuality.quantity);
703 //mout .debug3() << "dstData: " << dstData << mout.endl;
704
705 //DataDst dstData(dataGroup); // FIXME "qualityN" instead of dataN creates: /dataset1/qualityN/quality1/data
706 //mout.warn("odimFinal: " , odimFinal );
707 mout.debug("odimData: " , EncodingODIM(odimData) );
708 DataCoder dataCoder(odimData, odimQuality); // (will use only either odim!)
709 mout.debug("dataCoder: ", dataCoder);
710 mout.debug2("dataCoder: data: ", dataCoder.dataODIM);
711 mout.debug2("dataCoder: qind: ", dataCoder.qualityODIM);
712
713 if (!crop.empty()){
714 mout.unimplemented("crop ", crop, ", dstData.data resize + Accumulator::extractField ");
715 }
716
717 if (type == DATA){
718 mout.debug("DATA/" , field, " [", odimData.quantity, ']');
719 //mout.warn(dstData.odim );
720 pdata_dst_t & dstData = dstProduct.getData(odimData.quantity);
721 dstData.odim.importMap(odimData);
722 dstData.data.setType(odimData.type);
723 mout.debug3("dstData: " , dstData );
724 //mout.debug("quantity=" , dstData.odim.quantity );
725 this->Accumulator::extractField(field, dataCoder, dstData.data, crop);
726 }
727 else {
728 mout.debug("QUALITY/" , field , " [", odimQuality.quantity, ']');
729 //pdata_dst_t & dstData = dstProduct.getData(odimFinal.quantity);
733 dstData.odim.updateFromMap(odimQuality);
734 mout.debug3("dstData: " , dstData );
735 this->Accumulator::extractField(field, dataCoder, dstData.data, crop);
736 }
737
738
739 // mout.debug("updating local tree attributes");
740
741 }
742
743
744 // mout.debug("updating local tree attributes" );
745 // mout.debug("finished" );
746
747}
748
749
750} // rack::
751
752
753#endif /* RADAR_ACCUMULATOR */
754
755// Rack
LogSourc e is the means for a function or any program segment to "connect" to a Log.
Definition Log.h:326
static void updateValues(M &dst, const std::map< std::string, S > &src)
Definition MapTools.h:227
static const std::type_info & getTypeInfo(char t)
Returns the base type associated with a character key.
Definition Type.h:131
Function for accumulating data: maximum, average, weighted average etc.
Definition AccumulationMethods.h:66
Definition Accumulator.h:76
static bool isSpecific(FieldType field)
Future option to mark scaled/normalized etc.
Definition Accumulator.h:120
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.h:247
FieldType
Definition Accumulator.h:84
Class for multi-channel digital images. Supports dynamic typing with base types (char,...
Definition Image.h:183
Converts ODIM encoded data (with markers) to natural values and backwards.
Definition DataCoder.h:58
Tool for selecting datasets based on paths, quantities and min/max elevations.
Definition DataSelector.h:106
A map of radar data, indexed by quantity code (DBZH, VRAD, etc).
Definition Data.h:1293
Structure for data storage type, scaling and marker codes. Does not contain quantity.
Definition EncodingODIM.h:70
static const group_t QUALITY
Special group on first or second level, /quality + digit , used for storing quality data.
Definition ODIMPath.h:115
static const group_t DATA
Second level group, /data + digit .
Definition ODIMPath.h:109
ODIM metadata (quantity, gain, offset, undetect, nodata, date, time)
Definition ODIM.h:79
Essential class for storing radar data.
Definition Data.h:311
const plaindata_t & getQualityData(const std::string &quantity="QIND") const
Finds associated quality data - maybe empty and unscaled.
Definition Data.h:1137
Registry for regular quantities appearing in weather radar.
Definition QuantityMap.h:67
bool setQuantityDefaults(EncodingODIM &dst, const std::string &quantity, const std::string &values="") const
Sets default values of given quantity without assigning the quantity. Optionally overrides with user ...
Definition QuantityMap.cpp:210
Todo: consider non-template class:
Definition RadarAccumulator.h:63
size_t counter
Book-keeping for new data. Finally, in extraction phase, added to odim.ACCnum .
Definition RadarAccumulator.h:97
DataSelector dataSelector
Input data selector. Could be protected, but accumulation.cpp accesses directly.
Definition RadarAccumulator.h:83
double defaultQuality
If source data has no quality field, this value is applied for (detected) data.
Definition RadarAccumulator.h:91
Data array for creating composites and accumulated polar products (Surface rain fall or cluttermaps)
Definition RadarAccumulator.h:124
OD odim
For storing the scaling and encoding of (1st) input or user-defined values. Also for bookkeeping of d...
Definition RadarAccumulator.h:187
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:269
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:578
RadarAccumulator()
Default constructor.
Definition RadarAccumulator.h:135
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:304
bool checkCompositingMethod(const ODIM &dataODIM)
Warns if data scaling involves risks in using WAVG (weighted averaging)
Definition RadarAccumulator.h:217
PlainData< SrcType< OD const > > pdata_src_t
Input data type.
Definition RadarAccumulator.h:129
pdata_dst_t & extract(DataSet< DstType< OD > > &dstProduct, field_t field=field_t::DATA, const std::string &encoding="C", const drain::Rectangle< int > &cropArea={0, 0})
Definition RadarAccumulator.h:374
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:227
Definition AltitudeOp.cpp:42
QuantityMap & getQuantityMap()
Definition QuantityMap.cpp:282
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