Commit 7d506898 authored by Marius Kriegerowski's avatar Marius Kriegerowski
Browse files

snuffling: fix comparison

parent bc956ec2
......@@ -155,7 +155,7 @@ class LassieSnuffling(Snuffling):
def show_comparison(self):
'''
Iterates through reference catalog and searches for lassie detection
candidates in a time window of +- 2 seconds around the reference.
candidates in a time window of +- 1.5 seconds around the reference.
If multiple candidates are available selects the first as the matching
lassie detection for this reference.
......@@ -163,7 +163,7 @@ class LassieSnuffling(Snuffling):
This option requires the catalog to contain only pyrocko.model.Event
instances.
'''
scan_time = 2.
scan_time = 3.
select_by = 'first'
if not self.markers_compare:
......@@ -171,17 +171,17 @@ class LassieSnuffling(Snuffling):
markers_compare = self.filter_visible(self.markers_compare)
not_detected = []
detected_compare = []
detections_success = []
detections = copy.deepcopy(self.filter_visible(self.detections))
for i_m, m in enumerate(markers_compare):
marker_times = num.array([m.tmin for m in detections])
i_want = num.where(num.abs(marker_times-m.tmin) < scan_time / 2.)
if len(i_want[0]) == 0:
not_detected.append(m)
for i_m, mcompare in enumerate(markers_compare):
detection_times = num.array([d.tmin for d in detections])
i_want = num.where(num.abs(detection_times - mcompare.tmin) \
< (scan_time / 2.))[0]
if len(i_want) == 0:
not_detected.append(mcompare)
continue
candidates = [detections[i] for i in i_want[0]]
candidates = [detections[i] for i in i_want]
# if select_by == 'first':
matched_marker = min(
......@@ -191,7 +191,6 @@ class LassieSnuffling(Snuffling):
# matched_marker = max(
# candidates, key=lambda x: float(x.get_event().name))
detected_compare.append(m)
detections_success.append((matched_marker, i_m))
for c in candidates:
......@@ -210,12 +209,12 @@ class LassieSnuffling(Snuffling):
bins = num.linspace(-1, max(magnitudes), 30)
ax.hist([detected_magnitudes, magnitudes], bins,
label=['Lassie', 'Reference'], alpha=0.7)
n_detected = len(detections)
n_leftover_detections = len(detections)
n_undetected = len(not_detected)
ax.text(
0.05, 0.95, 'Other detections: %s\nNot detected: %s (%1.1f %%)' %
(n_detected, n_undetected,
(n_leftover_detections, n_undetected,
(float(n_undetected)/len(markers_compare)*100.)),
transform=ax.transAxes)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment