Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SOHViewer
Manage
Activity
Members
Labels
Plan
Issues
14
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
5
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Software Public
PASSOFT
SOHViewer
Commits
47ae466b
Commit
47ae466b
authored
1 year ago
by
Kien Le
Browse files
Options
Downloads
Patches
Plain Diff
Refactored mass-position log processing
parent
488c49d0
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
sohstationviewer/model/reftek_data/reftek.py
+6
-13
6 additions, 13 deletions
sohstationviewer/model/reftek_data/reftek.py
sohstationviewer/model/reftek_data/reftek_reader/log_file_reader.py
+31
-0
31 additions, 0 deletions
...viewer/model/reftek_data/reftek_reader/log_file_reader.py
with
37 additions
and
13 deletions
sohstationviewer/model/reftek_data/reftek.py
+
6
−
13
View file @
47ae466b
...
...
@@ -10,7 +10,9 @@ from obspy.core import Stream
from
sohstationviewer.conf
import
constants
from
sohstationviewer.model.reftek_data.reftek_reader.log_file_reader
import
\
LogFileReader
(
LogFileReader
,
process_mass_poss_line
,
)
from
sohstationviewer.view.util.enums
import
LogType
from
sohstationviewer.model.general_data.general_data
import
\
...
...
@@ -151,20 +153,11 @@ class RT130(GeneralData):
:param masspos_lines: the mass-position lines to process
"""
# Mass-position channels is suffixed by a number from 1 to 6.
for
masspos_num
in
range
(
1
,
7
):
masspos_chan
=
f
'
MassPos
{
masspos_num
}
'
current_lines
=
[
line
.
split
()
for
line
in
masspos_lines
if
int
(
line
.
split
()[
2
])
==
masspos_num
]
data
=
np
.
asarray
([
line
[
3
]
for
line
in
current_lines
],
dtype
=
float
)
time_format
=
'
%Y:%j:%H:%M:%S.%f
'
times
=
np
.
array
(
[
UTCDateTime
.
strptime
(
line
[
1
]
+
'
000
'
,
time_format
).
timestamp
for
line
in
current_lines
]
)
processed_masspos_data
=
process_mass_poss_line
(
masspos_lines
)
for
i
,
(
times
,
data
)
in
enumerate
(
processed_masspos_data
):
if
len
(
data
)
==
0
:
continue
masspos_chan
=
f
'
MassPos
{
i
}
'
trace
=
{
'
startTmEpoch
'
:
times
[
0
],
'
endTmEpoch
'
:
times
[
-
1
],
'
data
'
:
data
,
'
times
'
:
times
}
if
masspos_chan
not
in
self
.
mass_pos_data
[
key
]:
...
...
This diff is collapsed.
Click to expand it.
sohstationviewer/model/reftek_data/reftek_reader/log_file_reader.py
+
31
−
0
View file @
47ae466b
from
pathlib
import
Path
from
typing
import
List
,
Literal
,
Optional
,
Dict
,
Callable
,
Tuple
import
numpy
as
np
from
obspy
import
UTCDateTime
LogFileFormat
=
Literal
[
'
rt2ms
'
,
'
logpeek
'
,
'
sohstationviewer
'
]
# These packets can be found in section 4 of the RT130 record documentation.
RT130_PACKETS
=
[
'
SH
'
,
'
SC
'
,
'
OM
'
,
'
DS
'
,
'
AD
'
,
'
CD
'
,
'
FD
'
,
'
EH
'
,
'
ET
'
]
...
...
@@ -256,3 +259,31 @@ class LogFileReader:
# separate the SOH lines blocks during processing.
self
.
soh_lines
.
append
(
'
\n
'
)
self
.
masspos_lines
.
extend
(
masspos_lines
)
def
process_mass_poss_line
(
masspos_lines
:
List
[
str
]
)
->
List
[
Tuple
[
np
.
ndarray
,
np
.
ndarray
]]:
"""
Process a list of mass-position lines into a list of mass-position data,
sorted by the channel suffix
:param masspos_lines: a list of mass-position log lines
:return: a list of mass-position data, sorted by the channel suffix
"""
# There can be 6 mass-position channels.
mass_pos_data
=
[]
for
masspos_num
in
range
(
6
):
current_lines
=
[
line
.
split
()
for
line
in
masspos_lines
if
int
(
line
.
split
()[
2
])
==
masspos_num
]
data
=
np
.
asarray
([
line
[
3
]
for
line
in
current_lines
],
dtype
=
float
)
time_format
=
'
%Y:%j:%H:%M:%S.%f
'
times
=
np
.
array
(
# strptime requires the microsecond component to have 6 digits, but
# a mass-position log lines only have 3 digits for microsecond. So,
# we have to pad the time with 0s.
[
UTCDateTime
.
strptime
(
line
[
1
]
+
'
000
'
,
time_format
).
timestamp
for
line
in
current_lines
]
)
mass_pos_data
.
append
((
times
,
data
))
return
mass_pos_data
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