conversion.go 1 KB
Newer Older
Jonny Schäfer's avatar
Jonny Schäfer committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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

// PrecipitationRate returns the estimated precipitation rate in mm/h for the given
// reflectivity factor. The used Z-R relation is descibed in [6].
func (z DBZ) PrecipitationRate() float64 {
	return math.Pow(math.Pow(10, float64(z)/10)/256, 1/1.42)
}

// 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))
}