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  enum FieldType {
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  };
119 
120  //typedef drain::Dictionary<std::string,unsigned long> FieldDict;
121  //typedef drain::EnumDict<FieldType> FieldDict;
122  typedef drain::EnumDict<FieldType>::dict_t dict_t;
123  static
124  const dict_t dict;
125 
126  // Possible future extension.
127  // Must choose between char-based or bit flagging (d,w,c,s will overlap).
128  // typedef drain::EnumFlagger<drain::MultiFlagger<FieldType> > FieldFlagger;
129 
130 
131  Composite();
132 
133  virtual ~Composite(){};
134 
135  // To allow consecutive --cExtract calls (for --encoding )
136  bool extracting = false;
137 
138  void extractNEW2(DataSet<DstType<CartesianODIM> > & dstProduct, const std::string & fields="d", const drain::Rectangle<int> & cropArea={0,0}, const std::string & encoding="C");
139 
140  void extractNEW(DataSet<DstType<CartesianODIM> > & dstProduct, FieldType field = DATA, const drain::Rectangle<int> & cropArea={0,0}, const std::string & encoding="C");
141 
143 
147  inline
148  void setCropping(bool cropping = true){ this->cropping = cropping; };
149 
150  inline
151  bool isCropping(){
152  return cropping;
153  };
154 
155 
157  void checkQuantity(const std::string & quantity);
158 
159 
161 
168  void addPolar(const PlainData<PolarSrc> & src, const PlainData<PolarSrc> & srcQuality, double weight, bool autoProj);
169 
171 
177  void addCartesian(const PlainData<CartesianSrc> & src, const PlainData<CartesianSrc> & srcQuality, double weight = 1.0, int i=0, int j=0);
178 
179 
181  double decay;
182 
183  double getTimeDifferenceMinute(const CartesianODIM & odimIn) const;
184 
186 
189  void updateGeoData();
190 
193 
195  // drain::VariableMap metadataMap;
196 
198 
203  void updateInputSelector(const std::string & select);
204 
205  // With current settings, create simple "Polar volume" containing coordinates.
206  // void createProjectionLookup(Hi5Tree & dst, const AreaGeometry & binGeometry = {500,360});
207  void createBinIndex(Hi5Tree & dst);
208 
209  void createBinIndex(Hi5Tree & dst, const PolarODIM & odim);
210 
211 protected:
212 
213  void addPolarInnerLoop(const PlainData<PolarSrc> & srcData, const PlainData<PolarSrc> & srcQuality, double priorWeight,
214  const RadarProj & pRadarToComposite, const drain::Rectangle<int> & bboxPix);
215 
216  void updateNodeMap(const std::string & node, int i, int j);
217 
218  bool cropping;
219 
220 };
221 
222 } // rack::
223 
224 #endif /*COMPOSITE_H_*/
225 
226 // 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:148
FieldType
Definition: Composite.h:108
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:181
drain::VariableMap nodeMap
Node keys (like "fivan") associated with upper left corner pixel coordinates [int] of the "tile".
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