From d9f8decbd2b0424b0e0b1e028a6857427110e3d9 Mon Sep 17 00:00:00 2001 From: Since <ax20yhum@cip.cs.fau.de> Date: Sun, 19 Mar 2017 22:08:07 +0100 Subject: [PATCH] Allow various Z-R relationships --- conversion.go | 26 ++++++++++++++++++++------ conversion_test.go | 4 ++-- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/conversion.go b/conversion.go index ea0a541..1e63325 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 007c8ec..8f29d45 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 { -- GitLab