def extract_new_detections_(
cc_sums,
moveout_array,
n_mad=10.,
template_duration=8.,
step=1,
extracted_duration=60.):
n_templates = cc_sums.shape[0]
n_stations = moveout_array.shape[1]
n_components = moveout_array.shape[2]
n_extracted_samples = np.int32(extracted_duration * 100)
buffer_extracted_events = 10.
list_metadata = []
list_waveforms = []
for i in range(n_templates):
cc_sum = cc_sums[i, :]
cc_sum -= np.median(cc_sum)
threshold = n_mad * np.median(np.abs(cc_sum))
# ------------------
cc_idx = np.argwhere(cc_sum > threshold)
detections = cc_idx * step
# only keep highest correlation coefficient for grouped detections
# we assume the last component is the vertical component
d_mv = moveout_array[i, :, 0] - moveout_array[i, :, -1]
# fix the maximum window size to 3 times the template duration
# fix the minimum window size to 1 time the templare duration
# in between: choose an adaptive size based on the median
# P-S time
search_win = min(np.int32(3. * template_duration *
100 / step),
max(np.int32(1. * np.median(d_mv[d_mv != 0]) / step),
np.int32(template_duration *
100 / step)))
for j in range(cc_idx.size):
idx = np.arange(max(0, cc_idx[j] - search_win // 2),
min(cc_sum.size-1, cc_idx[j] + search_win // 2),
dtype=np.int32)
idx_to_update = np.where(cc_idx == cc_idx[j])[0]
cc_idx[idx_to_update] = np.argmax(cc_sum[idx]) + idx[0]
cc_idx = np.unique(cc_idx)
detections = cc_idx * step
# after this step, we can have detections closest than search_win / 2
cc_idx = list(cc_idx)
n_removed = 0
for j in range(1, detections.size):
if (cc_idx[j-n_removed] - cc_idx[j-n_removed-1]) < search_win // 2:
if cc_sum[cc_idx[j-n_removed]] > cc_sum[cc_idx[j-n_removed-1]]:
cc_idx.remove(cc_idx[j-n_removed-1])
else:
cc_idx.remove(cc_idx[j-n_removed])
n_removed += 1
cc_idx = np.asarray(cc_idx)
detections = cc_idx * step
return detections
2022-12-05 MAD检测,去重
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...