Loading...
Searching...
No Matches
Composite.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 COMPOSITE2_H_
32#define COMPOSITE2_H_
33
34#include <drain/image/AccumulationConverter.h>
35#include <drain/image/AccumulatorGeo.h>
36#include <drain/util/Rectangle.h>
37
38#include "hi5/Hi5.h"
39#include "data/CartesianODIM.h"
40#include "data/Data.h"
41
42#include "RadarAccumulator.h"
43#include "RadarProj.h"
44
45namespace rack
46{
47
48using namespace drain::image;
49
50
51
53
101class Composite : public RadarAccumulator<drain::image::AccumulatorGeo,CartesianODIM>
102{
103public:
104
105 /*
106 enum FieldType {
107 DATA_SPECIFIC = 32, // Ascii bit for lower-case chars, see below
108 QUALITY = 256, // Marker for non-data
109 DATA = 'd', // Main data, of named quantity
110 WEIGHT = 'w'|QUALITY, // Quality
111 COUNT = 'c'|QUALITY, // Number of samples
112 DEVIATION = 's'|QUALITY, // Separation: std.dev or difference
113 WEIGHT_DS = 'W'|QUALITY, // Quality
114 COUNT_DS = 'C'|QUALITY, // Number of samples
115 DEVIATION_DS = 'S'|QUALITY // Separation
116 };
117
118 typedef drain::EnumDict<FieldType>::dict_t dict_t;
119 static
120 const dict_t dict;
121 */
122
123 // Possible future extension.
124 // Must choose between char-based or bit flagging (d,w,c,s will overlap).
125 // typedef drain::EnumFlagger<drain::MultiFlagger<FieldType> > FieldFlagger;
126
127 //typedef std::map<int,std::string> legend_t;
128 //legend_t legend;
129
130 Composite();
131
132 virtual ~Composite(){};
133
134 // To allow consecutive --cExtract calls (for --encoding )
135 bool extracting = false;
136
137 /*
138 inline
139 void extract(DataSet<DstType<CartesianODIM> > & dstProduct, const std::string & fieldStr, const std::string & encoding="C", const drain::Rectangle<int> & cropArea={0,0}){
140 FieldList fields;
141 getFields(fieldStr, fields);
142 extract(dstProduct, fields, encoding, cropArea);
143 }
144
145 void extract(DataSet<DstType<CartesianODIM> > & dstProduct, const FieldList & fields, const std::string & encoding="C", const drain::Rectangle<int> & cropArea={0,0});
146
147 pdata_dst_t & extract(DataSet<DstType<CartesianODIM> > & dstProduct, FieldType field = DATA, const std::string & encoding="C", const drain::Rectangle<int> & cropArea={0,0});
148 */
149
151
155 inline
156 void setCropping(bool cropping = true){ this->cropping = cropping; };
157
158 inline
159 bool isCropping(){
160 return cropping;
161 };
162
163
165 void checkQuantity(const std::string & quantity);
166
167
169
176 void addPolar(const PlainData<PolarSrc> & src, const PlainData<PolarSrc> & srcQuality, double weight, bool autoProj);
177
179
185 void addCartesian(const PlainData<CartesianSrc> & src, const PlainData<CartesianSrc> & srcQuality, double weight = 1.0, int i=0, int j=0);
186
187
189
192 double decay = 0.0;
193
194 double getTimeDifferenceMinute(const CartesianODIM & odimIn) const;
195
197
200 void updateGeoData();
201
204
206 // drain::VariableMap metadataMap;
207
209
214 void updateInputSelector(const std::string & select);
215
216 // With current settings, create simple "Polar volume" containing coordinates.
217 // void createProjectionLookup(Hi5Tree & dst, const AreaGeometry & binGeometry = {500,360});
218 void createBinIndex(Hi5Tree & dst);
219
220 void createBinIndex(Hi5Tree & dst, const PolarODIM & odim);
221
222protected:
223
224 void addPolarInnerLoop(const PlainData<PolarSrc> & srcData, const PlainData<PolarSrc> & srcQuality, double priorWeight,
225 const RadarProj & pRadarToComposite, const drain::Rectangle<int> & bboxPix);
226
227 //static
228 //void createFieldList(const std::string & fields, std::list<FieldType> & fieldList);
229
230 void updateNodeMap(const std::string & node, int i, int j);
231
232 bool cropping = false;
233
234
235 Data<DstType<CartesianODIM> > & prepareDstData(DataSet<DstType<CartesianODIM> > & dstProduct);
236
237
238};
239
240} // rack::
241
242DRAIN_ENUM_OSTREAM(rack::Composite::FieldType);
243
244
245#endif /*COMPOSITE_H_*/
A map of Variables.
Definition VariableMap.h:61
FieldType
Definition Accumulator.h:84
Metadata structure for Cartesian radar data products (single-radar or composites).
Definition CartesianODIM.h:47
Cartesian composite (mosaic) of data from several radars.
Definition Composite.h:102
void addPolar(const PlainData< PolarSrc > &src, const PlainData< PolarSrc > &srcQuality, double weight, bool autoProj)
Projects radar data in polar coordinates to Cartesian coordinates.
Definition Composite.cpp:340
void setCropping(bool cropping=true)
If cropping is set, calling addPolar() also crops the bounding box to intersection of radar area and ...
Definition Composite.h:156
void addPolarInnerLoop(const PlainData< PolarSrc > &srcData, const PlainData< PolarSrc > &srcQuality, double priorWeight, const RadarProj &pRadarToComposite, const drain::Rectangle< int > &bboxPix)
Definition Composite.cpp:208
void createBinIndex(Hi5Tree &dst)
Definition Composite.cpp:106
void updateInputSelector(const std::string &select)
EXPERIMENTAL: save elangles TODO: consider rename metadataMap (for hairy details)
Definition Composite.cpp:651
void updateGeoData()
Updates xscale, rscale and secondary Bounding Box attributes.
Definition Composite.cpp:621
double decay
Weight decrease (0.0...1.0), per minute, in the weighting of delayed data. Zero means no change in we...
Definition Composite.h:192
void addCartesian(const PlainData< CartesianSrc > &src, const PlainData< CartesianSrc > &srcQuality, double weight=1.0, int i=0, int j=0)
Add data that matches the Cartesian projection and scaling of the composite.
Definition Composite.cpp:586
void checkQuantity(const std::string &quantity)
Sets quantity. Warns if input has a different quantity.
Definition Composite.cpp:166
Composite()
Definition Composite.cpp:76
drain::VariableMap nodeMap
Node keys (like "fivan") associated with upper left corner pixel coordinates [int] of the "tile".
Definition Composite.h:203
A map of radar data, indexed by quantity code (DBZH, VRAD, etc).
Definition Data.h:1215
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
Metadata structure for single-radar data (polar scans, volumes and products).
Definition PolarODIM.h:45
Data array for creating composites and accumulated polar products (Surface rain fall or cluttermaps)
Definition RadarAccumulator.h:122
CartesianODIM odim
For storing the scaling and encoding of (1st) input or user-defined values. Also for bookkeeping of d...
Definition RadarAccumulator.h:185
Definition RadarProj.h:99
Namespace for images and image processing tools.
Definition AccumulationArray.cpp:45
Definition DataSelector.cpp:44
Rectange defined through lower left and upper right coordinates.
Definition Rectangle.h:65
Writable data type.
Definition Data.h:120