Skip to content

Commit

Permalink
add ability to cache detect response to marginalize time model and us…
Browse files Browse the repository at this point in the history
…e alternate sampler rate than data
  • Loading branch information
ahnitz committed Jul 2, 2024
1 parent d993ca1 commit 01bc4ae
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions pycbc/inference/models/marginalized_gaussian_noise.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"""

import itertools
import logging
import numpy
from scipy import special

Expand Down Expand Up @@ -207,6 +208,7 @@ class MarginalizedTime(DistMarg, BaseGaussianNoise):
def __init__(self, variable_params,
data, low_frequency_cutoff, psds=None,
high_frequency_cutoff=None, normalize=False,
sample_rate=None,
**kwargs):

self.kwargs = kwargs
Expand Down Expand Up @@ -240,6 +242,13 @@ def __init__(self, variable_params,
gates=self.gates, **kwargs['static_params'])

self.dets = {}

if sample_rate is not None:
logging.info("Using %s sample rate for marginalization", sample_rate)
for det in self._whitened_data:
tlen = int(round(float(sample_rate) * self.whitened_data[det].duration))
flen = tlen // 2 + 1
self._whitened_data[det].resize(flen)

def _nowaveform_loglr(self):
"""Convenience function to set loglr values if no waveform generated.
Expand Down Expand Up @@ -325,15 +334,20 @@ def _loglr(self):
for det in wfs:
if det not in self.dets:
self.dets[det] = Detector(det)
fp, fc = self.dets[det].antenna_pattern(
params['ra'],
params['dec'],
params['polarization'],
params['tc'])
dt = self.dets[det].time_delay_from_earth_center(params['ra'],
params['dec'],
params['tc'])

if self.precalc_antenna_factors:
fp, fc, dt = self.get_precalc_antenna_factors(det)
else:
fp, fc = self.dets[det].antenna_pattern(
params['ra'],
params['dec'],
params['polarization'],
params['tc'])
dt = self.dets[det].time_delay_from_earth_center(params['ra'],
params['dec'],
params['tc'])
dtc = params['tc'] + dt

cplx_hd = fp * cplx_hpd[det].at_time(dtc,
interpolate='quadratic')
cplx_hd += fc * cplx_hcd[det].at_time(dtc,
Expand Down

0 comments on commit 01bc4ae

Please sign in to comment.