Skip to content
Snippets Groups Projects
Commit d3c210f9 authored by Ryan Magee's avatar Ryan Magee Committed by Patrick Godwin
Browse files

stats/inspiral_extrinsics.py: pass psd file and initial snr ratios through...

stats/inspiral_extrinsics.py: pass psd file and initial snr ratios through correctly. Previously failed because it was required but not initialized when read from h5
parent b41179d0
No related branches found
No related tags found
1 merge request!58dtdphi dag fixes
......@@ -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", 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.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.close()
......@@ -1330,6 +1330,9 @@ 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"]
......@@ -1354,7 +1357,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, **kwargs)
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)
@property
def combos(self):
......@@ -1459,7 +1462,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(time.values()[0])
outlen = len(list(time.values())[0])
else:
outlen =1
out = numpy.zeros((outlen, 1 + max(sum(slices.values(),[]))), dtype="float32")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment