From 521dc114c7508a9f02fb710039226d254dca5d72 Mon Sep 17 00:00:00 2001 From: Gareth S Cabourn Davies Date: Mon, 29 Apr 2024 09:14:11 +0100 Subject: [PATCH 1/4] Use approximant parsing argument for make_bayestar (#4712) * Use approximant parsing argument for make_bayestar * SPAtmplt not in bayestar --- bin/all_sky_search/pycbc_make_bayestar_skymap | 36 ++++++++++++++++--- pycbc/workflow/minifollowups.py | 3 +- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/bin/all_sky_search/pycbc_make_bayestar_skymap b/bin/all_sky_search/pycbc_make_bayestar_skymap index 7c4d7c3f255..de1c22c0852 100644 --- a/bin/all_sky_search/pycbc_make_bayestar_skymap +++ b/bin/all_sky_search/pycbc_make_bayestar_skymap @@ -23,8 +23,14 @@ import glob import sys import random import tempfile + +from ligo.lw import lsctables, utils as ligolw_utils + import pycbc.version from pycbc import init_logging +from pycbc.waveform import bank as wavebank +from pycbc.io import WaveformArray +from pycbc.io.ligolw import LIGOLWContentHandler parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('--version', action="version", @@ -38,14 +44,12 @@ parser.add_argument('--bayestar-executable', parser.add_argument('--event-xml', required=True, help="XML file containing event information, SNR " "timeseries and PSD to pass to bayestar") -parser.add_argument('--waveform', default='TaylorF2', - help="Waveform used in the matched-filtering " - "to generate the SNR timeseries.") parser.add_argument('--low-frequency-cutoff', type=float, default=20, help="Low-frequency cutoff used in the matched-filtering " "to generate the SNR timeseries") parser.add_argument('--output-file', required=True, help="Filename to output the fits file to.") +wavebank.add_approximant_arg(parser) args, unknown = parser.parse_known_args() # Default logging is set higher than normal for this job @@ -57,12 +61,36 @@ bayestar_exe = args.bayestar_executable or 'bayestar-localize-coincs' tmpdir = tempfile.mkdtemp() +# Work out which approximant is being used +# Load the file +xmldoc = ligolw_utils.load_filename( + args.event_xml, + contenthandler=LIGOLWContentHandler +) + +# Grab the single inspiral table(s) which contain the template information +sngl_inspiral_table = lsctables.SnglInspiralTable.get_table(xmldoc) + +# turn this into a waveform array +row = WaveformArray.from_ligolw_table( + sngl_inspiral_table, +) + +# Work out which waveform is used based on the template information +# Note that as there are multiple single inspiral tables (one per ifo) +# with the same information, we use [0] here +waveform = wavebank.parse_approximant_arg(args.approximant, row)[0] + +# BAYESTAR uses TaylorF2 instead of SPAtmplt +if waveform == 'SPAtmplt': + waveform = 'TaylorF2' + # Set up the command to pass to bayestar. # The XML file path being passed twice is a legacy requirement, not a mistake. cmd = [bayestar_exe, args.event_xml, args.event_xml, - '--waveform', args.waveform, + '--waveform', waveform, '--f-low', str(args.low_frequency_cutoff), '-o', tmpdir] diff --git a/pycbc/workflow/minifollowups.py b/pycbc/workflow/minifollowups.py index 947742d9ad3..126d0b3eec6 100644 --- a/pycbc/workflow/minifollowups.py +++ b/pycbc/workflow/minifollowups.py @@ -1104,11 +1104,12 @@ def make_upload_files(workflow, psd_files, snr_timeseries, xml_all, '--output-file', ) + # This will be called if the approximant is within the bank if approximant == b'SPAtmplt': # Bayestar doesn't use the SPAtmplt approximant approximant = b'TaylorF2' if approximant is not None: - bayestar_node.add_opt('--waveform', approximant.decode()) + bayestar_node.add_opt('--approximant', approximant.decode()) workflow += bayestar_node From ee2484bcad6406c4c0915884d815d7794e25b2ae Mon Sep 17 00:00:00 2001 From: Ian Harry Date: Tue, 28 May 2024 08:30:14 -0700 Subject: [PATCH 2/4] Cherry pick [manually] 4683 --- pycbc/psd/variation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pycbc/psd/variation.py b/pycbc/psd/variation.py index 50a006faf99..2548ab5707d 100644 --- a/pycbc/psd/variation.py +++ b/pycbc/psd/variation.py @@ -168,7 +168,7 @@ def calc_filt_psd_variation(strain, segment, short_segment, psd_long_segment, fweight = norm * fweight fwhiten = numpy.sqrt(2. / srate) / numpy.sqrt(plong) fwhiten[0] = 0. - full_filt = sig.hann(int(psd_duration * srate)) * numpy.roll( + full_filt = sig.windows.hann(int(psd_duration * srate)) * numpy.roll( irfft(fwhiten * fweight), int(psd_duration / 2) * srate) # Convolve the filter with long segment of data wstrain = sig.fftconvolve(astrain, full_filt, mode='same') From a898df53446fbee3a62ede231fae3dc737bd93a6 Mon Sep 17 00:00:00 2001 From: Gareth S Cabourn Davies Date: Thu, 4 Apr 2024 12:02:38 +0100 Subject: [PATCH 3/4] Bugfix: allow nothing to be given in --labels (#4681) * Bugfix: allow nothing to be given in --labels * Update bin/all_sky_search/pycbc_upload_single_event_to_gracedb Co-authored-by: Tito Dal Canton --------- Co-authored-by: Tito Dal Canton --- bin/all_sky_search/pycbc_upload_single_event_to_gracedb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/all_sky_search/pycbc_upload_single_event_to_gracedb b/bin/all_sky_search/pycbc_upload_single_event_to_gracedb index 78903ebbceb..8a965851e45 100755 --- a/bin/all_sky_search/pycbc_upload_single_event_to_gracedb +++ b/bin/all_sky_search/pycbc_upload_single_event_to_gracedb @@ -72,7 +72,7 @@ if args.production_server: else: gracedb = GraceDb(service_url='https://gracedb-playground.ligo.org/api/') -labels = [l.upper() for l in args.labels] +labels = [l.upper() for l in (args.labels or [])] allowed_labels = gracedb.allowed_labels if set(labels) - set(allowed_labels): From e0367be9dacbb54786f80b971cc3312b0d8afa64 Mon Sep 17 00:00:00 2001 From: Ian Harry Date: Tue, 28 May 2024 08:42:37 -0700 Subject: [PATCH 4/4] Bump version number --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 77ae3b73a99..894dffaf0a2 100755 --- a/setup.py +++ b/setup.py @@ -119,7 +119,7 @@ def __getattr__(self, attr): vinfo = _version_helper.generate_git_version_info() except: vinfo = vdummy() - vinfo.version = '2.3.6' + vinfo.version = '2.3.7' vinfo.release = 'True' version_script = f"""# coding: utf-8