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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jonny Schäfer
radolan
Commits
8daceb4b
Commit
8daceb4b
authored
8 years ago
by
Jonny Schäfer
Browse files
Options
Downloads
Patches
Plain Diff
Add Interval field and parsing
parent
2d3702b0
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
header.go
+14
-0
14 additions, 0 deletions
header.go
header_test.go
+8
-0
8 additions, 0 deletions
header_test.go
radolan.go
+1
-0
1 addition, 0 deletions
radolan.go
with
23 additions
and
0 deletions
header.go
+
14
−
0
View file @
8daceb4b
...
@@ -76,6 +76,20 @@ func (c *Composite) parseHeader(reader *bufio.Reader) error {
...
@@ -76,6 +76,20 @@ func (c *Composite) parseHeader(reader *bufio.Reader) error {
c
.
ForecastTime
=
c
.
CaptureTime
.
Add
(
time
.
Duration
(
min
)
*
time
.
Minute
)
c
.
ForecastTime
=
c
.
CaptureTime
.
Add
(
time
.
Duration
(
min
)
*
time
.
Minute
)
}
}
// Parse Interval - Example "INT 5" or "INT1008"
if
intr
,
ok
:=
section
[
"INT"
];
ok
{
min
:=
0
if
_
,
err
:=
fmt
.
Sscanf
(
intr
,
"%d"
,
&
min
);
err
!=
nil
{
return
newError
(
"parseHeader"
,
"could not parse interval: "
+
err
.
Error
())
}
c
.
Interval
=
time
.
Duration
(
min
)
*
time
.
Minute
switch
c
.
Product
{
case
"W1"
,
"W2"
,
"W3"
,
"W4"
:
c
.
Interval
*=
10
}
}
// Parse Dimensions - Example: "GP 450x 450" or "BG460460" or "GP 1500x1400"
// Parse Dimensions - Example: "GP 450x 450" or "BG460460" or "GP 1500x1400"
dim
:=
section
[
"GP"
]
dim
:=
section
[
"GP"
]
if
bg
,
ok
:=
section
[
"BG"
];
ok
{
if
bg
,
ok
:=
section
[
"BG"
];
ok
{
...
...
This diff is collapsed.
Click to expand it.
header_test.go
+
8
−
0
View file @
8daceb4b
...
@@ -16,6 +16,7 @@ type headerTestcase struct {
...
@@ -16,6 +16,7 @@ type headerTestcase struct {
expProduct
string
expProduct
string
expCaptureTime
time
.
Time
expCaptureTime
time
.
Time
expForecastTime
time
.
Time
expForecastTime
time
.
Time
expInterval
time
.
Duration
expDx
int
expDx
int
expDy
int
expDy
int
expDataLength
int
expDataLength
int
...
@@ -65,6 +66,7 @@ func TestParseHeaderFZ(t *testing.T) {
...
@@ -65,6 +66,7 @@ func TestParseHeaderFZ(t *testing.T) {
ht
.
expProduct
=
"FZ"
ht
.
expProduct
=
"FZ"
ht
.
expCaptureTime
,
err1
=
time
.
Parse
(
time
.
RFC1123
,
"Thu, 28 Jul 2016 23:05:00 CEST"
)
ht
.
expCaptureTime
,
err1
=
time
.
Parse
(
time
.
RFC1123
,
"Thu, 28 Jul 2016 23:05:00 CEST"
)
ht
.
expForecastTime
,
err2
=
time
.
Parse
(
time
.
RFC1123
,
"Fri, 29 Jul 2016 00:45:00 CEST"
)
ht
.
expForecastTime
,
err2
=
time
.
Parse
(
time
.
RFC1123
,
"Fri, 29 Jul 2016 00:45:00 CEST"
)
ht
.
expInterval
=
5
*
time
.
Minute
ht
.
expDx
=
450
ht
.
expDx
=
450
ht
.
expDy
=
450
ht
.
expDy
=
450
ht
.
expDataLength
=
405160
-
154
// BY - header_etx_length
ht
.
expDataLength
=
405160
-
154
// BY - header_etx_length
...
@@ -106,6 +108,12 @@ func testParseHeader(t *testing.T, ht *headerTestcase) {
...
@@ -106,6 +108,12 @@ func testParseHeader(t *testing.T, ht *headerTestcase) {
dummy
.
ForecastTime
.
String
(),
ht
.
expForecastTime
.
String
())
dummy
.
ForecastTime
.
String
(),
ht
.
expForecastTime
.
String
())
}
}
// Interval
if
dummy
.
Interval
!=
ht
.
expInterval
{
t
.
Errorf
(
"%s.parseHeader(): Interval: %#v; expected: %#v"
,
ht
.
expProduct
,
dummy
.
Interval
.
String
(),
ht
.
expInterval
.
String
())
}
// Dx Dy
// Dx Dy
if
dummy
.
Dx
!=
ht
.
expDx
||
dummy
.
Dy
!=
ht
.
expDy
{
if
dummy
.
Dx
!=
ht
.
expDx
||
dummy
.
Dy
!=
ht
.
expDy
{
t
.
Errorf
(
"%s.parseHeader(): Dx: %d Dy: %d; expected Dx: %d Dy: %d"
,
ht
.
expProduct
,
t
.
Errorf
(
"%s.parseHeader(): Dx: %d Dy: %d; expected Dx: %d Dy: %d"
,
ht
.
expProduct
,
...
...
This diff is collapsed.
Click to expand it.
radolan.go
+
1
−
0
View file @
8daceb4b
...
@@ -62,6 +62,7 @@ type Composite struct {
...
@@ -62,6 +62,7 @@ type Composite struct {
CaptureTime
time
.
Time
CaptureTime
time
.
Time
ForecastTime
time
.
Time
ForecastTime
time
.
Time
Interval
time
.
Duration
Data
[][]
RVP6
// rvp-6 data for each point [y][x]
Data
[][]
RVP6
// rvp-6 data for each point [y][x]
...
...
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