conversion.go 1.62 KB
Newer Older
Jonny Schäfer's avatar
Jonny Schäfer committed
1
2
3
4
5
6
7
8
9
10
11
12
package radolan

import (
	"math"
)

// Radar reflectivity factor Z in logarithmic representation dBZ: dBZ = 10 * log(Z)
type DBZ float64

// Raw radar video processor value.
type RVP6 float64

13
14
15
16
17
18
19
20
21
22
23
24
25
26
// 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
)

Jonny Schäfer's avatar
Jonny Schäfer committed
27
// PrecipitationRate returns the estimated precipitation rate in mm/h for the given
28
29
30
// 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)
Jonny Schäfer's avatar
Jonny Schäfer committed
31
32
}

Jonny Schäfer's avatar
Jonny Schäfer committed
33
// Reflectivity returns the estimated reflectivity factor for the given precipitation
34
35
36
// 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)))
Jonny Schäfer's avatar
Jonny Schäfer committed
37
38
}

Jonny Schäfer's avatar
Jonny Schäfer committed
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// ToDBZ converts the given radar video processor values (rvp-6) to radar reflectivity
// factors in decibel relative to Z (dBZ).
func (r RVP6) ToDBZ() DBZ {
	return DBZ(r/2.0 - 32.5)
}

// ToRVP6 converts the given radar reflectivity factors (dBZ) to radar video processor
// values (rvp-6).
func (z DBZ) ToRVP6() RVP6 {
	return RVP6((z + 32.5) * 2)
}

// rvp6Raw converts the raw value to radar video processor values (rvp-6) by applying the
// products precision field.
func (c *Composite) rvp6Raw(value int) RVP6 {
	return RVP6(float64(value) * math.Pow10(c.precision))
}