From 620648794b36927fa9f28832d741d9cf282c3d0d Mon Sep 17 00:00:00 2001
From: Leo Tsukada <leo.tsukada@ligo.org>
Date: Thu, 8 Aug 2019 00:10:27 -0700
Subject: [PATCH] inspiral_extrinsics.py : changed to pass snr dictioary and
 psd file name to the output .h5 file

---
 gstlal-inspiral/python/stats/inspiral_extrinsics.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/gstlal-inspiral/python/stats/inspiral_extrinsics.py b/gstlal-inspiral/python/stats/inspiral_extrinsics.py
index 74b8568498..50fd106c06 100644
--- a/gstlal-inspiral/python/stats/inspiral_extrinsics.py
+++ b/gstlal-inspiral/python/stats/inspiral_extrinsics.py
@@ -1187,7 +1187,7 @@ class TimePhaseSNR(object):
 	locations = {"H1":lal.CachedDetectors[lal.LHO_4K_DETECTOR].location, "L1":lal.CachedDetectors[lal.LLO_4K_DETECTOR].location, "V1":lal.CachedDetectors[lal.VIRGO_DETECTOR].location, "K1":lal.CachedDetectors[lal.KAGRA_DETECTOR].location}
 	numchunks = 20
 
-	def __init__(self, transtt = None, transtp = None, transpt = None, transpp = None, transdd = None, norm = None, tree_data = None, margsky = None, verbose = False, margstart = 0, margstop = None):
+	def __init__(self, transtt = None, transtp = None, transpt = None, transpp = None, transdd = None, norm = None, tree_data = None, margsky = None, verbose = False, margstart = 0, margstop = None, SNR=None, psd_fname=None):
 		"""
 		Initialize a new class from scratch via explicit computation
 		of the tree data and marginalized probability distributions or by providing
@@ -1270,7 +1270,10 @@ class TimePhaseSNR(object):
 		self.tree_data = tree_data
 		self.margsky = margsky
 
-		if self.tree_data is None or numpy.shape(self.tree_data)[1] != 1 + max(sum(self.slices.values(),[])):
+		self.snr = SNR
+		self.psd_fname = psd_fname
+
+		if self.tree_data is None:
 			time, phase, deff = TimePhaseSNR.tile(verbose = verbose)
 			self.tree_data = self.dtdphideffpoints(time, phase, deff, self.slices)
 
@@ -1325,6 +1328,11 @@ class TimePhaseSNR(object):
 			for k,v in mat.items():
 				group.create_dataset(",".join(sorted(k)), data = float(v))
 
+		f.create_dataset("psd", data=self.psd_fname)
+		h5_snr = f.create_group("SNR")
+		for ifo in self.snr:
+			h5_snr.create_dataset(ifo, data=self.snr[ifo].value)
+
 		f.close()
 
 	@staticmethod
-- 
GitLab