Skip to content
Snippets Groups Projects
Commit 808211a1 authored by Kipp Cannon's avatar Kipp Cannon
Browse files

inspiral.py: improve scaling of trigger segmentlist extraction

- use stream_thinca's discard_boundary and a bisection search to clip the ratebinlist objects to the range of segments we actually care about
parent 00dc774e
No related branches found
No related tags found
No related merge requests found
......@@ -778,13 +778,20 @@ class Data(object):
if not buf_is_gap:
self.rankingstat.denominator.triggerrates[instrument].add_ratebin(map(float, buf_seg), len(events))
# extract times when instruments were producing
# SNR. used to define "on instruments" for coinc
# tables among other things. will only need
# segment information for the times for which we
# have triggers, so use stream_thinca's discard
# boundary and a bisection search to clip the lists
# to reduce subsequent operation count.
discard_boundary = float(self.stream_thinca.discard_boundary)
snr_segments = segments.segmentlistdict((instrument, ratebinlist[bisect.bisect_left(ratebinlist, (discard_boundary,)):].segmentlist()) for instrument, ratebinlist in self.rankingstat.denominator.triggerrates.items())
# times when at least 2 instruments were generating
# SNR. used to sieve triggers for inclusion in the
# denominator. fast path: because all end times
# have been confirmed to be later than the start of
# the buffer we just collected, that can be used to
# clip the trigger rate history for speed
two_or_more_instruments = segmentsUtils.vote((ratebinlist[bisect.bisect_left(ratebinlist, (float(buf_timestamp),)):] for ratebinlist in self.rankingstat.denominator.triggerrates.values() if ratebinlist), 2)
# denominator.
two_or_more_instruments = segmentsUtils.vote(snr_segments.values(), 2)
# run stream thinca. update the parameter
# distribution data from sngls that weren't used in
......@@ -802,7 +809,7 @@ class Data(object):
# contaminating our noise model, so it's not
# necessary for this test to be super precisely
# defined.
for event in itertools.chain(self.stream_thinca.add_events(self.coincs_document.xmldoc, self.coincs_document.process_id, events, buf_timestamp, self.rankingstat.segmentlists, fapfar = self.fapfar), self.stream_thinca.last_coincs.single_sngl_inspirals() if self.stream_thinca.last_coincs else ()):
for event in itertools.chain(self.stream_thinca.add_events(self.coincs_document.xmldoc, self.coincs_document.process_id, events, buf_timestamp, snr_segments, fapfar = self.fapfar), self.stream_thinca.last_coincs.single_sngl_inspirals() if self.stream_thinca.last_coincs else ()):
if event.end in two_or_more_instruments:
self.rankingstat.denominator.increment(event)
self.coincs_document.commit()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment