RainRateDPOp.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  // Algorithm is based on the study made by Brandon Hickman from The University Of Helsinki
32 #ifndef RAINRATE_DP_OP_H_
33 #define RAINRATE_DP_OP_H_
34 
35 //#include "VolumeOpNew.h"
36 #include "PolarProductOp.h"
37 
38 
39 using namespace drain::image;
40 
41 namespace rack {
42 
44 
57 
58 public:
59 
60  //RainRateDPOp(double a = 22.7, double b = 0.802) :
61  RainRateDPOp() :
62  PolarProductOp("RainRateDP","Precip. rate [mm/h] from dual-pol using fuzzy thresholds. Alg. by Brandon Hickman"),
63  dbzRange(30.0, 50.0), kdpRange(0.25, 0.35), zdrRange(0.15, 0.25)
64  {
65 
66  dataSelector.setQuantities("^(DBZH|RHOHV|KDP|ZDR|QIND)$");
67  dataSelector.setMaxCount(1);
68 
69  odim.product = "SURF";
70  odim.quantity = "RATE";
71  odim.type = "S";
72 
73  parameters.link("dbz", dbzRange.tuple(), "heavy:hail").fillArray = true;
74  parameters.link("zdr", zdrRange.tuple(), "heavy").fillArray = true;
75  parameters.link("rhohv", rhohv = 0.85, "met");
76  parameters.link("kdp", kdpRange.tuple(), "heavy").fillArray = true;
77 
78  // quantityMap.setQuantityDefaults(odim, "RATE", "S");
79  /*
80  odim.quantity = "RATE";
81  odim.type = "S";
82  odim.setTypeDefaults();
83  odim.scaling.scale = 0.0001;
84  odim.scaling.offset = 0.0;
85  */
86 
87  // Later these...
88  // allowedEncoding.delink("gain");
89  /*
90  allowedEncoding.clear();
91  allowedEncoding.link("type", odim.type);
92  allowedEncoding.link("gain", odim.scaling.scale);
93  allowedEncoding.link("offset", odim.scaling.offset);
94  //allowedEncoding.link("freeze", odim.freeze);
95  allowedEncoding.link("type", odim.type, "S");
96  allowedEncoding.link("gain", odim.scaling.scale);
97  allowedEncoding.link("offset", odim.scaling.offset);
98  */
99 
100  /*
101  allowedEncoding.link("rscale", odim.rscale);
102  allowedEncoding.link("nrays", odim.geometry.height);
103  allowedEncoding.link("nbins", odim.geometry.width);
104  */
105 
106  };
107 
108 
109 
110 
111  virtual
112  inline
113  ~RainRateDPOp(){};
114 
115  virtual
116  void processDataSet(const DataSet<PolarSrc> & srcSweep, DataSet<PolarDst> & dstProduct) const;
117 
118  drain::Range<double> dbzRange;
119  drain::Range<double> kdpRange;
120  drain::Range<double> zdrRange;
121  double rhohv;
122 
123 protected:
124 
125  void computeFuzzyMembership(
126  const PlainData<PolarSrc> & srcData, const drain::Fuzzifier<double> & fuzzyFctor,
127  Data<PolarDst> & dstData) const;
128 
129  void computeProduct(
130  const PlainData<PolarSrc> & srcData, const drain::Fuzzifier<double> & fuzzyFctor,
131  const SingleParamPrecip & rateFnc, DataSet<PolarDst> & dstProduct) const;
132 
133  void computeProduct2(
134  const PlainData<PolarSrc> & srcData, const drain::Fuzzifier<double> & fuzzyFctor,
135  const PlainData<PolarSrc> & srcData2, const drain::Fuzzifier<double> & fuzzyFctor2,
136  const DoubleParamPrecip & rateFnc, DataSet<PolarDst> & dstProduct) const;
137 
138 
139 };
140 
141 
142 }
143 
144 #endif
145 
146 // Rack
A base class for fuzzy functions; also an unary functor.
Definition: Fuzzy.h:55
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: Precipitation.h:122
Essential class for storing radar data.
Definition: Data.h:302
Base class for flat (2D) products computed in the polar coordinate system. Volume is used as input.
Definition: PolarProductOp.h:61
Uses DBZ, ZDR and KDP to derive rain rate. Under construction.
Definition: RainRateDPOp.h:56
Definition: Precipitation.h:104
Namespace for images and image processing tools.
Definition: AccumulationArray.cpp:45
Definition: DataSelector.cpp:44