From d4a9f388e8d0a32ab5cb319b7c6a31f45a99f910 Mon Sep 17 00:00:00 2001 From: SouradeepPal <126229608+SouradeepPal@users.noreply.github.com> Date: Tue, 11 Jul 2023 13:43:16 +0530 Subject: [PATCH] Introduced a new arguement --skymap-only-ifos in pycbc_live (#4346) * 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 Co-authored-by: Ian Harry --- bin/pycbc_live | 26 +++++++++++++++++--------- bin/pycbc_optimize_snr | 2 +- pycbc/io/live.py | 14 -------------- 3 files changed, 18 insertions(+), 24 deletions(-) diff --git a/bin/pycbc_live b/bin/pycbc_live index 210e2529be2..76929fcce8f 100755 --- a/bin/pycbc_live +++ b/bin/pycbc_live @@ -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 @@ -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 @@ -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 @@ -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: @@ -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) @@ -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], @@ -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) @@ -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' @@ -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, "-")) @@ -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) diff --git a/bin/pycbc_optimize_snr b/bin/pycbc_optimize_snr index f0eea382558..ce38ac7f793 100755 --- a/bin/pycbc_optimize_snr +++ b/bin/pycbc_optimize_snr @@ -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') diff --git a/pycbc/io/live.py b/pycbc/io/live.py index 5e546cfc2a7..754fcbcf563 100644 --- a/pycbc/io/live.py +++ b/pycbc/io/live.py @@ -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 @@ -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 @@ -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)