diff --git a/gstlal-inspiral/python/stats/inspiral_extrinsics.py b/gstlal-inspiral/python/stats/inspiral_extrinsics.py index 6b335746399925ee4d78c407e1d6ebea42811298..b8dff593fbda7251fe5bcc3a0629b62da9b7b6b5 100644 --- a/gstlal-inspiral/python/stats/inspiral_extrinsics.py +++ b/gstlal-inspiral/python/stats/inspiral_extrinsics.py @@ -1168,7 +1168,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, instruments = ("H1", "L1", "V1", "K1"), 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): + def __init__(self, instruments = ("H1", "L1", "V1", "K1"), 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 @@ -1252,7 +1252,7 @@ class TimePhaseSNR(object): self.tree_data = tree_data self.margsky = margsky - self.snr = snr + self.snr = SNR self.psd_fname = psd_fname if self.tree_data is None: @@ -1306,14 +1306,14 @@ class TimePhaseSNR(object): h5_transpp = f.create_group("transpp") h5_transdd = f.create_group("transdd") h5_norm = f.create_group("norm") - h5_snr = f.create_group("SNR") for group, mat in zip((h5_transtt, h5_transtp, h5_transpt, h5_transpp, h5_transdd, h5_norm), (self.transtt, self.transtp, self.transpt, self.transpp, self.transdd, self.norm)): for k,v in mat.items(): group.create_dataset(",".join(sorted(k)), data = float(v)) - f.create_dataset("psd", (1,), data=self.psd_fname) - for ifo, v in self.snr.items(): - h5_snr.create_dataset(",".join(sorted(ifo)), data=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() @@ -1330,9 +1330,6 @@ class TimePhaseSNR(object): transpp = dict((frozenset(k.split(",")), numpy.array(f["transpp"][k])) for k in f["transpp"]) transdd = dict((frozenset(k.split(",")), numpy.array(f["transdd"][k])) for k in f["transdd"]) norm = dict((frozenset(k.split(",")), numpy.array(f["norm"][k])) for k in f["norm"]) - snr = dict((frozenset(k.split(",")), numpy.array(f["SNR"][k][:])) for k in f["SNR"]) - - psd_fname = f["psd"][0] try: dgrp = f["gstlal_extparams"] @@ -1357,7 +1354,7 @@ class TimePhaseSNR(object): margsky[combo] += numpy.array(dgrp["marg"][key]) f.close() - return cls(instruments = instruments, transtt = transtt, transtp = transtp, transpt = transpt, transpp = transpp, transdd = transdd, norm = norm, tree_data = tree_data, margsky = margsky, snr = snr, psd_fname = psd_fname, **kwargs) + return cls(instruments = instruments, transtt = transtt, transtp = transtp, transpt = transpt, transpp = transpp, transdd = transdd, norm = norm, tree_data = tree_data, margsky = margsky, **kwargs) @property def combos(self): @@ -1462,7 +1459,7 @@ class TimePhaseSNR(object): # order is dt, dphi and effective distance ratio for each combination # NOTE the instruments argument here really needs to come from calling instrument_pairs() if hasattr(list(time.values())[0], "__iter__"): - outlen = len(list(time.values())[0]) + outlen = len(time.values()[0]) else: outlen =1 out = numpy.zeros((outlen, 1 + max(sum(slices.values(),[]))), dtype="float32")