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() ...@@ -152,12 +152,10 @@ options, filenames, paramdict = parse_command_line()
if options.coinc_segs is not None: 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): 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 # for the purposes of the coinc segs feature, the coinc
events = sorted(events, key = lambda event: event.peak) # time is minimum of event peak times. this is a fast, and
# coinc time is SNR-weighted mean of event peak times # guaranteed reproducible definition
epoch = events[0].peak + offset_vector[events[0].ifo] return len(events) < min_instruments or min(event.peak for event in events) not in coinc_segs
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
else: else:
def coinc_segs_ntuple_comparefunc(events, offset_vector, min_instruments = options.min_instruments): def coinc_segs_ntuple_comparefunc(events, offset_vector, min_instruments = options.min_instruments):
return len(events) < min_instruments return len(events) < min_instruments
......
...@@ -290,14 +290,9 @@ def StringCoincCompare(a, offseta, b, offsetb, light_travel_time, threshold): ...@@ -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 return abs(float(a.peak + offseta - b.peak - offsetb)) > threshold + light_travel_time
def StringNTupleCoincCompare(events, offset_vector): def StringNTupleCoincCompare(events, offset_vector, disallowed = frozenset(("H1", "H2"))):
instruments = set(event.ifo for event in events)
# disallow H1,H2 only coincs # disallow H1,H2 only coincs
coincident = instruments != set(["H1", "H2"]) return set(event.ifo for event in events) == disallowed
# return result
return not coincident
# #
......
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