Skip to content

Commit

Permalink
updating pycbc_live
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurTolley committed Jul 11, 2023
1 parent 09ea171 commit 71bc23c
Showing 1 changed file with 36 additions and 14 deletions.
50 changes: 36 additions & 14 deletions bin/pycbc_live
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import os.path
import itertools
import platform
import subprocess
import multiprocessing
from multiprocessing.dummy import threading
from matplotlib import use
use('agg')
Expand Down Expand Up @@ -80,6 +81,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 @@ -114,13 +116,20 @@ class LiveEventManager(object):
available_cores = len(os.sched_getaffinity(0))
bg_cores = len(tuple(itertools.combinations(ifos, 2)))
analysis_cores = 1 + bg_cores
self.fu_cores = available_cores - analysis_cores
self.optimizer = args.optimizer
if self.fu_cores <= 0:
logging.warning('Insufficient number of CPU cores (%d) to '
'run search and trigger followups. Uploaded '
'triggers will momentarily increase the lag',
available_cores)
if platform.system() != 'Darwin':
available_cores = len(os.sched_getaffinity(0))
self.fu_cores = available_cores - analysis_cores
self.optimizer = args.optimizer
if self.fu_cores <= 0:
logging.warning(
'Insufficient number of CPU cores (%d) to '
'run search and trigger followups. Uploaded '
'triggers will momentarily increase the lag',
available_cores
)
self.fu_cores = 1
else:
# To enable mac testing, this is just set to 1
self.fu_cores = 1
# Convert SNR optimizer options into a string
self.snr_opt_options = snr_optimizer.args_to_string(args)
Expand Down Expand Up @@ -216,7 +225,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 @@ -466,7 +475,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 @@ -552,6 +562,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 @@ -909,13 +920,16 @@ parser.add_argument('--snr-opt-timeout', type=int, default=400, metavar='SECONDS
help='Maximum allowed duration of followup process to maximize SNR')
parser.add_argument('--snr-opt-label', type=str, default='SNR_OPTIMIZED',
help='Label to apply to snr-optimized GraceDB uploads')

parser.add_argument('--enable-embright-has-massgap', action='store_true', default=False,
help='Estimate HasMassGap probability for EMBright info. Lower limit '
'of the mass gap is equal to the maximum NS mass used for '
'the source classification.')
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 +973,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 +1051,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 @@ -1099,6 +1115,11 @@ with ctx:
else:
psd_count[ifo] -= 1

status &= data_reader[ifo].check_psd_dist(
args.min_psd_abort_distance,
args.max_psd_abort_distance
)

if data_reader[ifo].psd is not None:
dist = data_reader[ifo].psd.dist
if dist < args.min_psd_abort_distance or dist > args.max_psd_abort_distance:
Expand All @@ -1108,10 +1129,11 @@ with ctx:
status = False

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

0 comments on commit 71bc23c

Please sign in to comment.