Skip to content

Commit d5f6fe7

Browse files
titodalcantonpannaralespxiwhahnitz
authored
Cherry-pick for v2.8.3 (#5128)
* Make pycbc_multi_inspiral way less verbose (#5107) * Make pycbc_multi_inspiral way less verbose * Silence more bank veto logging * Ensure that the PyGRB offsource segmentlist contains ints (#5108) * Ensure that the offsource segmentlist has ints * Cleaner soluziont * Comment * Change recursion parameter in resample (#5113) * Expand multi_inspiral examples and tests (#5114) * Cleanup and simplify examples * Add 170817 cases with 1 and 2 detectors * Handle different detectors in check * Update test suite * PyGRB: handling the 2 IFO case with the coherent search methods (#5115) * PyGRB single IFO case fixes (#5118) * Copy gating information as is when combining trigger files in PyGRB * Missing verb in comment * Apply coinc SNR cut even in single IFO PyGRB runs * Comment update * Comment update * Missing help string * Workaround for git.ligo.org authentication change (#5119) * Workaround for git.ligo.org auth change * Workaround for git.ligo.org auth change * Forgot args * Fix error * Two possible URL schemes * Fix regex * Set version to 2.8.3 * updated for depcreated fillcolor value (#5123) --------- Co-authored-by: Francesco Pannarale <[email protected]> Co-authored-by: Ian Harry <[email protected]> Co-authored-by: Alex Nitz <[email protected]>
1 parent 9c44fd0 commit d5f6fe7

18 files changed

+363
-176
lines changed

bin/pycbc_multi_inspiral

Lines changed: 31 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ with ctx:
624624
if not inj_filter_rejector[ifo].template_segment_checker(
625625
bank, t_num, stilde[ifo]
626626
):
627-
logging.info(
627+
logging.debug(
628628
"Skipping segment %d/%d with template %d/%d as no "
629629
"detectable injection is present",
630630
s_num + 1,
@@ -648,7 +648,11 @@ with ctx:
648648
if not analyse_segment:
649649
continue
650650
logging.info(
651-
"Analyzing segment %d/%d", s_num + 1, len(segments[ifo])
651+
"Analyzing template %d/%d, segment %d/%d",
652+
t_num + 1,
653+
n_bank,
654+
s_num + 1,
655+
len(segments[ifo])
652656
)
653657
# The following dicts with IFOs as keys are created to store
654658
# copies of the matched filtering results computed below.
@@ -664,7 +668,7 @@ with ctx:
664668
# - The list of normalized SNR values at the trigger locations
665669
snr = dict.fromkeys(args.instruments)
666670
for ifo in args.instruments:
667-
logging.info(
671+
logging.debug(
668672
"Filtering template %d/%d, ifo %s", t_num + 1, n_bank, ifo
669673
)
670674
# The following lines unpack and store copies of the matched
@@ -696,10 +700,10 @@ with ctx:
696700

697701
# Loop over (short) time-slides, starting with the zero-lag
698702
for slide in range(num_slides):
699-
logging.info("Analyzing slide %d/%d", slide, num_slides)
703+
logging.debug("Analyzing slide %d/%d", slide, num_slides)
700704
# Loop over sky positions
701705
for position_index in range(len(sky_positions)):
702-
logging.info(
706+
logging.debug(
703707
"Analyzing sky position %d/%d",
704708
position_index + 1,
705709
len(sky_positions),
@@ -741,7 +745,7 @@ with ctx:
741745
args.instruments[0]
742746
]
743747
)
744-
logging.info(
748+
logging.debug(
745749
"Found %d coincident triggers", len(coinc_idx)
746750
)
747751
# Time delay is applied to indices to have them at the IFOs
@@ -753,9 +757,14 @@ with ctx:
753757
% len(snr_dict[ifo])
754758
for ifo in args.instruments
755759
}
756-
# Calculate the coincident and coherent SNR.
757-
# First check there is enough data to compute the SNRs.
758-
if len(coinc_idx) != 0 and nifo > 1:
760+
# Calculate the quadrature sum of individual detector SNRs,
761+
# regardless of how many IFOs are available.
762+
# This accounts for a coherent SNR component and an
763+
# incoherent one. It is referred to as coincident SNR
764+
# throughout the code, even in the single IFO case.
765+
# The calculation is performed only if triggers were
766+
# gathered so far.
767+
if len(coinc_idx) != 0:
759768
# Find coinc SNR at trigger times and apply coinc SNR
760769
# threshold (which depopulates coinc_idx accordingly)
761770
(
@@ -768,32 +777,24 @@ with ctx:
768777
args.coinc_threshold,
769778
time_delay_idx[slide][position_index],
770779
)
771-
logging.info(
780+
logging.debug(
772781
"%d triggers above coincident SNR threshold",
773782
len(coinc_idx),
774783
)
775784
if len(coinc_idx) != 0:
776-
logging.info(
785+
logging.debug(
777786
"With max coincident SNR = %.2f",
778787
max(rho_coinc),
779788
)
780-
# If there is only one IFO, just take its triggers
781-
# and their SNRs
782-
elif len(coinc_idx) != 0 and nifo == 1:
783-
coinc_triggers = {
784-
args.instruments[0]: snr_dict[args.instruments[0]][
785-
coinc_idx_det_frame[args.instruments[0]]
786-
]
787-
}
788789
else:
789790
coinc_triggers = {}
790-
logging.info("No coincident triggers were found")
791+
logging.debug("No coincident triggers were found")
791792
# If there are triggers above coinc threshold and more
792-
# than 2 IFOs, then calculate the coherent statistics for
793+
# than 1 IFO, then calculate the coherent statistics for
793794
# them and apply the cut on coherent SNR (with threshold
794795
# equal to the coinc SNR one)
795-
if len(coinc_idx) != 0 and nifo > 2:
796-
logging.info("Calculating their coherent statistics")
796+
if len(coinc_idx) != 0 and nifo > 1:
797+
logging.debug("Calculating their coherent statistics")
797798
# Plus and cross antenna pattern dictionaries
798799
fp = {
799800
ifo: antenna_pattern[ifo][position_index][0]
@@ -893,12 +894,12 @@ with ctx:
893894
project,
894895
rho_coinc,
895896
)
896-
logging.info(
897+
logging.debug(
897898
"%d triggers above coherent SNR threshold",
898899
len(rho_coh),
899900
)
900901
if len(coinc_idx) != 0:
901-
logging.info(
902+
logging.debug(
902903
"With max coherent SNR = %.2f", max(rho_coh)
903904
)
904905
# Calculate the null SNR and apply the null SNR cut
@@ -918,11 +919,11 @@ with ctx:
918919
snrv=coinc_triggers,
919920
index=coinc_idx,
920921
)
921-
logging.info(
922+
logging.debug(
922923
"%d triggers above null threshold", len(null)
923924
)
924925
if len(coinc_idx) != 0:
925-
logging.info(
926+
logging.debug(
926927
"With max null SNR = %.2f", max(null)
927928
)
928929
# Now calculate the individual detector chi2 values
@@ -967,7 +968,7 @@ with ctx:
967968
chisq, chisq_dof, coherent_ifo_trigs
968969
)
969970
# Calculate chisq reweighted SNR
970-
if nifo > 2:
971+
if nifo > 1:
971972
reweighted_snr = ranking.newsnr(
972973
rho_coh,
973974
network_chisq_dict,
@@ -983,13 +984,6 @@ with ctx:
983984
null_grad=args.null_grad,
984985
null_step=args.null_step,
985986
)
986-
elif nifo == 2:
987-
reweighted_snr = ranking.newsnr(
988-
rho_coinc,
989-
network_chisq_dict,
990-
q=args.chisq_index,
991-
n=args.chisq_nhigh,
992-
)
993987
else:
994988
rho_sngl = abs(
995989
snr_dict[args.instruments[0]][
@@ -1050,11 +1044,9 @@ with ctx:
10501044
ifo_names,
10511045
[ifo_out_vals[n] for n in ifo_names],
10521046
)
1053-
if nifo > 2:
1047+
if nifo > 1:
10541048
network_out_vals['coherent_snr'] = rho_coh
10551049
network_out_vals['null_snr'] = null
1056-
elif nifo == 2:
1057-
network_out_vals['coherent_snr'] = rho_coinc
10581050
else:
10591051
network_out_vals['coherent_snr'] = abs(
10601052
snr_dict[args.instruments[0]][
@@ -1089,7 +1081,7 @@ with ctx:
10891081
cluster_window = int(template.chirp_length * sample_rate)
10901082
# Cluster template events by slide
10911083
for slide in range(num_slides):
1092-
logging.info("Clustering slide %d", slide)
1084+
logging.debug("Clustering slide %d", slide)
10931085
event_mgr.cluster_template_network_events(
10941086
'time_index', 'reweighted_snr', cluster_window, slide=slide
10951087
)

bin/pygrb/pycbc_grb_trig_combiner

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def merge_hdf5_files(inputfiles, outputfile, verbose=False, **compression_kw):
137137
all_event_id_names = sngl_event_id_names + network_event_id_names
138138

139139
# handle search datasets as a special case
140-
# (they will the same in all files)
140+
# (they will be the same in all files)
141141
search_datasets = set(filter(lambda x: "/search/" in x, dataset_names))
142142
gating_datasets = set(filter(lambda x: "/gating/" in x, dataset_names))
143143
once_only_datasets = search_datasets.union(gating_datasets)
Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,46 @@
11
#!/usr/bin/env python
2+
23
# Read a pycbc_multi_inspiral HDF5 trigger file and check that it contains
3-
# triggers compatible with mock GW170817-like injections
4+
# triggers compatible with GW170817
45
# 2022 Andrew Williamson, Tito Dal Canton
56

67
import sys
78
import logging
89
import h5py
9-
from pycbc import init_logging
1010

11-
init_logging(True)
12-
gw170817_time = 1187008882.43
13-
status = 0
11+
1412
with h5py.File('GW170817_test_output.hdf', 'r') as f:
15-
snrs = [
16-
f['network/end_time_gc'][:],
17-
f['network/coherent_snr'][:],
18-
f['network/reweighted_snr'][:],
19-
f['network/slide_id'][:]]
20-
# search for compatible trigs
21-
mask = (
22-
(abs(gw170817_time - snrs[0]) < 0.1)
23-
& (snrs[1] > 25)
24-
& (snrs[2] > 25)
25-
& (snrs[3] == 0)
13+
end_time = f['network/end_time_gc'][:]
14+
coh_snr = f['network/coherent_snr'][:]
15+
rw_snr = f['network/reweighted_snr'][:]
16+
slide_id = f['network/slide_id'][:]
17+
present_detectors = ''.join(
18+
d for d in 'HLV' if f'{d}1' in f.keys()
2619
)
20+
21+
# basic sanity checks
22+
assert (end_time > 0).all()
23+
assert (coh_snr > 0).all()
24+
assert (rw_snr > 0).all()
25+
26+
# search for trigs compatible with GW170817
27+
expected_time = 1187008882.43
28+
required_net_snr = {'H': 17, 'HL': 28, 'HLV': 28}
29+
mask = (
30+
(abs(expected_time - end_time) < 0.1)
31+
& (coh_snr > required_net_snr[present_detectors])
32+
& (rw_snr > required_net_snr[present_detectors])
33+
& (slide_id == 0)
34+
)
2735
n = mask.sum()
2836
if n > 0:
29-
result = 'PASS'
37+
print(
38+
f'PASS: GW170817 found with max coherent SNR {max(coh_snr[mask]):.2f}, '
39+
f'max reweighted SNR {max(rw_snr[mask]):.2f}'
40+
)
3041
status = 0
3142
else:
32-
result = 'FAIL'
43+
print('FAIL: GW170817 not found')
3344
status = 1
34-
logging.info(
35-
'%s: GW170817 found with coherent SNR = %.2f; reweighted SNR %.2f', result,
36-
snrs[1][mask], snrs[2][mask])
45+
3746
sys.exit(status)

examples/multi_inspiral/clean.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
rm -f bank_veto_bank.xml *.hdf *.gwf
1+
rm -f bank_veto_bank.xml *.hdf

examples/multi_inspiral/faceon_faceaway.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ PAD=8
3232
BANK_FILE=gw170817_single_template.hdf
3333
BANK_VETO_FILE=bank_veto_bank.xml
3434
CHANNEL=SIMULATED_GW170817
35-
RA=5.016076270234897
36-
DEC=-0.408407044967
35+
RA="5.016076270234897 rad"
36+
DEC="-0.408407044967 rad"
3737

3838
echo -e "\\n\\n>> [`date`] Getting template bank"
3939
wget -nv -nc ${CONFIG_URL}/${BANK_FILE}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
CONFIG_URL=https://github.com/gwastro/pycbc-config/raw/master/test/multi_inspiral
6+
BANK_FILE=gw170817_single_template.hdf
7+
echo -e "\\n\\n>> [`date`] Getting template bank"
8+
wget -nv -nc ${CONFIG_URL}/${BANK_FILE}
9+
10+
EVENT=1187008882
11+
PAD=8
12+
START_PAD=111
13+
END_PAD=17
14+
GPS_START=$((EVENT - 192 - PAD))
15+
GPS_END=$((EVENT + 192 + PAD))
16+
TRIG_START=$((GPS_START + START_PAD))
17+
TRIG_END=$((GPS_END - END_PAD))
18+
OUTPUT=GW170817_test_output.hdf
19+
20+
echo -e "\\n\\n>> [`date`] Running pycbc_multi_inspiral on GW170817 data"
21+
pycbc_multi_inspiral \
22+
--verbose \
23+
--projection left+right \
24+
--instruments H1 \
25+
--channel-name H1:GWOSC-16KHZ_R1_STRAIN \
26+
--frame-type H1:GWOSC \
27+
--trigger-time ${EVENT} \
28+
--gps-start-time ${GPS_START} \
29+
--gps-end-time ${GPS_END} \
30+
--trig-start-time ${TRIG_START} \
31+
--trig-end-time ${TRIG_END} \
32+
--ra '3.44527994344 rad' \
33+
--dec '-0.408407044967 rad' \
34+
--bank-file ${BANK_FILE} \
35+
--approximant IMRPhenomD \
36+
--order -1 \
37+
--low-frequency-cutoff 30 \
38+
--sngl-snr-threshold 3.0 \
39+
--chisq-bins "0.9*get_freq('fSEOBNRv4Peak',params.mass1,params.mass2,params.spin1z,params.spin2z)**(2./3.)" \
40+
--pad-data 8 \
41+
--strain-high-pass 25 \
42+
--sample-rate 4096 \
43+
--autogating-threshold 100 \
44+
--autogating-cluster 0.5 \
45+
--autogating-width 0.25 \
46+
--autogating-taper 0.25 \
47+
--autogating-pad 0 \
48+
--cluster-method window \
49+
--cluster-window 0.1 \
50+
--segment-length 256 \
51+
--segment-start-pad ${START_PAD} \
52+
--segment-end-pad ${END_PAD} \
53+
--psd-estimation median \
54+
--psd-segment-length 32 \
55+
--psd-segment-stride 8 \
56+
--psd-num-segments 29 \
57+
--do-shortslides \
58+
--slide-shift 1 \
59+
--output ${OUTPUT}
60+
61+
echo -e "\\n\\n>> [`date`] Checking output files"
62+
python check_gw170817_trigs.py

0 commit comments

Comments
 (0)