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

Documentation

parent cae0388c
No related branches found
No related tags found
1 merge request!33Add tests and refactor trim_downsample_WFChan
...@@ -585,8 +585,9 @@ def trim_waveform_data(wf_channel_data: Dict, start_time: float, ...@@ -585,8 +585,9 @@ def trim_waveform_data(wf_channel_data: Dict, start_time: float,
""" """
Trim off waveform traces whose times does not intersect the closed interval Trim off waveform traces whose times does not intersect the closed interval
[start_time, end_time]. [start_time, end_time].
:param wf_channel_data: dict - a dictionary that contains the waveform :param wf_channel_data: dict - a dictionary that contains the waveform
times and data of a channel. For its structure, refer to information of a channel. For its structure, refer to
DataTypeModel.waveformData[key]['readData'][chan_id]. DataTypeModel.waveformData[key]['readData'][chan_id].
:param start_time: the start of the time range to trim waveform data to. :param start_time: the start of the time range to trim waveform data to.
:param end_time: the end of the time range to trim waveform data to. :param end_time: the end of the time range to trim waveform data to.
...@@ -627,6 +628,17 @@ def trim_waveform_data(wf_channel_data: Dict, start_time: float, ...@@ -627,6 +628,17 @@ def trim_waveform_data(wf_channel_data: Dict, start_time: float,
def downsample_waveform_data(trimmed_traces_list: List[Dict], def downsample_waveform_data(trimmed_traces_list: List[Dict],
start_time: float, end_time: float start_time: float, end_time: float
) -> Tuple[List[np.ndarray], List[np.ndarray]]: ) -> Tuple[List[np.ndarray], List[np.ndarray]]:
"""
Downsample trimmed waveform data. Works on one trace at a time instead
of combining the traces before downsampling.
:param trimmed_traces_list: a list of traces that have been trimmed to
include only those that intersect the closed interval
[start_time, end_time]
:param start_time: the start of the time range
:param end_time: the end of the time range
:return: list of downsampled times array and list of downsampled data array
"""
# Calculate the number of requested_points # Calculate the number of requested_points
total_size = sum([tr['size'] for tr in trimmed_traces_list]) total_size = sum([tr['size'] for tr in trimmed_traces_list])
requested_points = 0 requested_points = 0
...@@ -663,8 +675,6 @@ def trim_downsample_WFChan(chan, startTm, endTm, firsttime): ...@@ -663,8 +675,6 @@ def trim_downsample_WFChan(chan, startTm, endTm, firsttime):
Different with soh_data where times and data are each in one np.array, Different with soh_data where times and data are each in one np.array,
in waveform_data, times and data are each kept in a list of np.memmap in waveform_data, times and data are each kept in a list of np.memmap
files along with startTmEpoch and endTmEpoch. files along with startTmEpoch and endTmEpoch.
chan['startIdx'] and chan['endIdx'] will be identify to exclude np.memmap
files that aren't in the zoom time range (startTm, endTm).
Data in np.memmap files will be trimmed again if there is still time Data in np.memmap files will be trimmed again if there is still time
outside the zoom time range then downsampled and combined to get the outside the zoom time range then downsampled and combined to get the
times and data with size closed to the expected const.CHAN_SIZE_LIMIT, times and data with size closed to the expected const.CHAN_SIZE_LIMIT,
......
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