32 from scipy.interpolate
import PPoly
37 from lal.rate
import IrregularBins
39 def __init__(self, c, x):
44 def __call__(self, x):
46 return numpy.poly1d(self.
coeffs[:,i].squeeze())(x - self.
x0[i]),
49 from gstlal
import stats
as gstlalstats
56 from gstlal
import paths
as gstlal_config_paths
60 "UniformInTemplatePopulationModel",
61 "SourcePopulationModel"
81 Assumes uniform in template population model, no
87 @gstlalstats.assert_ln_probability
88 def lnP_template_signal(self, template_id, snr):
109 Sets the polynomial coefficients, given the template ID and
110 SNR for a source population model, from which lnP is then
111 computed using PPoly.
113 if filename
is not None:
114 with h5py.File(filename,
'r') as model:
115 coefficients = model['coefficients'][()]
116 snr_bp = model[
'SNR'][()]
118 model_ids = model[
'template_id'][()]
122 model_ids = model[
'event_id'][()]
131 template_indices = {}
132 for template_id
in template_ids:
136 template_indices[template_id] = numpy.where(model_ids==template_id)[0][0]
138 raise IndexError(
"template ID %d is not in this model".format(template_id))
139 self.
polys = dict((template_id,
PPoly(coefficients[:,:,[template_indices[template_id]]], snr_bp))
for template_id
in template_ids)
145 @gstlalstats.assert_ln_probability
146 def lnP_template_signal(self, template_id, snr):
149 lnP_vs_snr = self.
polys[template_id]
151 raise KeyError(
"template ID %d is not in this model".format(template_id))
154 return lnP_vs_snr(min(snr, self.
max_snr))[0]