There will be maintenance performed on,,, and starting at 9am PDT on Tuesday 18th August 2020. There will be an extremely small period of downtime at the start of the maintenance window as various services are restarted. Please address any comments, questions, or concerns to

Commit 79299982 authored by Leo Pound Singer's avatar Leo Pound Singer

bayestar_localize_lvalert: reuse coinc_and_sngl_inspirals_for_xmldoc

Original: 5b39f18e884b469d75cc0564566ac6390691c646
parent 97bd8dea
......@@ -127,7 +127,7 @@ def sim_coinc_and_sngl_inspirals_for_xmldoc(xmldoc):
yield sim_inspiral, coinc, sngl_inspirals
def coinc_and_sngl_inspirals_for_xmldoc(xmldoc):
def coinc_and_sngl_inspirals_for_xmldoc(xmldoc, coinc_def=InspiralCoincDef):
"""Retrieve (as a generator) all of the
(sngl_inspiral, sngl_inspiral, ... sngl_inspiral) tuples from coincidences
in a LIGO-LW XML document."""
......@@ -139,9 +139,10 @@ def coinc_and_sngl_inspirals_for_xmldoc(xmldoc):
sngl_inspiral_table = ligolw_table.get_table(xmldoc, lsctables.SnglInspiralTable.tableName)
# Look up coinc_def id.
sngl_sngl_coinc_def_ids = {row.coinc_def_id for row in coinc_def_table
if (, row.search_coinc_type) ==
(, InspiralCoincDef.search_coinc_type)}
if coinc_def:
sngl_sngl_coinc_def_ids = {row.coinc_def_id for row in coinc_def_table
if (, row.search_coinc_type) ==
(, coinc_def.search_coinc_type)}
# Indices to speed up lookups by ID.
key = operator.attrgetter('coinc_event_id')
......@@ -153,7 +154,7 @@ def coinc_and_sngl_inspirals_for_xmldoc(xmldoc):
# Loop over all sngl_inspiral <-> sngl_inspiral coincs.
for coinc in coinc_table:
if coinc.coinc_def_id in sngl_sngl_coinc_def_ids:
if not coinc_def or coinc.coinc_def_id in sngl_sngl_coinc_def_ids:
coinc_maps = coinc_maps_by_coinc_event_id[coinc.coinc_event_id]
yield coinc, tuple(sngl_inspirals_by_event_id[coinc_map.event_id]
for coinc_map in coinc_maps)
......@@ -418,14 +418,6 @@ def gracedb_sky_map(
xmldoc, _ = ligolw_utils.load_fileobj(
coinc_file, contenthandler=ligolw.LSCTablesAndSeriesContentHandler)
# Locate the tables that we need.
coinc_inspiral_table = ligolw_table.get_table(xmldoc,
coinc_map_table = ligolw_table.get_table(xmldoc,
sngl_inspiral_table = ligolw_table.get_table(xmldoc,
# Attempt to determine phase convention from process table.
process_table = ligolw_table.get_table(xmldoc,
......@@ -440,12 +432,9 @@ def gracedb_sky_map(
phase_convention = 'antifindchirp'
# Locate the sngl_inspiral rows that we need.
coinc_inspiral = coinc_inspiral_table[0]
coinc_event_id = coinc_inspiral.coinc_event_id
event_ids = [coinc_map.event_id for coinc_map in coinc_map_table
if coinc_map.coinc_event_id == coinc_event_id]
sngl_inspirals = [next((sngl_inspiral for sngl_inspiral in sngl_inspiral_table
if sngl_inspiral.event_id == event_id)) for event_id in event_ids]
(_, sngl_inspirals), = ligolw.coinc_and_sngl_inspirals_for_xmldoc(
xmldoc, coinc_def=None)
sngl_inspirals = list(sngl_inspirals)
# Try to load complex SNR time series.
snrs = ligolw.snr_series_by_sngl_inspiral_id_for_xmldoc(xmldoc)
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