Skip to content

Commit

Permalink
Introduced a new arguement --skymap-only-ifos in pycbc_live (#4346)
Browse files Browse the repository at this point in the history
* Introduced a new arguement --skymap-only-ifos in pycbc_live

* Default skymap_only_ifos changed

* skymap_only_ifos as an attribute of LiveEventManager

* Test skymaps with V1 as skymap_only_ifos

* singles with skymap_only_ifos

* Removing commented lines etc

* A default seed for SNR opt

* Poking CI tests

I remove an unnecessary FIXME in the comments, but mostly doing this to restart the CI tests, which seem to have not linked up right.

---------

Co-authored-by: Souradeep Pal <souradeep.pal@ldas-pcdev4.ligo.caltech.edu>
Co-authored-by: Ian Harry <ian.harry@port.ac.uk>
  • Loading branch information
3 people authored Jul 11, 2023
1 parent 006f52f commit d4a9f38
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 24 deletions.
26 changes: 17 additions & 9 deletions bin/pycbc_live
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class LiveEventManager(object):
def __init__(self, args, bank):
self.low_frequency_cutoff = args.low_frequency_cutoff
self.bank = bank
self.skymap_only_ifos = [] if args.skymap_only_ifos is None else list(set(args.skymap_only_ifos))

# Figure out what we are supposed to process within the pool of MPI processes
self.comm = mpi.COMM_WORLD
Expand Down Expand Up @@ -219,7 +220,7 @@ class LiveEventManager(object):
ifo,
triggers,
pvalue_info,
recalculate_ifar=recalculate_ifar
recalculate_ifar=recalculate_ifar and ifo not in self.skymap_only_ifos
)

# the SNR time series sample rate can vary slightly due to
Expand Down Expand Up @@ -423,7 +424,7 @@ class LiveEventManager(object):
# reload_buffer time. These args are documented here:
# https://ligo-gracedb.readthedocs.io/en/latest/api.html#ligo.gracedb.rest.GraceDb
# Because we do not change any of the request session values when running the
# code, it should remain thread safe.
# code, it should remain thread safe.
gdbargs = {'reload_certificate': True, 'reload_buffer': 300}
if self.gracedb_server:
gdbargs['service_url'] = self.gracedb_server
Expand Down Expand Up @@ -464,7 +465,8 @@ class LiveEventManager(object):

logging.info('computing followup data for coinc')
coinc_ifos = coinc_results['foreground/type'].split('-')
followup_ifos = list(set(ifos) - set(coinc_ifos))
followup_ifos = set(ifos) - set(coinc_ifos)
followup_ifos = list(followup_ifos | set(self.skymap_only_ifos))

double_ifar = coinc_results['foreground/ifar']
if double_ifar < args.ifar_double_followup_threshold:
Expand Down Expand Up @@ -510,7 +512,7 @@ class LiveEventManager(object):
ifar = coinc_results['foreground/ifar']
upload_checks = self.enable_gracedb_upload and self.ifar_upload_threshold < ifar
optimize_snr_checks = self.run_snr_optimization and self.ifar_upload_threshold < ifar

# Keep track of the last few coincs uploaded in order to
# prevent singles being uploaded as well for coinc events
self.last_few_coincs_uploaded.append(event.merger_time)
Expand Down Expand Up @@ -550,6 +552,7 @@ class LiveEventManager(object):
logging.info(f'Found {ifo} single with ifar {sifar}')

followup_ifos = [i for i in active if i is not ifo]
followup_ifos = list(set(followup_ifos) | set(self.skymap_only_ifos))
# Don't recompute ifar considering other ifos
sld = self.compute_followup_data(
[ifo],
Expand Down Expand Up @@ -917,6 +920,8 @@ parser.add_argument('--enable-embright-has-massgap', action='store_true', defaul
parser.add_argument('--embright-massgap-max', type=float, default=5.0, metavar='SOLAR MASSES',
help='Upper limit of the mass gap, used for estimating '
'HasMassGap probability.')
parser.add_argument('--skymap-only-ifos', nargs='+',
help="Detectors that only contribute in sky localization")

scheme.insert_processing_option_group(parser)
LiveSingle.insert_args(parser)
Expand Down Expand Up @@ -959,6 +964,7 @@ ifos = set(args.channel_name.keys())
logging.info('Analyzing data from detectors %s', ppdets(ifos))

evnt = LiveEventManager(args, bank)
logging.info('Detectors that only aid in the sky localization %s', ppdets(evnt.skymap_only_ifos))

# include MPI rank and functional description into proctitle
task_name = 'root' if evnt.rank == 0 else 'filtering'
Expand Down Expand Up @@ -1036,7 +1042,8 @@ with ctx:

# Create double coincident background estimator for every combo
if args.enable_background_estimation and evnt.rank == 0:
ifo_combos = itertools.combinations(ifos, 2)
trigg_ifos = [ifo for ifo in ifos if ifo not in evnt.skymap_only_ifos]
ifo_combos = itertools.combinations(trigg_ifos, 2)
estimators = []
for combo in ifo_combos:
logging.info('Will calculate %s background', ppdets(combo, "-"))
Expand Down Expand Up @@ -1105,10 +1112,11 @@ with ctx:
)

if status is True:
evnt.live_detectors.add(ifo)
if evnt.rank > 0:
logging.info('Filtering %s', ifo)
results[ifo] = mf.process_data(data_reader[ifo])
if ifo not in evnt.skymap_only_ifos:
evnt.live_detectors.add(ifo)
if evnt.rank > 0:
logging.info('Filtering %s', ifo)
results[ifo] = mf.process_data(data_reader[ifo])
else:
logging.info('Insufficient data for %s analysis', ifo)

Expand Down
2 changes: 1 addition & 1 deletion bin/pycbc_optimize_snr
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ parser.add_argument('--include-candidate-in-optimizer', action='store_true',
help='Include parameters of the candidate event in the '
'initialised array for the optimizer. Only relevant for '
'--optimizer pso or differential_evolution')
parser.add_argument('--seed', type=int,
parser.add_argument('--seed', type=int, default=42,
help='Seed to supply to the random generation of initial '
'array to pass to the optimizer. Only relevant for '
'--optimizer pso or differential_evolution')
Expand Down
14 changes: 0 additions & 14 deletions pycbc/io/live.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ def __init__(self, coinc_ifos, ifos, coinc_results, **kwargs):
snr_ifos = sld.keys() # Ifos with SNR time series calculated
self.snr_series = {ifo: sld[ifo]['snr_series'] for ifo in snr_ifos}
# Extra ifos have SNR time series but not sngl inspiral triggers
extra_ifos = list(set(snr_ifos) - set(self.et_ifos))

for ifo in snr_ifos:
# Ifos used for sky loc must have a PSD
Expand All @@ -101,14 +100,11 @@ def __init__(self, coinc_ifos, ifos, coinc_results, **kwargs):
else:
self.snr_series = None
snr_ifos = self.et_ifos
extra_ifos = []

# Set up the bare structure of the xml document
outdoc = ligolw.Document()
outdoc.appendChild(ligolw.LIGO_LW())

# FIXME is it safe (in terms of downstream operations) to let
# `program_name` default to the actual script name?
proc_id = create_process_table(outdoc, program_name='pycbc',
detectors=snr_ifos).process_id

Expand Down Expand Up @@ -191,16 +187,6 @@ def __init__(self, coinc_ifos, ifos, coinc_results, **kwargs):
self.et_ifos]) \
+ self.time_offset

# For extra detectors used only for sky loc, respect BAYESTAR's
# assumptions and checks
bayestar_check_fields = ('mass1 mass2 mtotal mchirp eta spin1x '
'spin1y spin1z spin2x spin2y spin2z').split()
for sngl in sngl_inspiral_table:
if sngl.ifo in extra_ifos:
for bcf in bayestar_check_fields:
setattr(sngl, bcf, getattr(sngl_populated, bcf))
sngl.end = lal.LIGOTimeGPS(self.merger_time)

outdoc.childNodes[0].appendChild(coinc_event_map_table)
outdoc.childNodes[0].appendChild(sngl_inspiral_table)

Expand Down

0 comments on commit d4a9f38

Please sign in to comment.