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

Refactor downsample_waveform_chan

Make downsample_waveform_chan return the downsampled list of times and
data instead of saving this information to the waveform channel data
dictionary. This makes the function comply with SRP.
parent 45a79030
No related branches found
No related tags found
1 merge request!33Add tests and refactor trim_downsample_WFChan
......@@ -627,7 +627,8 @@ def trim_waveform_data(wf_channel_data: Dict, start_time: float,
def downsample_waveform_chan(wf_channel_data: Dict,
trimmed_traces_list: List[Dict],
start_time: float, end_time: float,
first_time: bool) -> None:
first_time: bool
) -> Tuple[List[np.ndarray], List[np.ndarray]]:
# Calculate the number of requested_points
total_size = sum([tr['size'] for tr in trimmed_traces_list])
requested_points = 0
......@@ -639,8 +640,8 @@ def downsample_waveform_chan(wf_channel_data: Dict,
wf_channel_data['fulldata'] = True
# Downsample the data
wf_channel_data['times'] = []
wf_channel_data['data'] = []
downsampled_times_list = []
downsampled_data_list = []
for trIdx, tr in enumerate(trimmed_traces_list):
times = np.memmap(tr['times_f'],
dtype='int64', mode='r',
......@@ -653,11 +654,10 @@ def downsample_waveform_chan(wf_channel_data: Dict,
data = data[indexes]
if requested_points != 0:
times, data = downsample(times, data, requested_points)
wf_channel_data['times'].append(times)
wf_channel_data['data'].append(data)
downsampled_times_list.append(times)
downsampled_data_list.append(data)
wf_channel_data['times'] = np.hstack(wf_channel_data['times'])
wf_channel_data['data'] = np.hstack(wf_channel_data['data'])
return downsampled_times_list, downsampled_data_list
def trim_downsample_WFChan(chan, startTm, endTm, firsttime):
......
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