DopplerOp.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 DOPPLER_OP_H_
33 #define DOPPLER_OP_H_
34 
35 #include "PolarProductOp.h"
36 
37 //#include "radar/Doppler.h"
38 #include "radar/PolarSector.h"
39 
40 
41 namespace rack {
42 
43 
45 
49 class DopplerOp : public PolarProductOp {
50 
51 public:
52 
53 
54  /*
55  DopplerOp() : PolarProductOp(__FUNCTION__, "Projects Doppler speeds to unit circle. Window corners as (azm,range) or (ray,bin)") {
56  parameters.append(w.getParameters());
57  dataSelector.quantity = "^(VRAD|VRADH)$";
58  dataSelector.setMaxCount(1);
59  };
60  */
61 
62  virtual inline ~DopplerOp(){};
63 
64  //mutable PolarSector w;
65 
67  // raise
68  static inline
69  double project(double azmR, double u, double v) {
70  // double speed = sqrt(u*u + v*v);
71  return u*sin(azmR) + v*cos(azmR);
72  }
73 
74 
75  // Re-alias
76  // x - 2*Vm*math.floor((Vm+x)/2.0/Vm)
77  static inline
78  double alias(double v, double vNyq) {
79  return v - (2.0*vNyq)*floor((vNyq + v)/(2.0*vNyq)); // consider vNyq2
80  }
81 
82  static
83  const drain::RegExp regExpVRAD;
84 
85 protected:
86 
87  DopplerOp(const std::string & name, const std::string &description) : PolarProductOp(name, description){
88  //dataSelector.quantity = "VRADH?";
89  dataSelector.setQuantities("^VRADH?$"); // avoid VRADDH
90  dataSelector.setMaxCount(1);
91  // dataSelector.selectPRF = DataSelector::Prf::DOUBLE;
92  }
93 
94  //virtual void processDataSet(const DataSet<PolarSrc> & srcSweep, DataSet<PolarDst> & dstProduct) const ;
95 
96 
97 };
98 
99 
101 
104 class DopplerDiffOp : public DopplerOp { // DopplerWindow unused!
105 public:
106 
107 
109 
112  DopplerDiffOp(double dMaz = 100.0) : DopplerOp(__FUNCTION__, "Azimuthal difference of VRAD") { //, widthM, heightD) {
113  //parameters.link("width", this->widthM = widthM, "metres");
114  parameters.link("dMax", this->dMax = dMax, "m/s");
115 
116  dataSelector.setQuantities("VRAD.*");
117 
118  dataSelector.setMaxCount(1);
119 
120  odim.type = "S";
121  odim.quantity = "VRAD_DIFF";
122 
123  };
124 
125  virtual inline
126  ~DopplerDiffOp(){};
127 
128  double dMax;
129 
130  virtual
131  void processData(const Data<PolarSrc> & vradSrc, Data<PolarDst> & dstData) const;
132 
133 protected:
134 
135 
136 };
137 
138 
139 // for Testing
141 public:
142 
143  inline
144  DopplerReprojectOp() : DopplerOp(__FUNCTION__, "Creates virtual ") {
145 
146  parameters.link("nyquist", odim.NI = 100.0, "max-unamb-velocity");
147  parameters.link("match", matchOriginal=0, "flag(aliased=1,nodata=2)"); // ALIASED=1, NODATA=2
148  parameters.link("quantity", odim.quantity = "VRAD", "output-quantity");
149 
150  dataSelector.setMaxCount(1);
151  dataSelector.setQuantities("^(AMVU|AMVV|VRAD)$");
152 
153  //odim.quantity; // VRAD_C
154  odim.type = "S";
155  }
156 
157  // void processData(const Data<PolarSrc> & srcData, Data<PolarDst> & dstData) const;
158  virtual
159  void processDataSet(const DataSet<PolarSrc> & srcSweep, DataSet<PolarDst> & dstProduct) const;
160 
161 
162 
163  int matchOriginal;
164 
165 
166 };
167 
168 
169 // for Testing
170 class DopplerCrawlerOp : public DopplerOp {
171 public:
172 
173  inline
174  DopplerCrawlerOp() : DopplerOp(__FUNCTION__, "Creates virtual ") {
175 
176  parameters.link("nyquist", odim.NI = 100.0, "max-unamb-velocity");
177  parameters.link("threshold", relative_NI_threshold=0.9, "relative speed");
178  //parameters.link("quantity", odim.quantity = "VRAD", "output-quantity");
179 
180  dataSelector.setMaxCount(1);
181  dataSelector.setQuantities("^VRAD");
182 
183  odim.quantity = "VRAD";
184  odim.type = "S";
185  }
186 
187  virtual
188  void processData(const Data<src_t > & srcData, Data<dst_t > & dstData) const;
189 
190  double relative_NI_threshold;
191 
192 
193 };
194 
195 
196 } // namespace rack
197 
198 
199 #endif /* RACKOP_H_ */
200 
201 // Rack
Definition: RegExp.h:58
A map of radar data, indexed by quantity code (DBZH, VRAD, etc).
Definition: Data.h:1213
Data structure consisting of plain data and an optional quality data.
Definition: Data.h:1144
Definition: DopplerOp.h:170
Experimental.
Definition: DopplerOp.h:104
DopplerDiffOp(double dMaz=100.0)
Constructor.
Definition: DopplerOp.h:112
Base class for computing products using Doppler speed [VRAD] data.
Definition: DopplerOp.h:49
static double project(double azmR, double u, double v)
Projects wind (u,v) to beam direction (rad). Unit (typically m/s) is preserved.
Definition: DopplerOp.h:69
Definition: DopplerOp.h:140
virtual void processDataSet(const DataSet< PolarSrc > &srcSweep, DataSet< PolarDst > &dstProduct) const
Definition: DopplerOp.cpp:117
Base class for flat (2D) products computed in the polar coordinate system. Volume is used as input.
Definition: PolarProductOp.h:61
Definition: DataSelector.cpp:44