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
!199
Write log file
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Write log file
feature-write_log_file
into
master
Overview
1
Commits
11
Pipelines
3
Changes
9
Merged
Kien Le
requested to merge
feature-write_log_file
into
master
1 year ago
Overview
1
Commits
11
Pipelines
3
Changes
1
Expand
#94 (closed)
👍
0
👎
0
Merge request reports
Viewing commit
26d09158
Prev
Next
Show latest version
1 file
+
3
−
3
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
26d09158
Moved software version constant to top
· 26d09158
Kien Le
authored
1 year ago
sohstationviewer/model/reftek_data/reftek.py
+
56
−
0
Options
"""
RT130 object to hold and process RefTek data
"""
import
datetime
from
pathlib
import
Path
from
typing
import
Union
,
List
,
Tuple
,
Dict
import
traceback
import
numpy
as
np
from
obspy
import
UTCDateTime
from
obspy.core
import
Stream
from
sohstationviewer.conf
import
constants
from
sohstationviewer.conf.constants
import
SOFTWARE_VERSION
from
sohstationviewer.model.reftek_data.reftek_reader.log_file_reader
import
(
LogFileReader
,
process_mass_poss_line
,
)
@@ -26,6 +29,24 @@ from sohstationviewer.model.reftek_data.reftek_reader import core, soh_packet
from
sohstationviewer.model.reftek_data.log_info
import
LogInfo
def
format_timestamp_as_mass_pos_time
(
timestamp
:
float
)
->
str
:
"""
Format a UTC timestamp in the format of a mass-position time in SOH
messages.
:param timestamp: the UTC timestamp to format
:return: the formatted time string
"""
# We trim the last three character because the %f format character has a
# millisecond precision (6 characters), while the time format we use only
# has a microsecond precision (3 characters).
return
UTCDateTime
(
timestamp
).
strftime
(
'
%Y:%j:%H:%M:%S.%f
'
)[:
-
3
]
format_timestamp_as_mass_pos_time
=
np
.
vectorize
(
format_timestamp_as_mass_pos_time
,
otypes
=
[
str
]
)
class
RT130
(
GeneralData
):
"""
read and process reftek file into object with properties can be used to
@@ -114,6 +135,41 @@ class RT130(GeneralData):
# this happens when there is text or ascii only in the data
self
.
data_time
[
key
]
=
[
self
.
read_start
,
self
.
read_end
]
for
key
in
self
.
log_data
:
if
key
==
'
TEXT
'
:
continue
soh_header
=
''
soh_footer
=
''
soh_messages
=
self
.
log_data
[
key
][
'
SOH
'
]
# We want to include a log file header only when there is not
# already one.
possible_programs
=
[
'
logpeek
'
,
'
SOHStationViewer
'
,
'
rt2ms
'
]
message_has_header
=
any
(
soh_messages
[
0
].
startswith
(
program
)
for
program
in
possible_programs
)
if
not
message_has_header
:
current_time
=
datetime
.
datetime
.
now
().
ctime
()
soh_header
=
(
f
'
SOHStationViewer: v
{
SOFTWARE_VERSION
}
'
f
'
Run time (UTC):
{
current_time
}
\n
'
)
if
self
.
include_masspos_in_soh_messages
:
soh_footer
+=
'
\n\n
Mass-positions:
\n
'
mass_pos_lines
=
[]
soh_messages
=
self
.
log_data
[
key
][
'
SOH
'
]
for
chan
in
self
.
mass_pos_data
[
key
]:
chan_data
=
self
.
mass_pos_data
[
key
][
chan
]
# We combined all data into one trace above
trace
=
chan_data
[
'
tracesInfo
'
][
0
]
times
=
format_timestamp_as_mass_pos_time
(
trace
[
'
times
'
])
data
=
trace
[
'
data
'
].
astype
(
times
.
dtype
)
formatted_lines
=
[
f
'
LPMP
{
time
}
{
chan
[
-
1
]
}
{
mass_position
}
'
for
(
time
,
mass_position
)
in
zip
(
times
,
data
)
]
mass_pos_lines
.
extend
(
formatted_lines
)
soh_footer
+=
'
\n
'
.
join
(
mass_pos_lines
)
soh_messages
[
0
]
=
soh_header
+
soh_messages
[
0
]
+
soh_footer
def
read_log_files
(
self
):
"""
Read data from self.rt130_log_files and store it in self.log_data
Loading