Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SOHViewer
Manage
Activity
Members
Labels
Plan
Issues
11
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
3
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
30437627
Commit
30437627
authored
2 months ago
by
Kien Le
Browse files
Options
Downloads
Patches
Plain Diff
Read all data points based on database
parent
74e96200
No related branches found
No related tags found
No related merge requests found
Pipeline
#4297
failed with stage
Stage: Build Env and Test
in 3 minutes and 51 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
sohstationviewer/model/mseed_data/mseed.py
+19
-1
19 additions, 1 deletion
sohstationviewer/model/mseed_data/mseed.py
sohstationviewer/model/mseed_data/mseed_reader.py
+28
-9
28 additions, 9 deletions
sohstationviewer/model/mseed_data/mseed_reader.py
with
47 additions
and
10 deletions
sohstationviewer/model/mseed_data/mseed.py
+
19
−
1
View file @
30437627
...
@@ -6,6 +6,7 @@ import re
...
@@ -6,6 +6,7 @@ import re
from
pathlib
import
Path
from
pathlib
import
Path
from
typing
import
Dict
,
List
from
typing
import
Dict
,
List
from
sohstationviewer.database.process_db
import
execute_db_dict
from
sohstationviewer.view.util.enums
import
LogType
from
sohstationviewer.view.util.enums
import
LogType
from
sohstationviewer.model.general_data.general_data
import
GeneralData
from
sohstationviewer.model.general_data.general_data
import
GeneralData
...
@@ -29,6 +30,20 @@ class MSeed(GeneralData):
...
@@ -29,6 +30,20 @@ class MSeed(GeneralData):
self
.
nets_by_sta
:
Dict
[
str
,
List
[
str
]]
=
{}
self
.
nets_by_sta
:
Dict
[
str
,
List
[
str
]]
=
{}
self
.
invalid_blockettes
=
False
self
.
invalid_blockettes
=
False
self
.
not_mseed_files
=
[]
self
.
not_mseed_files
=
[]
# Get whether a channel should have all its data points read.
channels_sql
=
(
f
"
SELECT channel, readAllPoints
"
f
"
FROM Channels
"
f
"
WHERE dataType=
'
{
self
.
data_type
}
'"
)
channels_db_info
=
execute_db_dict
(
channels_sql
)
self
.
channels_db_info
=
{
channel_info
[
'
channel
'
]:
int
(
channel_info
[
'
readAllPoints
'
])
for
channel_info
in
channels_db_info
}
# We never want to read all data points in waveform channels, so we
# remove it preemptively.
self
.
channels_db_info
.
pop
(
'
SEISMIC
'
,
None
)
self
.
processing_data
()
self
.
processing_data
()
def
finalize_data
(
self
):
def
finalize_data
(
self
):
...
@@ -86,7 +101,10 @@ class MSeed(GeneralData):
...
@@ -86,7 +101,10 @@ class MSeed(GeneralData):
mass_pos_data
=
self
.
mass_pos_data
,
mass_pos_data
=
self
.
mass_pos_data
,
waveform_data
=
self
.
waveform_data
,
waveform_data
=
self
.
waveform_data
,
log_data
=
self
.
log_data
,
log_data
=
self
.
log_data
,
gap_minimum
=
self
.
gap_minimum
)
gap_minimum
=
self
.
gap_minimum
,
channels_db_info
=
self
.
channels_db_info
,
data_type
=
self
.
data_type
,
)
try
:
try
:
reader
.
read
()
reader
.
read
()
self
.
invalid_blockettes
=
(
self
.
invalid_blockettes
self
.
invalid_blockettes
=
(
self
.
invalid_blockettes
...
...
This diff is collapsed.
Click to expand it.
sohstationviewer/model/mseed_data/mseed_reader.py
+
28
−
9
View file @
30437627
...
@@ -5,6 +5,8 @@ from pathlib import Path
...
@@ -5,6 +5,8 @@ from pathlib import Path
import
numpy
import
numpy
from
obspy
import
UTCDateTime
from
obspy
import
UTCDateTime
from
sohstationviewer.database.extract_data
import
\
convert_actual_channel_to_db_channel_w_question_mark
from
sohstationviewer.model.mseed_data.record_reader
import
RecordReader
from
sohstationviewer.model.mseed_data.record_reader
import
RecordReader
from
sohstationviewer.model.mseed_data.record_reader_helper
import
\
from
sohstationviewer.model.mseed_data.record_reader_helper
import
\
RecordMetadata
RecordMetadata
...
@@ -48,7 +50,9 @@ class MSeedReader:
...
@@ -48,7 +50,9 @@ class MSeedReader:
mass_pos_data
:
Dict
=
{},
mass_pos_data
:
Dict
=
{},
waveform_data
:
Dict
=
{},
waveform_data
:
Dict
=
{},
log_data
:
LogData
=
{},
log_data
:
LogData
=
{},
gap_minimum
:
Optional
[
float
]
=
None
gap_minimum
:
Optional
[
float
]
=
None
,
channels_db_info
:
Dict
=
None
,
data_type
:
str
=
None
,
)
->
None
:
)
->
None
:
"""
"""
The object of the class is to read data from given file to add
The object of the class is to read data from given file to add
...
@@ -74,6 +78,9 @@ class MSeedReader:
...
@@ -74,6 +78,9 @@ class MSeedReader:
:param log_data: data dict of log_data
:param log_data: data dict of log_data
:param gap_minimum: minimum length of gaps required to detect
:param gap_minimum: minimum length of gaps required to detect
from record
from record
:param channels_db_info: dict containing the needed information about
each channel. Only includes whether to read all data points from
a channel currently.
"""
"""
self
.
read_start
=
read_start
self
.
read_start
=
read_start
self
.
read_end
=
read_end
self
.
read_end
=
read_end
...
@@ -89,6 +96,8 @@ class MSeedReader:
...
@@ -89,6 +96,8 @@ class MSeedReader:
self
.
log_data
=
log_data
self
.
log_data
=
log_data
self
.
file_path
=
file_path
self
.
file_path
=
file_path
self
.
file
:
BinaryIO
=
open
(
file_path
,
'
rb
'
)
self
.
file
:
BinaryIO
=
open
(
file_path
,
'
rb
'
)
self
.
channels_db_info
=
channels_db_info
self
.
data_type
=
data_type
self
.
invalid_blockettes
=
False
,
self
.
invalid_blockettes
=
False
,
...
@@ -319,18 +328,24 @@ class MSeedReader:
...
@@ -319,18 +328,24 @@ class MSeedReader:
continue
continue
else
:
else
:
break
break
if
data_dict
is
self
.
waveform_data
:
data_points
=
list
(
record
.
get_two_data_points
())
# Some channels are represented differently in the database, so we
times
=
[
record
.
record_metadata
.
start_time
,
# need to convert them to that representation. One such example is
record
.
record_metadata
.
end_time
]
# VM1 for Centaur, which is represented by VM? in the database.
else
:
# Waveform channels also work like this, but because we never want
# to read all the data points in a waveform channel, we ignore them
# in this conversion.
db_channel
=
convert_actual_channel_to_db_channel_w_question_mark
(
record
.
record_metadata
.
channel
,
self
.
data_type
)
if
self
.
channels_db_info
.
get
(
db_channel
):
try
:
try
:
data_points
=
record
.
get_data_points
()
data_points
=
record
.
get_data_points
()
sample_interval
=
1
/
record
.
record_metadata
.
sample_rate
sample_interval
=
1
/
record
.
record_metadata
.
sample_rate
times
=
numpy
.
arange
(
times
=
numpy
.
arange
(
record
.
record_metadata
.
start_time
,
record
.
record_metadata
.
start_time
,
record
.
record_metadata
.
end_time
,
record
.
record_metadata
.
end_time
,
sample_interval
).
tolist
()
sample_interval
).
tolist
()
# The previous calculation will always miss one time point
# The previous calculation will always miss one time point
# at the end. We can adjust the stop argument to capture
# at the end. We can adjust the stop argument to capture
# that point in one calculation, but the code for that is a
# that point in one calculation, but the code for that is a
...
@@ -340,6 +355,10 @@ class MSeedReader:
...
@@ -340,6 +355,10 @@ class MSeedReader:
except
ZeroDivisionError
:
except
ZeroDivisionError
:
data_points
=
None
data_points
=
None
times
=
None
times
=
None
else
:
data_points
=
list
(
record
.
get_two_data_points
())
times
=
[
record
.
record_metadata
.
start_time
,
record
.
record_metadata
.
end_time
]
self
.
append_data
(
data_dict
,
record
,
data_points
,
times
)
self
.
append_data
(
data_dict
,
record
,
data_points
,
times
)
self
.
append_log
(
record
)
self
.
append_log
(
record
)
...
...
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