Commit 05522083 authored by Kipp Cannon's avatar Kipp Cannon

lalapps_burca: ntuple_comparefunc() performance improvements

- simplify definition of "coinc time" for purpose of the --coincidence-segments feature
- pre-construct the ("H1", "H2") set for the comparison used to identify disallowed instrument combos
Original: d059552aea872093b9b505f6483923ea3ead0490
parent 6ab15793
......@@ -152,12 +152,10 @@ options, filenames, paramdict = parse_command_line()
if options.coinc_segs is not None:
def coinc_segs_ntuple_comparefunc(events, offset_vector, min_instruments = options.min_instruments, coinc_segs = options.coinc_segs):
# sort so we always do arithmetic in the same order
events = sorted(events, key = lambda event: event.peak)
# coinc time is SNR-weighted mean of event peak times
epoch = events[0].peak + offset_vector[events[0].ifo]
coinc_time = epoch + sum(float(event.peak + offset_vector[event.ifo] - epoch) * event.snr for event in events) / sum(event.snr for event in events)
return len(events) < min_instruments or coinc_time not in coinc_segs
# for the purposes of the coinc segs feature, the coinc
# time is minimum of event peak times. this is a fast, and
# guaranteed reproducible definition
return len(events) < min_instruments or min(event.peak for event in events) not in coinc_segs
else:
def coinc_segs_ntuple_comparefunc(events, offset_vector, min_instruments = options.min_instruments):
return len(events) < min_instruments
......
......@@ -290,14 +290,9 @@ def StringCoincCompare(a, offseta, b, offsetb, light_travel_time, threshold):
return abs(float(a.peak + offseta - b.peak - offsetb)) > threshold + light_travel_time
def StringNTupleCoincCompare(events, offset_vector):
instruments = set(event.ifo for event in events)
def StringNTupleCoincCompare(events, offset_vector, disallowed = frozenset(("H1", "H2"))):
# disallow H1,H2 only coincs
coincident = instruments != set(["H1", "H2"])
# return result
return not coincident
return set(event.ifo for event in events) == disallowed
#
......
Markdown is supported
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