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
106 DATA_SPECIFIC = 32,
107 QUALITY = 256,
108 DATA = 'd',
114 DEVIATION_DS = 'S'|QUALITY
115 };
116
118 static
119 const dict_t dict;
120
121 // Possible future extension.
122 // Must choose between char-based or bit flagging (d,w,c,s will overlap).
123 // typedef drain::EnumFlagger<drain::MultiFlagger<FieldType> > FieldFlagger;
124
125 typedef std::map<int,std::string> legend_t;
126 legend_t legend;
127
128 Composite();
129
130 virtual ~Composite(){};
131
132 // To allow consecutive --cExtract calls (for --encoding )
133 bool extracting = false;
134
135 void extract(DataSet<DstType<CartesianODIM> > & dstProduct, const std::string & fields, const drain::Rectangle<int> & cropArea={0,0}, const std::string & encoding="C");
136 // void extract(DataSet<DstType<CartesianODIM> > & dstProduct, const std::string & fields="d", const drain::Rectangle<int> & cropArea={0,0}, const std::string & encoding="C");
137
138 pdata_dst_t & extract(DataSet<DstType<CartesianODIM> > & dstProduct, FieldType field = DATA, const drain::Rectangle<int> & cropArea={0,0}, const std::string & encoding="C");
139
141
145 inline
146 void setCropping(bool cropping = true){ this->cropping = cropping; };
147
148 inline
149 bool isCropping(){
150 return cropping;
151 };
152
153
155 void checkQuantity(const std::string & quantity);
156
157
159
166 void addPolar(const PlainData<PolarSrc> & src, const PlainData<PolarSrc> & srcQuality, double weight, bool autoProj);
167
169
175 void addCartesian(const PlainData<CartesianSrc> & src, const PlainData<CartesianSrc> & srcQuality, double weight = 1.0, int i=0, int j=0);
176
177
179
182 double decay = 0.0;
183
184 double getTimeDifferenceMinute(const CartesianODIM & odimIn) const;
185
187
190 void updateGeoData();
191
194
196 // drain::VariableMap metadataMap;
197
199
204 void updateInputSelector(const std::string & select);
205
206 // With current settings, create simple "Polar volume" containing coordinates.
207 // void createProjectionLookup(Hi5Tree & dst, const AreaGeometry & binGeometry = {500,360});
208 void createBinIndex(Hi5Tree & dst);
209
210 void createBinIndex(Hi5Tree & dst, const PolarODIM & odim);
211
212protected:
213
214 void addPolarInnerLoop(const PlainData<PolarSrc> & srcData, const PlainData<PolarSrc> & srcQuality, double priorWeight,
215 const RadarProj & pRadarToComposite, const drain::Rectangle<int> & bboxPix);
216
217 void updateNodeMap(const std::string & node, int i, int j);
218
219 bool cropping = false;
220
221
222 Data<DstType<CartesianODIM> > & prepareDstData(DataSet<DstType<CartesianODIM> > & dstProduct);
223
224
225};
226
227} // rack::
228
229DRAIN_ENUM_OSTREAM(rack::Composite::FieldType);
230
231
232#endif /*COMPOSITE_H_*/
Two-way mapping between strings and objects of template class T.
Definition Dictionary.h:63
A map of Variables.
Definition VariableMap.h:61
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:353
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:146
void addPolarInnerLoop(const PlainData< PolarSrc > &srcData, const PlainData< PolarSrc > &srcQuality, double priorWeight, const RadarProj &pRadarToComposite, const drain::Rectangle< int > &bboxPix)
Definition Composite.cpp:221
void createBinIndex(Hi5Tree &dst)
Definition Composite.cpp:119
void updateInputSelector(const std::string &select)
EXPERIMENTAL: save elangles TODO: consider rename metadataMap (for hairy details)
Definition Composite.cpp:664
void updateGeoData()
Updates xscale, rscale and secondary Bounding Box attributes.
Definition Composite.cpp:634
FieldType
Definition Composite.h:105
@ WEIGHT_DS
Definition Composite.h:112
@ COUNT
Definition Composite.h:110
@ DEVIATION_DS
Definition Composite.h:114
@ COUNT_DS
Definition Composite.h:113
@ WEIGHT
Definition Composite.h:109
@ DATA
Definition Composite.h:108
@ QUALITY
Definition Composite.h:107
@ DEVIATION
Definition Composite.h:111
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:182
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:599
void checkQuantity(const std::string &quantity)
Sets quantity. Warns if input has a different quantity.
Definition Composite.cpp:179
Composite()
Definition Composite.cpp:89
drain::VariableMap nodeMap
Node keys (like "fivan") associated with upper left corner pixel coordinates [int] of the "tile".
Definition Composite.h:193
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:61
CartesianODIM odim
For storing the scaling and encoding of (1st) input or user-defined values. Also for bookkeeping of d...
Definition RadarAccumulator.h:111
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