Skip to content
Snippets Groups Projects
Commit 4bf37e06 authored by Kien Le's avatar Kien Le
Browse files

Fix plotting waveform data for RT130 data

parent 7d2a2899
No related branches found
No related tags found
1 merge request!139Change the way RT130 data is read for better performance
...@@ -76,7 +76,7 @@ def get_rt130_packet_header(rt130_packet: bytes, ...@@ -76,7 +76,7 @@ def get_rt130_packet_header(rt130_packet: bytes,
print_error('The given file does not appear to be a valid RT130 file.') print_error('The given file does not appear to be a valid RT130 file.')
raise RT130ParseError raise RT130ParseError
experiment_number = unpacker.unpack('b', rt130_packet[2:3])[0] experiment_number = int(rt130_packet[2:3].hex())
year = int(rt130_packet[3:4].hex()) year = int(rt130_packet[3:4].hex())
# A call to str.upper() is needed because bytes.hex() makes any # A call to str.upper() is needed because bytes.hex() makes any
# hexadecimal letter (i.e. ABCDEF) lowercase, while we want them to be # hexadecimal letter (i.e. ABCDEF) lowercase, while we want them to be
...@@ -95,9 +95,9 @@ def read_rt130_file(file_name: str, unpacker: Unpacker): ...@@ -95,9 +95,9 @@ def read_rt130_file(file_name: str, unpacker: Unpacker):
# RT130 data looks to be all big-endian (logpeek assumes this, and it has # RT130 data looks to be all big-endian (logpeek assumes this, and it has
# been working pretty well), so we don't have to do any endianness check. # been working pretty well), so we don't have to do any endianness check.
if os.path.getsize(file_name) % 1024: # if os.path.getsize(file_name) % 1024:
warnings.warn('The size of the data is not a multiple of 1024; it ' # warnings.warn('The size of the data is not a multiple of 1024; it '
'might be truncated.') # 'might be truncated.')
packets = [] packets = []
...@@ -199,7 +199,7 @@ class Reftek130(core.Reftek130): ...@@ -199,7 +199,7 @@ class Reftek130(core.Reftek130):
for packet in packets_in_file: for packet in packets_in_file:
converted_packets.append( converted_packets.append(
convert_packet_to_obspy_format(packet, rt130_unpacker)) convert_packet_to_obspy_format(packet, rt130_unpacker))
rt._data = numpy.array(converted_packets, PACKET_FINAL_DTYPE) rt._data = numpy.array(converted_packets, dtype=PACKET_FINAL_DTYPE)
return rt return rt
...@@ -207,5 +207,5 @@ waveform_file = '/Users/kle/PycharmProjects/sohstationviewer/tests/test_data/RT1 ...@@ -207,5 +207,5 @@ waveform_file = '/Users/kle/PycharmProjects/sohstationviewer/tests/test_data/RT1
soh_file = '/Users/kle/PycharmProjects/sohstationviewer/tests/test_data/RT130-sample/2017149.92EB/2017150/92EB/0/000000000_00000000' soh_file = '/Users/kle/PycharmProjects/sohstationviewer/tests/test_data/RT130-sample/2017149.92EB/2017150/92EB/0/000000000_00000000'
import time import time
start = time.perf_counter() start = time.perf_counter()
print((Reftek130.from_file(soh_file)._data)) print(repr(Reftek130.from_file(waveform_file)._data))
print('Time taken:', time.perf_counter() - start) # print('Time taken:', time.perf_counter() - start)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment