Composite.h
1 /*
2 
3 MIT License
4 
5 Copyright (c) 2017 FMI Open Development / Markus Peura, first.last@fmi.fi
6 
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software and associated documentation files (the "Software"), to deal
9 in the Software without restriction, including without limitation the rights
10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 copies of the Software, and to permit persons to whom the Software is
12 furnished to do so, subject to the following conditions:
13 
14 The above copyright notice and this permission notice shall be included in all
15 copies or substantial portions of the Software.
16 
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 SOFTWARE.
24 
25 */
26 /*
27 Part of Rack development has been done in the BALTRAD projects part-financed
28 by the European Union (European Regional Development Fund and European
29 Neighbourhood 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 
36 #include "drain/image/AccumulatorGeo.h"
37 #include "drain/util/Rectangle.h"
38 
39 #include "hi5/Hi5.h"
40 #include "data/CartesianODIM.h"
41 #include "data/Data.h"
42 //#include "data/DataSelector.h"
43 //#include "Coordinates.h"
44 
45 #include "RadarAccumulator.h"
46 #include "RadarProj.h"
47 
48 namespace rack
49 {
50 
51 using namespace drain::image;
52 
53 
54 
56 
104 class Composite : public RadarAccumulator<drain::image::AccumulatorGeo,CartesianODIM>
105 {
106 public:
107 
108  typedef enum {
109  DATA_SPECIFIC = 32,
110  QUALITY = 256,
111  DATA = 'd',
112  WEIGHT = 'w'|QUALITY,
113  COUNT = 'c'|QUALITY,
114  DEVIATION = 's'|QUALITY,
115  WEIGHT_DS = 'W'|QUALITY,
116  COUNT_DS = 'C'|QUALITY,
117  DEVIATION_DS = 'S'|QUALITY
118  } FieldType;
119 
121  static FieldDict dict;
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 
128  Composite();
129 
130  virtual ~Composite(){};
131 
132  // To allow consecutive --cExtract calls (for --encoding )
133  bool extracting = false;
134 
135  void extractNEW2(DataSet<DstType<CartesianODIM> > & dstProduct, const std::string & fields="d", const drain::Rectangle<int> & cropArea={0,0}, const std::string & encoding="C");
136 
137  void extractNEW(DataSet<DstType<CartesianODIM> > & dstProduct, FieldType field = DATA, const drain::Rectangle<int> & cropArea={0,0}, const std::string & encoding="C");
138 
140 
144  inline
145  void setCropping(bool cropping = true){ this->cropping = cropping; };
146 
147  inline
148  bool isCropping(){
149  return cropping;
150  };
151 
152 
154  void checkQuantity(const std::string & quantity);
155 
156 
158 
165  void addPolar(const PlainData<PolarSrc> & src, const PlainData<PolarSrc> & srcQuality, double weight, bool autoProj);
166 
168 
174  void addCartesian(const PlainData<CartesianSrc> & src, const PlainData<CartesianSrc> & srcQuality, double weight = 1.0, int i=0, int j=0);
175 
176 
178  double decay;
179 
180  double getTimeDifferenceMinute(const CartesianODIM & odimIn) const;
181 
183 
186  void updateGeoData();
187 
190 
193 
195 
200  void updateInputSelector(const std::string & select);
201 
202  // With current settings, create simple "Polar volume" containing coordinates.
203  // void createProjectionLookup(Hi5Tree & dst, const AreaGeometry & binGeometry = {500,360});
204  void createBinIndex(Hi5Tree & dst);
205 
206  void createBinIndex(Hi5Tree & dst, const PolarODIM & odim);
207 
208 protected:
209 
210  void addPolarInnerLoop(const PlainData<PolarSrc> & srcData, const PlainData<PolarSrc> & srcQuality, double priorWeight,
211  const RadarProj & pRadarToComposite, const drain::Rectangle<int> & bboxPix);
212 
213  void updateNodeMap(const std::string & node, int i, int j);
214 
215  bool cropping;
216 
217 };
218 
219 } // rack::
220 
221 #endif /*COMPOSITE_H_*/
222 
223 // Rack
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:105
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:145
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:178
drain::VariableMap nodeMap
Node keys (like "fivan") associated with upper left corner pixel coordinates [int] of the "tile".
Definition: Composite.h:189
drain::VariableMap metadataMap
EXPERIMENTAL: save elangles TODO: consider rename metadataMap (for hairy details)
Definition: Composite.h:192
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
Data array for creating composites and accumulated polar products (Surface rain fall or cluttermaps)
Definition: RadarAccumulator.h:61
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