Skip to content
Snippets Groups Projects

Add support for Q8 datalogger

Merged Kien Le requested to merge feature-#290-add_Q8_support into build-2025.1.0.0
1 file
+ 34
2
Compare changes
  • Side-by-side
  • Inline
@@ -15,6 +15,7 @@ from PySide6.QtWidgets import QTextBrowser, QApplication
@@ -15,6 +15,7 @@ from PySide6.QtWidgets import QTextBrowser, QApplication
from obspy.io import reftek
from obspy.io import reftek
from obspy import UTCDateTime
from obspy import UTCDateTime
 
from sohstationviewer.conf.dbSettings import dbConf
from sohstationviewer.model.mseed_data.mseed_reader import \
from sohstationviewer.model.mseed_data.mseed_reader import \
move_to_next_record
move_to_next_record
@@ -250,9 +251,23 @@ def get_data_type_from_file(path2file: Path,
@@ -250,9 +251,23 @@ def get_data_type_from_file(path2file: Path,
"""
"""
file = open(path2file, 'rb')
file = open(path2file, 'rb')
chans_in_stream = set()
chans_in_stream = set()
possible_data_types = set()
possible_data_types = set()
 
# Handle waveform files, which give no information about the possible data
 
# type. The standard in the industry at the moment of writing is to only
 
# multiplex SOH channels if at all, so we only need to check the first
 
# channel in a file to determine if it is a waveform file.
 
try:
 
chan = get_next_channel_from_mseed_file(file)
 
if dbConf['seisRE'].match(chan):
 
return None
 
file.seek(0)
 
except ValueError:
 
file.close()
 
if reftek.core._is_reftek130(path2file):
 
return {'RT130'}, False
 
return None
 
while 1:
while 1:
is_eof = (file.read(1) == b'')
is_eof = (file.read(1) == b'')
if is_eof:
if is_eof:
@@ -267,6 +282,15 @@ def get_data_type_from_file(path2file: Path,
@@ -267,6 +282,15 @@ def get_data_type_from_file(path2file: Path,
return {'RT130'}, False
return {'RT130'}, False
return None
return None
 
# Handle mass-position channels, which give no information about the
 
# possible data type. Mass-position channels are considered SOH
 
# channels, so they can be multiplexed with other SOH channels in the
 
# same file. As a result, unlike the waveform channels, we can't deal
 
# with them at the file level.
 
if chan.startswith('VM'):
 
chans_in_stream.add(chan)
 
continue
 
if chan in chans_in_stream:
if chan in chans_in_stream:
continue
continue
@@ -280,8 +304,16 @@ def get_data_type_from_file(path2file: Path,
@@ -280,8 +304,16 @@ def get_data_type_from_file(path2file: Path,
possible_data_types |= all_channels_dict[chan]
possible_data_types |= all_channels_dict[chan]
file.close()
file.close()
 
 
# Handle case where mass-position channels are not multiplexed with other
 
# SOH channels. We have to do this because mass-position-only files give
 
# an empty set for the possible data types, which means that any data sets
 
# with these files will be processed as having no data type.
 
if all(chan.startswith('VM') for chan in chans_in_stream):
 
return None
 
is_multiplex = is_multiplex or (len(chans_in_stream) > 1)
is_multiplex = is_multiplex or (len(chans_in_stream) > 1)
return frozenset(possible_data_types), is_multiplex
return possible_data_types, is_multiplex
def get_next_channel_from_mseed_file(mseed_file: BinaryIO) -> str:
def get_next_channel_from_mseed_file(mseed_file: BinaryIO) -> str:
Loading