Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
geomag-algorithms
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ghsc
National Geomagnetism Program
geomag-algorithms
Commits
717ae201
Commit
717ae201
authored
9 years ago
by
Eddie McWhirter
Browse files
Options
Downloads
Patches
Plain Diff
Add channel into parser and use 'station' instead of 'observatory'.
parent
69a0df4a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
geomagio/pcdcp/PCDCPParser.py
+23
-7
23 additions, 7 deletions
geomagio/pcdcp/PCDCPParser.py
with
23 additions
and
7 deletions
geomagio/pcdcp/PCDCPParser.py
+
23
−
7
View file @
717ae201
...
...
@@ -16,6 +16,8 @@ class PCDCPParser(object):
----------
header : dict
parsed PCDCP header.
channels : array
parsed channel names.
times : array
parsed timeseries times.
data : dict
...
...
@@ -28,6 +30,8 @@ class PCDCPParser(object):
"""
Create a new PCDCP parser.
"""
# header fields
self
.
header
=
{}
# array of channel names
self
.
channels
=
[]
# timestamps of data (datetime.datetime)
self
.
times
=
[]
# dictionary of data (channel : numpy.array<float64>)
...
...
@@ -43,6 +47,8 @@ class PCDCPParser(object):
data : str
PCDCP formatted file contents.
"""
self
.
_set_channels
()
parsing_header
=
True
lines
=
data
.
splitlines
()
for
line
in
lines
:
...
...
@@ -59,13 +65,11 @@ class PCDCPParser(object):
Adds value to ``self.header``.
"""
self
.
header
[
'
header
'
]
=
line
self
.
header
[
'
observatory
'
]
=
line
[
0
:
3
]
self
.
header
[
'
station
'
]
=
line
[
0
:
3
]
self
.
header
[
'
year
'
]
=
line
[
5
:
10
]
self
.
header
[
'
yearday
'
]
=
line
[
11
:
14
]
self
.
header
[
'
date
'
]
=
line
[
16
:
25
]
self
.
_parsedata
=
([],
[],
[],
[],
[])
return
def
_parse_data
(
self
,
line
):
...
...
@@ -89,11 +93,23 @@ class PCDCPParser(object):
Replaces empty values with ``numpy.nan``.
"""
self
.
times
=
self
.
_parsedata
[
0
]
i
=
0
for
data
in
zip
(
self
.
_parsedata
[
1
:]):
for
channel
,
data
in
zip
(
self
.
channels
,
self
.
_parsedata
[
1
:]):
data
=
numpy
.
array
(
data
,
dtype
=
numpy
.
float64
)
# filter empty values
data
[
data
==
NINES
]
=
numpy
.
nan
self
.
data
[
i
]
=
data
i
+=
1
data
=
numpy
.
divide
(
data
,
100
)
self
.
data
[
channel
]
=
data
self
.
_parsedata
=
None
def
_set_channels
(
self
):
"""
Adds channel names to ``self.channels``.
Creates empty values arrays in ``self.data``.
"""
self
.
channels
.
append
(
'
H
'
)
self
.
channels
.
append
(
'
E
'
)
self
.
channels
.
append
(
'
Z
'
)
self
.
channels
.
append
(
'
F
'
)
self
.
_parsedata
=
([],
[],
[],
[],
[])
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