Skip to content
Snippets Groups Projects
Commit ae8a5bef authored by Lan Dam's avatar Lan Dam
Browse files

split reading ehet packet to 2 functions, one for log_data, the other for...

split reading ehet packet to 2 functions, one for log_data, the other for mass_pos_data and waveform_data
parent 698dfea6
No related branches found
No related tags found
1 merge request!100remove merge, index; retrieve gaps, overlap; plot gap;overlap with different color
Pipeline #2455 passed with stage
in 2 minutes and 46 seconds
......@@ -139,12 +139,12 @@ class RT130(DataTypeModel):
nbr_packet_type = dict(zip(unique, counts))
if b"SH" in nbr_packet_type:
self.get_soh_in_log_data(path2file)
self.read_sh_packet(path2file)
if b"EH" in nbr_packet_type or b"ET" in nbr_packet_type:
self.get_ehet_in_log_data_and_masspos_n_waveform_data(rt130)
self.read_eh_or_et_packet(rt130)
return True
def get_soh_in_log_data(self, path2file: Path) -> None:
def read_sh_packet(self, path2file: Path) -> None:
"""
Use soh_packet library to read file with SH packet for soh data
to append tuple (time, log string) to log_data[self.cur_key][SOH]
......@@ -163,27 +163,20 @@ class RT130(DataTypeModel):
self.log_data[cur_key]['SOH'] = []
self.log_data[cur_key]['SOH'].append((d['time'], logs))
def get_ehet_in_log_data_and_masspos_n_waveform_data(
self, rt130: core.Reftek130) -> None:
def read_eh_or_et_packet(self, rt130: core.Reftek130) -> None:
"""
Files that contents EH or ET packets are data stream files.
Name of file is name of data stream that retrieve from packets + 1.
To be consistent with filename, check data stream by the real value + 1
The data stream to be selected from GUI is also this value
There can be at most 1 - 9 data streams.
Files that contents EH or ET packets are data stream (DS and
mass position (DS 9) files.
Name of file is name of packets' DS + 1.
To be consistent with filename, check DS by the real value + 1
The DS to be selected from GUI is also this value.
There can be at most 1 - 9 DSs.
DSs that aren't selected will be excluded first.
This function will read Event header info to add to log_data['EHET'].
According to which DS is read, data will be aim for mass_pos_data or
waveform_data. Header will be read first to decide traces' available
indexes to read data so the file won't be looked deeply into if
time range isn't included in user's selection.
Then data will be retrieved for log_data, mass_pos_data and
waveform data.
:param rt130: of a data stream file in which
+ event info can be found in EH packet and save in
self.log_data['EHET']
+ mass position data can be found in data stream 9
+ waveform data can be found in data stream 1-8
:param rt130: RT130 object of a data stream file.
"""
if len(rt130._data) == 0:
return
......@@ -192,6 +185,21 @@ class RT130(DataTypeModel):
data_stream not in self.req_data_streams + [9]):
return
self.found_data_streams.append(data_stream)
# suppose all data in a reftek file have the same key
cur_key = (rt130._data[0]['unit_id'].decode(),
f"{rt130._data[0]['experiment_number']}")
self.populate_cur_key_for_all_data(cur_key)
self.get_ehet_in_log_data(rt130, cur_key)
self.get_mass_pos_data_and_waveform_data(rt130, data_stream, cur_key)
def get_ehet_in_log_data(self, rt130: core.Reftek130,
cur_key: Tuple[str, str]) -> None:
"""
Read event header info to add to log_data['EHET']
:param rt130: RT130 object
:param cur_key: current key of data set:
"""
ind_ehet = [ind for ind, val in
enumerate(rt130._data["packet_type"])
if val in [b"EH"]] # only need event header
......@@ -200,11 +208,6 @@ class RT130(DataTypeModel):
for ind in range(0, len(rt130._data))
if ind not in ind_ehet])
# suppose all data in a reftek file have the same key
cur_key = (rt130._data[0]['unit_id'].decode(),
f"{rt130._data[0]['experiment_number']}")
self.populate_cur_key_for_all_data(cur_key)
for index in ind_ehet:
d = rt130._data[index]
logs = packet.EHPacket(d).eh_et_info(nbr_dt_samples)
......@@ -212,6 +215,19 @@ class RT130(DataTypeModel):
self.log_data[cur_key]['EHET'] = []
self.log_data[cur_key]['EHET'].append((d['time'], logs))
def get_mass_pos_data_and_waveform_data(self, rt130: core.Reftek130,
data_stream: int,
cur_key: Tuple[str, str]) -> None:
"""
Get mass_pos_data for the current key in DS 9.
Get waveform_data for the current key in DS 1-8
Read header to find the available trace indexes to decide to read
deeply for real data.
:param rt130: RT130 object
:param data_stream: index of data stream (1-8)
:param cur_key: current key of data set
"""
if data_stream == 9:
cur_data_dict = self.mass_pos_data[cur_key]
else:
......
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