diff --git a/sohstationviewer/model/reftek_data/reftek.py b/sohstationviewer/model/reftek_data/reftek.py index 0bcddc848987de8a5af08afd13d7f74d774dccdd..3648ab192854a42ba90948f8a56c568e1b099afd 100755 --- a/sohstationviewer/model/reftek_data/reftek.py +++ b/sohstationviewer/model/reftek_data/reftek.py @@ -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 @@ -73,6 +75,7 @@ class RT130(GeneralData): if self.creator_thread.isInterruptionRequested(): raise ThreadStopped() self.finalize_data() + print(self.mass_pos_data) def finalize_data(self): """ @@ -130,6 +133,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: """