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
a392011d
Commit
a392011d
authored
9 years ago
by
Hal Simpson
Browse files
Options
Downloads
Patches
Plain Diff
moved dead_value processing into post_process, moved metadata out to factory, other minor cleanup.
parent
99dcde0b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
geomagio/imfv283/IMFV283Parser.py
+10
-20
10 additions, 20 deletions
geomagio/imfv283/IMFV283Parser.py
with
10 additions
and
20 deletions
geomagio/imfv283/IMFV283Parser.py
+
10
−
20
View file @
a392011d
...
@@ -56,11 +56,8 @@ class IMFV283Parser(object):
...
@@ -56,11 +56,8 @@ class IMFV283Parser(object):
We can change this to get smarter, but right now, there
'
s no need to.
We can change this to get smarter, but right now, there
'
s no need to.
"""
"""
def
__init__
(
self
,
observatoryMetadata
=
None
):
def
__init__
(
self
):
"""
Create a new IMFV283 parser.
"""
"""
Create a new IMFV283 parser.
"""
# dictionary of data (channel : numpy.array<float64>)
self
.
observatoryMetadata
=
observatoryMetadata
or
ObservatoryMetadata
()
# temporary storage for data being parsed
self
.
_parsedata
=
None
self
.
_parsedata
=
None
self
.
stream
=
obspy
.
core
.
Stream
()
self
.
stream
=
obspy
.
core
.
Stream
()
...
@@ -124,18 +121,6 @@ class IMFV283Parser(object):
...
@@ -124,18 +121,6 @@ class IMFV283Parser(object):
d4
=
0x100
*
data
[
bytecount
+
6
]
+
data
[
bytecount
+
7
]
d4
=
0x100
*
data
[
bytecount
+
6
]
+
data
[
bytecount
+
7
]
bytecount
+=
8
bytecount
+=
8
# take 2 byte int, scale and offset it then shift it to the
# correct value 10th nanotesla, and convert it to a nanotesla
# float.
if
d1
==
DEAD_VALUE
:
d1
=
numpy
.
nan
if
d2
==
DEAD_VALUE
:
d2
=
numpy
.
nan
if
d3
==
DEAD_VALUE
:
d3
=
numpy
.
nan
if
d4
==
DEAD_VALUE
:
d4
=
numpy
.
nan
parse_data
[
channels
[
0
]].
append
(
d1
)
parse_data
[
channels
[
0
]].
append
(
d1
)
parse_data
[
channels
[
1
]].
append
(
d2
)
parse_data
[
channels
[
1
]].
append
(
d2
)
parse_data
[
channels
[
2
]].
append
(
d3
)
parse_data
[
channels
[
2
]].
append
(
d3
)
...
@@ -297,15 +282,17 @@ class IMFV283Parser(object):
...
@@ -297,15 +282,17 @@ class IMFV283Parser(object):
orientation
=
goes_header
[
'
orient
'
]
orientation
=
goes_header
[
'
orient
'
]
for
channel
,
loc
in
zip
(
CHANNELS
[
orientation
],
xrange
(
0
,
4
)):
for
channel
,
loc
in
zip
(
CHANNELS
[
orientation
],
xrange
(
0
,
4
)):
stats
=
obspy
.
core
.
Stats
()
stats
=
obspy
.
core
.
Stats
()
stats
.
sampling_rate
=
0.0166666666667
stats
.
channel
=
channel
stats
.
channel
=
channel
stats
.
sampling_rate
=
0.0166666666667
stats
.
starttime
=
goes_time
stats
.
starttime
=
goes_time
stats
.
npts
=
12
stats
.
npts
=
12
stats
.
station
=
msg_header
[
'
obs
'
]
stats
.
station
=
msg_header
[
'
obs
'
]
self
.
observatoryMetadata
.
set_metadata
(
stats
,
msg_header
[
'
obs
'
],
channel
,
'
variation
'
,
'
minute
'
)
numpy_data
=
numpy
.
array
(
data
[
channel
],
dtype
=
numpy
.
float64
)
numpy_data
=
numpy
.
array
(
data
[
channel
],
dtype
=
numpy
.
float64
)
numpy_data
[
numpy_data
==
DEAD_VALUE
]
=
numpy
.
nan
numpy_data
[
numpy_data
==
DEAD_VALUE
]
=
numpy
.
nan
# Data values need to be scaled, offset and shifted into the
# correct 10th nanotesla value.
# For our convenience we convert to nanotesla values.
numpy_data
=
numpy
.
multiply
(
numpy_data
,
scale
[
loc
])
numpy_data
=
numpy
.
multiply
(
numpy_data
,
scale
[
loc
])
numpy_data
=
numpy
.
add
(
numpy_data
,
offset
[
loc
]
*
BIAS
-
SHIFT
)
numpy_data
=
numpy
.
add
(
numpy_data
,
offset
[
loc
]
*
BIAS
-
SHIFT
)
numpy_data
=
numpy
.
divide
(
numpy_data
,
10.0
)
numpy_data
=
numpy
.
divide
(
numpy_data
,
10.0
)
...
@@ -330,7 +317,10 @@ class IMFV283Parser(object):
...
@@ -330,7 +317,10 @@ class IMFV283Parser(object):
ness_byte
=
0
ness_byte
=
0
goes_byte
=
0
goes_byte
=
0
offset
=
self
.
_get_data_offset
(
data_len
)
if
data_len
==
MSG_SIZE_300B
:
offset
=
HEADER_SIZE
+
1
else
:
offset
=
HEADER_SIZE
for
cnt
in
xrange
(
0
,
63
):
for
cnt
in
xrange
(
0
,
63
):
# Convert 3 byte "pair" into ordinal values for manipulation.
# Convert 3 byte "pair" into ordinal values for manipulation.
...
...
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