-
Notifications
You must be signed in to change notification settings - Fork 347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add ability to cache detector response to marginalize time model and us… #4806
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
""" | ||
|
||
import itertools | ||
import logging | ||
import numpy | ||
from scipy import special | ||
|
||
|
@@ -207,8 +208,10 @@ class MarginalizedTime(DistMarg, BaseGaussianNoise): | |
def __init__(self, variable_params, | ||
data, low_frequency_cutoff, psds=None, | ||
high_frequency_cutoff=None, normalize=False, | ||
sample_rate=None, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the advantage of doing this instead of just increasing the sample rate of the data? Also, this might need some documentation, or maybe change the name of the argument to make it clearer what it is. People are going to think this is the data sample rate otherwise. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Increasing the sample rate of the data means that you need to do data conditioning and parts of the generation at a higher sample rate. That's only useful if you actually care about the frequency band at higher frequencies. If you just need better timing resolution that would be extremely slow and memory intensive. I think the separation is clear as the data sample rate is in the data section. This is only about the model itself. BTW, we already have this distinction for the heterodyne likelihoods when doing sky marginalization. This was just advancing the same interface / feature to the more regular model |
||
**kwargs): | ||
|
||
self.sample_rate = float(sample_rate) | ||
self.kwargs = kwargs | ||
variable_params, kwargs = self.setup_marginalization( | ||
variable_params, | ||
|
@@ -241,6 +244,14 @@ def __init__(self, variable_params, | |
|
||
self.dets = {} | ||
|
||
if sample_rate is not None: | ||
for ifo in self.data: | ||
if self.sample_rate < self.data[ifo].sample_rate: | ||
raise ValueError("Model sample rate was set less than the" | ||
" data. ") | ||
logging.info("Using %s sample rate for marginalization", | ||
sample_rate) | ||
|
||
def _nowaveform_loglr(self): | ||
"""Convenience function to set loglr values if no waveform generated. | ||
""" | ||
|
@@ -296,8 +307,15 @@ def _loglr(self): | |
hp[self._kmin[det]:kmax] *= self._weight[det][slc] | ||
hc[self._kmin[det]:kmax] *= self._weight[det][slc] | ||
|
||
hp.resize(len(self._whitened_data[det])) | ||
hc.resize(len(self._whitened_data[det])) | ||
# Use a higher sample rate if requested | ||
if self.sample_rate is not None: | ||
tlen = int(round(self.sample_rate * | ||
self.whitened_data[det].duration)) | ||
flen = tlen // 2 + 1 | ||
hp.resize(flen) | ||
hc.resize(flen) | ||
self._whitened_data[det].resize(flen) | ||
|
||
cplx_hpd[det], _, _ = matched_filter_core( | ||
hp, | ||
self._whitened_data[det], | ||
|
@@ -325,15 +343,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: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's already handled by the marginalization parent class. The features were implemented first for other cases, and this just extends the use to the marginalized time model. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, but I was asking how you set that in the config file and how that's passed to the model initialization. I couldn't figure it out from looking at the code, although I didn't dig too deep. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, it's automatically populated if you do sky marginalization so it's the same set of settings really. These factors are calculated in any case when the sky grid is set up. |
||
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, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the example to make explicit use of this feature.