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

Plot masspos lines in log file

parent d9675c87
No related branches found
No related tags found
1 merge request!191Read log files generated by users
......@@ -2,9 +2,11 @@
RT130 object to hold and process RefTek data
"""
from pathlib import Path
from time import strptime
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
......@@ -77,6 +79,7 @@ class RT130(GeneralData):
if self.creator_thread.isInterruptionRequested():
raise ThreadStopped()
self.finalize_data()
print(self.mass_pos_data)
def finalize_data(self):
"""
......@@ -134,6 +137,33 @@ class RT130(GeneralData):
self.log_data[file_key]['SOH'].append(
(key_file_count, reader.soh_lines)
)
self.convert_mass_pos_log_lines_to_data(file_key, reader.masspos_lines)
def convert_mass_pos_log_lines_to_data(self, current_key, masspos_lines):
for masspos_num in range(1, 7):
masspos_string = f'MassPos{masspos_num}'
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([UTCDateTime.strptime(line[1] + '000', time_format).timestamp for line in current_lines])
if len(data) == 0:
continue
trace = {}
trace['startTmEpoch'] = times[0]
trace['endTmEpoch'] = times[-1]
trace['data'] = data
trace['times'] = times
if masspos_string not in self.mass_pos_data[current_key]:
self.mass_pos_data[current_key][masspos_string] = {'tracesInfo': [trace]}
self.mass_pos_data[current_key][masspos_string]['samplerate'] = 0
trace['startTmEpoch'] = times[0]
trace['endTmEpoch'] = times[-1]
else:
self.mass_pos_data[current_key][masspos_string]['tracesInfo'].append(trace)
trace['endTmEpoch'] = times[-1]
def read_folders(self) -> None:
"""
......
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