diff --git a/conversion.go b/conversion.go index ea0a541f735f272db2c01bddeec8b0f43e9410ad..1e63325a62cec0d9652db1e9118853a4ecbe58ca 100644 --- a/conversion.go +++ b/conversion.go @@ -10,16 +10,30 @@ type DBZ float64 // Raw radar video processor value. type RVP6 float64 +// Z-R relationship mathematically expressed as Z = a * R^b +type ZR struct { + A float64 + B float64 +} + +// Common Z-R relationships +var ( + Aniol80 = ZR{256, 1.42} // operational use in germany, described in [6] + Doelling98 = ZR{316, 1.50} // operational use in switzerland + JossWaldvogel70 = ZR{300, 1.50} + MarshallPalmer55 = ZR{200, 1.60} // operational use in austria +) + // PrecipitationRate returns the estimated precipitation rate in mm/h for the given -// reflectivity factor. The used Z-R relation is described in [6]. -func (z DBZ) PrecipitationRate() float64 { - return math.Pow(math.Pow(10, float64(z)/10)/256, 1/1.42) +// reflectivity factor and Z-R relationship. +func (z DBZ) PrecipitationRate(relation ZR) float64 { + return math.Pow(math.Pow(10, float64(z)/10)/relation.A, 1/relation.B) } // Reflectivity returns the estimated reflectivity factor for the given precipitation -// rate (mm/h). The used Z-R relation is described in [6]. -func Reflectivity(rate float64) DBZ { - return DBZ(10 * math.Log10(256*math.Pow(rate, 1.42))) +// rate (mm/h) and Z-R relationship. +func Reflectivity(rate float64, relation ZR) DBZ { + return DBZ(10 * math.Log10(relation.A*math.Pow(rate, relation.B))) } // ToDBZ converts the given radar video processor values (rvp-6) to radar reflectivity diff --git a/conversion_test.go b/conversion_test.go index 007c8ecd46d9009b199a3d523f0002481089fc94..8f29d4505385fd744527f4821334e4c301fa2a98 100644 --- a/conversion_test.go +++ b/conversion_test.go @@ -19,8 +19,8 @@ func TestConversion(t *testing.T) { for _, test := range testcases { dbz := test.rvp.ToDBZ() - zr := dbz.PrecipitationRate() - rz := Reflectivity(zr) + zr := dbz.PrecipitationRate(Aniol80) + rz := Reflectivity(zr, Aniol80) rvp := dbz.ToRVP6() if dbz != test.dbz {