PseudoRhiOp.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 
32 #ifndef PseudoRhiOP_OP_H_
33 #define PseudoRhiOP_OP_H_
34 
35 #include <string>
36 
37 #include "data/Data.h"
38 #include "data/DataSelector.h"
39 #include "data/PolarODIM.h"
40 #include "data/VerticalODIM.h"
41 #include "product/VolumeOp.h"
42 
43 namespace rack {
44 
45 using namespace drain::image;
46 
48 
51 class PseudoRhiOp : public VolumeOp<RhiODIM> { // Consider class lift
52 public:
53 
54  //PseudoRhiOp(const std::string & name = "PolarProductOp", const std::string & description = "");
55  PseudoRhiOp(double az_angle=0.0, long int xsize=500, long int ysize=250, double minRange=1.0, double range=250.0,
56  double minHeight=0, double maxHeight=10000, double beamWidth = 0.25, double beamPowerThreshold = 0.01) : //, std::string type="C", double gain=0.5, double offset=-32.0) :
57  VolumeOp<RhiODIM>("PseudoRhiOp","Computes vertical intersection in a volume in the beam direction.") {
58 
59  odim.object = "XSEC";
60  odim.product = "PRHI";
61 
62  parameters.link("az_angle", odim.az_angle = az_angle, "deg");
63  parameters.link("xsize", odim.area.width = xsize, "pix");
64  parameters.link("ysize", odim.area.height = ysize, "pix");
65 
66  odim.range.set(minRange, range);
67  parameters.link("range", odim.range.tuple(), "km");
68 
69  odim.altitudeRange.set(minHeight, maxHeight);
70  parameters.link("height", odim.altitudeRange.tuple(), "m" );
71 
72  /*
73  parameters.link("minRange", odim.minRange = minRange, "km");
74  parameters.link("range", odim.range = range, "km");
75  parameters.link("minHeight", odim.minheight = minHeight, "m");
76  parameters.link("maxHeight", odim.maxheight = maxHeight, "m");
77  */
78  //link("levels", odim.levels, levels);
79 
80  parameters.link("beamWidth", this->beamWidth = beamWidth, "deg");
81  parameters.link("beamPowerThreshold", this->weightThreshold = beamPowerThreshold, "0..1");
82 
83  // link("undetectValue", undetectValue, -30.0); AUTOMATIC, see --quantity DBZH:undetectValue
84  //link("type", odim.type, "C"); // TODO
85  //link("gain", odim.scaling.scale, 0.5);
86  //link("offset", odim.scaling.offset, -32.0);
87 
88  allowedEncoding.link("type", odim.type = "C"); // TODO: automatic?
89  allowedEncoding.link("gain", odim.scaling.scale);
90  allowedEncoding.link("offset", odim.scaling.offset);
91 
92  dataSelector.setQuantities("^DBZH$");
93 
94  }
95 
96  virtual
97  inline
98  ~PseudoRhiOp(){};
99 
100 
101  double beamWidth;
102  double weightThreshold; // = 0.1;
103  // double undetectValue;
104 
106  virtual
107  void computeSingleProduct(const DataSetMap<PolarSrc> & src, DataSet<RhiDst> & dstProduct) const;
108 
109 protected:
110 
111  inline
112  void setGeometry(const PolarODIM & srcODIM, PlainData<RhiDst> & dstData) const;
114 
118  inline
119  static
120  double relativeBeamPower(double angle, double beamWidth2){
121  return beamWidth2 / (beamWidth2 + angle*angle);
122  }
123 
124 
125 };
126 
127 
128 } // namespace rack
129 
130 #endif /* RACKOP_H_ */
131 
132 // Rack
Definition: Data.h:1368
A map of radar data, indexed by quantity code (DBZH, VRAD, etc).
Definition: Data.h:1213
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
Pseudo Range-Height indicator.
Definition: PseudoRhiOp.h:51
static double relativeBeamPower(double angle, double beamWidth2)
Definition: PseudoRhiOp.h:120
Base class for radar data processors.
Definition: VolumeOp.h:88
Namespace for images and image processing tools.
Definition: AccumulationArray.cpp:45
Definition: DataSelector.cpp:44