def _postprocess_contours(self, index, times, freqs, salience):
"""Remove contours that are too short.
Parameters
----------
index : np.array
array of contour numbers
times : np.array
array of contour times
freqs : np.array
array of contour frequencies
salience : np.array
array of contour salience values
Returns
-------
index_pruned : np.array
Pruned array of contour numbers
times_pruned : np.array
Pruned array of contour times
freqs_pruned : np.array
Pruned array of contour frequencies
salience_pruned : np.array
Pruned array of contour salience values
"""
keep_index = np.ones(times.shape).astype(bool)
for i in set(index):
this_idx = (index == i)
if np.ptp(times[this_idx]) <= self.min_contour_len:
keep_index[this_idx] = False
return (index[keep_index], times[keep_index],
freqs[keep_index], salience[keep_index])
评论列表
文章目录