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
Merge requests
!191
Read log files generated by users
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Read log files generated by users
feature-#94-read_log_files
into
master
Overview
11
Commits
36
Pipelines
8
Changes
6
Merged
Kien Le
requested to merge
feature-#94-read_log_files
into
master
1 year ago
Overview
11
Commits
36
Pipelines
8
Changes
2
Expand
Let the program reads file generated by rt2ms, logpeek, or itself.
#94 (closed)
Edited
1 year ago
by
Kien Le
👍
0
👎
0
Merge request reports
Viewing commit
b99f9f9d
Prev
Next
Show latest version
2 files
+
37
−
13
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
b99f9f9d
Refactored mass-position log processing
· b99f9f9d
Kien Le
authored
1 year ago
sohstationviewer/model/reftek_data/reftek_reader/log_file_reader.py
+
31
−
0
Options
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
Loading