Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
radolan
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jonny Schäfer
radolan
Commits
19990cc6
Commit
19990cc6
authored
8 years ago
by
Jonny Schäfer
Browse files
Options
Downloads
Patches
Plain Diff
Add Reflectivity function
parent
3badb514
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
conversion.go
+7
-1
7 additions, 1 deletion
conversion.go
conversion_test.go
+9
-4
9 additions, 4 deletions
conversion_test.go
with
16 additions
and
5 deletions
conversion.go
+
7
−
1
View file @
19990cc6
...
@@ -11,11 +11,17 @@ type DBZ float64
...
@@ -11,11 +11,17 @@ type DBZ float64
type
RVP6
float64
type
RVP6
float64
// PrecipitationRate returns the estimated precipitation rate in mm/h for the given
// PrecipitationRate returns the estimated precipitation rate in mm/h for the given
// reflectivity factor. The used Z-R relation is descibed in [6].
// reflectivity factor. The used Z-R relation is desc
r
ibed in [6].
func
(
z
DBZ
)
PrecipitationRate
()
float64
{
func
(
z
DBZ
)
PrecipitationRate
()
float64
{
return
math
.
Pow
(
math
.
Pow
(
10
,
float64
(
z
)
/
10
)
/
256
,
1
/
1.42
)
return
math
.
Pow
(
math
.
Pow
(
10
,
float64
(
z
)
/
10
)
/
256
,
1
/
1.42
)
}
}
// 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
)))
}
// ToDBZ converts the given radar video processor values (rvp-6) to radar reflectivity
// ToDBZ converts the given radar video processor values (rvp-6) to radar reflectivity
// factors in decibel relative to Z (dBZ).
// factors in decibel relative to Z (dBZ).
func
(
r
RVP6
)
ToDBZ
()
DBZ
{
func
(
r
RVP6
)
ToDBZ
()
DBZ
{
...
...
This diff is collapsed.
Click to expand it.
conversion_test.go
+
9
−
4
View file @
19990cc6
...
@@ -9,7 +9,7 @@ func TestConversion(t *testing.T) {
...
@@ -9,7 +9,7 @@ func TestConversion(t *testing.T) {
testcases
:=
[]
struct
{
testcases
:=
[]
struct
{
rvp
RVP6
rvp
RVP6
dbz
DBZ
dbz
DBZ
r
ate
float64
z
r
float64
}{
}{
{
0
,
-
32.5
,
0.0001
},
{
0
,
-
32.5
,
0.0001
},
{
65
,
0
,
0.0201
},
{
65
,
0
,
0.0201
},
...
@@ -19,7 +19,8 @@ func TestConversion(t *testing.T) {
...
@@ -19,7 +19,8 @@ func TestConversion(t *testing.T) {
for
_
,
test
:=
range
testcases
{
for
_
,
test
:=
range
testcases
{
dbz
:=
test
.
rvp
.
ToDBZ
()
dbz
:=
test
.
rvp
.
ToDBZ
()
rate
:=
dbz
.
PrecipitationRate
()
zr
:=
dbz
.
PrecipitationRate
()
rz
:=
Reflectivity
(
zr
)
rvp
:=
dbz
.
ToRVP6
()
rvp
:=
dbz
.
ToRVP6
()
if
dbz
!=
test
.
dbz
{
if
dbz
!=
test
.
dbz
{
...
@@ -28,8 +29,12 @@ func TestConversion(t *testing.T) {
...
@@ -28,8 +29,12 @@ func TestConversion(t *testing.T) {
if
rvp
!=
test
.
rvp
{
if
rvp
!=
test
.
rvp
{
t
.
Errorf
(
"RVP6(%f).ToDBZ().ToRVP6() = %f; expected: %f"
,
test
.
rvp
,
rvp
,
test
.
rvp
)
t
.
Errorf
(
"RVP6(%f).ToDBZ().ToRVP6() = %f; expected: %f"
,
test
.
rvp
,
rvp
,
test
.
rvp
)
}
}
if
math
.
Abs
(
test
.
rate
-
rate
)
>
0.0001
{
if
math
.
Abs
(
test
.
zr
-
zr
)
>
0.0001
{
t
.
Errorf
(
"RVP6(%f).ToDBZ().PrecipitationRate() = %f; expected: %f"
,
test
.
rvp
,
rate
,
test
.
rate
)
t
.
Errorf
(
"RVP6(%f).ToDBZ().PrecipitationRate() = %f; expected: %f"
,
test
.
rvp
,
zr
,
test
.
zr
)
}
if
math
.
Abs
(
float64
(
test
.
dbz
-
rz
))
>
0.0000001
{
t
.
Errorf
(
"Reflectivity(RVP6(%f).ToDBZ().PrecipitationRate()) = %f; expected: %f"
,
test
.
rvp
,
rz
,
test
.
dbz
)
}
}
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment