Esempio n. 1
0
def ligolw_thinca(xmldoc,
                  process_id,
                  coinc_definer_row,
                  event_comparefunc,
                  thresholds,
                  ntuple_comparefunc=default_ntuple_comparefunc,
                  effective_snr_factor=250.0,
                  veto_segments=None,
                  trigger_program=u"inspiral",
                  likelihood_func=None,
                  likelihood_params_func=None,
                  verbose=False,
                  max_dt=None):
    #
    # prepare the coincidence table interface.
    #

    if verbose:
        print >> sys.stderr, "indexing ..."
    coinc_tables = InspiralCoincTables(
        xmldoc,
        vetoes=veto_segments,
        program=trigger_program,
        likelihood_func=likelihood_func,
        likelihood_params_func=likelihood_params_func)
    coinc_def_id = ligolw_coincs.get_coinc_def_id(
        xmldoc,
        coinc_definer_row.search,
        coinc_definer_row.search_coinc_type,
        create_new=True,
        description=coinc_definer_row.description)
    sngl_index = dict((row.event_id, row)
                      for row in lsctables.SnglInspiralTable.get_table(xmldoc))

    #
    # build the event list accessors, populated with events from those
    # processes that can participate in a coincidence.  apply vetoes by
    # removing events from the lists that fall in vetoed segments
    #

    eventlists = snglcoinc.make_eventlists(
        xmldoc, InspiralEventList, lsctables.SnglInspiralTable.tableName)
    if veto_segments is not None:
        for eventlist in eventlists.values():
            iterutils.inplace_filter(
                (lambda event: event.ifo not in veto_segments or event.end
                 not in veto_segments[event.ifo]), eventlist)

    #
    # set the \Delta t parameter on all the event lists
    #

    if max_dt is None:
        max_dt = inspiral_max_dt(lsctables.SnglInspiralTable.get_table(xmldoc),
                                 thresholds)
    if verbose:
        print >> sys.stderr, "event bisection search window will be %.16g s" % max_dt
    for eventlist in eventlists.values():
        eventlist.set_dt(max_dt)

    #
    # replicate the ethinca parameter for every possible instrument
    # pair
    #

    thresholds = replicate_threshold(thresholds, set(eventlists))

    #
    # construct offset vector assembly graph
    #

    time_slide_graph = snglcoinc.TimeSlideGraph(coinc_tables.time_slide_index,
                                                verbose=verbose)

    #
    # retrieve all coincidences, apply the final n-tuple compare func
    # and record the survivors
    #

    for node, coinc in time_slide_graph.get_coincs(eventlists,
                                                   event_comparefunc,
                                                   thresholds,
                                                   verbose=verbose):
        coinc = tuple(sngl_index[event_id] for event_id in coinc)
        if not ntuple_comparefunc(coinc, node.offset_vector):
            coinc_tables.append_coinc(process_id, node.time_slide_id,
                                      coinc_def_id, coinc,
                                      effective_snr_factor)

    #
    # remove time offsets from events
    #

    del eventlists.offsetvector

    #
    # done
    #

    return xmldoc
Esempio n. 2
0
def ligolw_burca(xmldoc,
                 process_id,
                 EventListType,
                 CoincTables,
                 coinc_definer_row,
                 event_comparefunc,
                 thresholds,
                 ntuple_comparefunc=lambda events, offset_vector: False,
                 min_instruments=2,
                 verbose=False):
    #
    # validate input
    #

    if min_instruments < 1:
        raise ValueError("min_instruments (=%d) must be >= 1" %
                         min_instruments)

    #
    # prepare the coincidence table interface.
    #

    if verbose:
        print >> sys.stderr, "indexing ..."
    coinc_tables = CoincTables(xmldoc)
    coinc_def_id = ligolw_coincs.get_coinc_def_id(
        xmldoc,
        coinc_definer_row.search,
        coinc_definer_row.search_coinc_type,
        create_new=True,
        description=coinc_definer_row.description)
    sngl_burst_table = lsctables.SnglBurstTable.get_table(xmldoc)
    sngl_index = dict((row.event_id, row) for row in sngl_burst_table)

    #
    # build the event list accessors, populated with events from those
    # processes that can participate in a coincidence
    #

    eventlists = snglcoinc.EventListDict(
        EventListType,
        sngl_burst_table,
        instruments=set(
            coinc_tables.time_slide_table.getColumnByName("instrument")))

    #
    # construct offset vector assembly graph
    #

    time_slide_graph = snglcoinc.TimeSlideGraph(coinc_tables.time_slide_index,
                                                verbose=verbose)

    #
    # retrieve all coincidences, apply the final n-tuple compare func
    # and record the survivors
    #

    for node, coinc in time_slide_graph.get_coincs(eventlists,
                                                   event_comparefunc,
                                                   thresholds,
                                                   verbose=verbose):
        if len(coinc) < min_instruments:
            continue
        ntuple = tuple(sngl_index[id] for id in coinc)
        if not ntuple_comparefunc(ntuple, node.offset_vector):
            coinc_tables.append_coinc(*coinc_tables.coinc_rows(
                process_id, node.time_slide_id, coinc_def_id, ntuple))

    #
    # done
    #

    return xmldoc
Esempio n. 3
0
def ligolw_burca(xmldoc,
                 process_id,
                 EventListType,
                 CoincTables,
                 coinc_definer_row,
                 event_comparefunc,
                 thresholds,
                 ntuple_comparefunc=lambda events, offset_vector: False,
                 verbose=False):
    #
    # prepare the coincidence table interface.
    #

    if verbose:
        print >> sys.stderr, "indexing ..."
    coinc_tables = CoincTables(xmldoc)
    coinc_def_id = ligolw_coincs.get_coinc_def_id(
        xmldoc,
        coinc_definer_row.search,
        coinc_definer_row.search_coinc_type,
        create_new=True,
        description=coinc_definer_row.description)
    sngl_index = dict((row.event_id, row)
                      for row in lsctables.SnglBurstTable.get_table(xmldoc))

    #
    # build the event list accessors, populated with events from those
    # processes that can participate in a coincidence
    #

    eventlists = snglcoinc.make_eventlists(xmldoc, EventListType,
                                           lsctables.SnglBurstTable.tableName)

    #
    # construct offset vector assembly graph
    #

    time_slide_graph = snglcoinc.TimeSlideGraph(coinc_tables.time_slide_index,
                                                verbose=verbose)

    #
    # retrieve all coincidences, apply the final n-tuple compare func
    # and record the survivors
    #

    for node, coinc in time_slide_graph.get_coincs(eventlists,
                                                   event_comparefunc,
                                                   thresholds,
                                                   verbose=verbose):
        ntuple = tuple(sngl_index[id] for id in coinc)
        if not ntuple_comparefunc(ntuple, node.offset_vector):
            coinc_tables.append_coinc(process_id, node.time_slide_id,
                                      coinc_def_id, ntuple)

    #
    # remove time offsets from events
    #

    del eventlists.offsetvector

    #
    # done
    #

    return xmldoc
Esempio n. 4
0
def ligolw_rinca(xmldoc,
                 process_id,
                 EventListType,
                 CoincTables,
                 coinc_definer_row,
                 event_comparefunc,
                 thresholds,
                 ntuple_comparefunc=lambda events, offset_vector: False,
                 small_coincs=False,
                 veto_segments=None,
                 coinc_end_time_segment=None,
                 verbose=False):
    #
    # prepare the coincidence table interface.
    #

    if verbose:
        print >> sys.stderr, "indexing ..."
    coinc_tables = CoincTables(xmldoc, vetoes=veto_segments)
    coinc_def_id = llwapp.get_coinc_def_id(
        xmldoc,
        coinc_definer_row.search,
        coinc_definer_row.search_coinc_type,
        create_new=True,
        description=coinc_definer_row.description)
    sngl_index = dict((row.event_id, row)
                      for row in lsctables.SnglRingdownTable.get_table(xmldoc))

    #
    # build the event list accessors, populated with events from those
    # processes that can participate in a coincidence.  apply vetoes by
    # removing events from the lists that fall in vetoed segments
    #

    eventlists = snglcoinc.EventListDict(
        EventListType, lsctables.SnglRingdownTable.get_table(xmldoc))
    if veto_segments is not None:
        for eventlist in eventlists.values():
            iterutils.inplace_filter(
                (lambda event: event.ifo not in veto_segments or event.
                 get_start() not in veto_segments[event.ifo]), eventlist)

    #
    # set the \Delta t parameter on all the event lists
    #

    max_dt = ringdown_max_dt(lsctables.SnglRingdownTable.get_table(xmldoc),
                             thresholds)
    if verbose:
        print >> sys.stderr, "event bisection search window will be %.16g s" % max_dt
    for eventlist in eventlists.values():
        eventlist.set_dt(max_dt)

    #
    # replicate the ds_sq threshold for every possible instrument
    # pair
    #

    thresholds = replicate_threshold(thresholds, set(eventlists))

    #
    # construct offset vector assembly graph
    #

    time_slide_graph = snglcoinc.TimeSlideGraph(coinc_tables.time_slide_index,
                                                verbose=verbose)

    #
    # retrieve all coincidences, apply the final n-tuple compare func
    # and record the survivors
    #

    for node, coinc in time_slide_graph.get_coincs(eventlists,
                                                   event_comparefunc,
                                                   thresholds,
                                                   verbose=verbose):
        if len(coinc) < 2 or (len(coinc) < len(node.offset_vector)
                              and not small_coincs):
            continue
        ntuple = tuple(sngl_index[id] for id in coinc)
        if not ntuple_comparefunc(ntuple, node.offset_vector):
            coinc_tables.append_coinc(*coinc_tables.coinc_rows(
                process_id, node, coinc_def_id, ntuple))

    #
    # remove time offsets from events
    #

    del eventlists.offsetvector

    #
    # done
    #

    return xmldoc
Esempio n. 5
0
def ligolw_thinca(xmldoc,
                  process_id,
                  coinc_definer_row,
                  event_comparefunc,
                  thresholds,
                  max_dt,
                  ntuple_comparefunc=default_ntuple_comparefunc,
                  veto_segments=None,
                  trigger_program=u"inspiral",
                  likelihood_func=None,
                  likelihood_params_func=None,
                  min_instruments=2,
                  min_log_L=None,
                  verbose=False):
    #
    # validate input
    #

    if min_instruments < 1:
        raise ValueError("min_instruments (=%d) must be >= 1" %
                         min_instruments)
    if min_log_L is not None and likelihood_func is None:
        raise ValueError("must supply likelihood_func to impose min_log_L cut")

    #
    # prepare the coincidence table interface.
    #

    if verbose:
        print >> sys.stderr, "indexing ..."
    coinc_tables = InspiralCoincTables(
        xmldoc,
        vetoes=veto_segments,
        program=trigger_program,
        likelihood_func=likelihood_func,
        likelihood_params_func=likelihood_params_func)
    coinc_def_id = ligolw_coincs.get_coinc_def_id(
        xmldoc,
        coinc_definer_row.search,
        coinc_definer_row.search_coinc_type,
        create_new=True,
        description=coinc_definer_row.description)
    sngl_inspiral_table = lsctables.SnglInspiralTable.get_table(xmldoc)
    sngl_index = dict((row.event_id, row) for row in sngl_inspiral_table)

    #
    # build the event list accessors, populated with events from those
    # processes that can participate in a coincidence.  apply vetoes by
    # removing events from the lists that fall in vetoed segments
    #

    eventlists = snglcoinc.EventListDict(
        InspiralEventList,
        sngl_inspiral_table,
        instruments=set(
            coinc_tables.time_slide_table.getColumnByName("instrument")))
    if veto_segments is not None:
        for eventlist in eventlists.values():
            iterutils.inplace_filter(
                (lambda event: event.ifo not in veto_segments or event.end
                 not in veto_segments[event.ifo]), eventlist)

    #
    # set the \Delta t parameter on all the event lists
    #

    if verbose:
        print >> sys.stderr, "event bisection search window will be %.16g s" % max_dt
    for eventlist in eventlists.values():
        eventlist.set_dt(max_dt)

    #
    # replicate the ethinca parameter for every possible instrument
    # pair
    #

    thresholds = replicate_threshold(thresholds, eventlists)

    #
    # construct offset vector assembly graph
    #

    time_slide_graph = snglcoinc.TimeSlideGraph(coinc_tables.time_slide_index,
                                                verbose=verbose)

    #
    # retrieve all coincidences, apply the final n-tuple compare func
    # and record the survivors
    #

    for node, coinc in time_slide_graph.get_coincs(eventlists,
                                                   event_comparefunc,
                                                   thresholds,
                                                   verbose=verbose):
        if len(coinc) < min_instruments:
            continue
        coinc = tuple(sngl_index[event_id] for event_id in coinc)
        if not ntuple_comparefunc(coinc, node.offset_vector):
            coinc, coincmaps, coinc_inspiral = coinc_tables.coinc_rows(
                process_id, node.time_slide_id, coinc_def_id, coinc)
            if min_log_L is None or coinc.likelihood >= min_log_L:
                coinc_tables.append_coinc(coinc, coincmaps, coinc_inspiral)

    #
    # done
    #

    return xmldoc