From 941b15f9bff15b366fce9dc2588761b33367e4c9 Mon Sep 17 00:00:00 2001 From: Gareth S Cabourn Davies Date: Wed, 23 Oct 2024 09:43:07 +0100 Subject: [PATCH] Make things qork in the case that no foreground is present (#4908) --- bin/all_sky_search/pycbc_coinc_statmap | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bin/all_sky_search/pycbc_coinc_statmap b/bin/all_sky_search/pycbc_coinc_statmap index a0ff2eabcbf..12d2f3fcc6b 100755 --- a/bin/all_sky_search/pycbc_coinc_statmap +++ b/bin/all_sky_search/pycbc_coinc_statmap @@ -291,9 +291,9 @@ if fore_locs.sum() > 0: f['foreground/ifar_exc'] = conv.sec_to_year(ifar_exc) f['foreground/fap_exc'] = fap_exc else: - f['foreground/ifar'] = numpy.array([]) + f['foreground/ifar'] = ifar = numpy.array([]) f['foreground/fap'] = numpy.array([]) - f['foreground/ifar_exc'] = numpy.array([]) + f['foreground/ifar_exc'] = ifar_exc = numpy.array([]) f['foreground/fap_exc'] = numpy.array([]) if 'name' in all_trigs.attrs: @@ -331,6 +331,10 @@ else : # will happen when ifar_foreground has no elements greater than # the background time. +# This is a workaround for the case that we have no foreground, so that the +# while loop comparison doesnt fail straight away +ifar_foreground = numpy.append(ifar_foreground, 0) + while numpy.any(ifar_foreground >= background_time): # If the user wants to stop doing hierarchical removals after a set # number of iterations then break when that happens.