From 8b6d034ca2fc401b705152df637c0bf07e7056b2 Mon Sep 17 00:00:00 2001 From: Chad Hanna <chad.hanna@ligo.org> Date: Tue, 19 Jun 2018 08:33:48 -0700 Subject: [PATCH] gstlal_svd_bank: cleanup writing the psd --- gstlal-inspiral/bin/gstlal_svd_bank | 3 +-- gstlal-inspiral/python/svd_bank.py | 12 +++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/gstlal-inspiral/bin/gstlal_svd_bank b/gstlal-inspiral/bin/gstlal_svd_bank index 0d01e87dac..b654dad966 100755 --- a/gstlal-inspiral/bin/gstlal_svd_bank +++ b/gstlal-inspiral/bin/gstlal_svd_bank @@ -148,6 +148,5 @@ svd_bank.write_bank( contenthandler = svd_bank.DefaultContentHandler ) for (template_bank, bank_id) in zip(options.template_bank, options.bank_id)], options.clipleft, - options.clipright, - write_psd = True + options.clipright ) diff --git a/gstlal-inspiral/python/svd_bank.py b/gstlal-inspiral/python/svd_bank.py index a55af69f6f..2d295183f6 100644 --- a/gstlal-inspiral/python/svd_bank.py +++ b/gstlal-inspiral/python/svd_bank.py @@ -259,7 +259,7 @@ def build_bank(template_bank_url, psd, flow, ortho_gate_fap, snr_threshold, svd_ return bank -def write_bank(filename, banks, cliplefts = None, cliprights = None, write_psd = False, verbose = False): +def write_bank(filename, banks, cliplefts = None, cliprights = None, verbose = False): """Write SVD banks to a LIGO_LW xml file.""" # Create new document @@ -333,8 +333,7 @@ def write_bank(filename, banks, cliplefts = None, cliprights = None, write_psd = # put a copy of the processed PSD file in # FIXME in principle this could be different for each bank included in # this file, but we only put one here - if write_psd: - lal.series.make_psd_xmldoc({bank.sngl_inspiral_table[0].ifo: bank.processed_psd}, lw) + lal.series.make_psd_xmldoc({bank.sngl_inspiral_table[0].ifo: bank.processed_psd}, lw) # Write to file ligolw_utils.write_filename(xmldoc, filename, gz = filename.endswith('.gz'), verbose = verbose) @@ -348,6 +347,10 @@ def read_banks(filename, contenthandler, verbose = False): banks = [] + # FIXME in principle this could be different for each bank included in + # this file, but we only put one in the file for now + psd = lal.series.read_psd_xmldoc(xmldoc) + for root in (elem for elem in xmldoc.getElementsByTagName(ligolw.LIGO_LW.tagName) if elem.hasAttribute(u"Name") and elem.Name == "gstlal_svd_bank_Bank"): # Create new SVD bank object @@ -370,6 +373,9 @@ def read_banks(filename, contenthandler, verbose = False): bank.autocorrelation_mask = ligolw_array.get_array(root, 'autocorrelation_mask').array bank.sigmasq = ligolw_array.get_array(root, 'sigmasq').array + # attach a reference to the psd + bank.psd = psd + # Read bank fragments bank.bank_fragments = [] for el in (node for node in root.childNodes if node.tagName == ligolw.LIGO_LW.tagName): -- GitLab