Skip to content
Snippets Groups Projects

MAINT: Separate adding SNRs per IFO to a sample into a new function

All threads resolved!
2 files
+ 3
41
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -9,12 +9,10 @@ from scipy.special import logsumexp
from ...core.likelihood import Likelihood
from ...core.utils import logger, UnsortedInterp2d, create_time_series
from ...core.prior import Interped, Prior, Uniform, DeltaFunction
from ..detector import InterferometerList, get_empty_interferometer, calibration, Interferometer
from ..detector import InterferometerList, get_empty_interferometer, calibration
from ..prior import BBHPriorDict, Cosmological
from ..utils import noise_weighted_inner_product, zenith_azimuth_to_ra_dec, ln_i0
from typing import Any
class GravitationalWaveTransient(Likelihood):
""" A gravitational-wave transient likelihood object
@@ -1144,34 +1142,3 @@ class GravitationalWaveTransient(Likelihood):
reference_frame=self._reference_frame_str,
lal_version=self.lal_version,
lalsimulation_version=self.lalsimulation_version)
def add_interferometer_snrs_to_sample(
ifo : Interferometer,
ifo_index : int,
new_samples : list,
sample : Any
) -> None:
"""For use in gw.conversion.compute_snrs().
Attached here so alternate likelihoods may implement their own method.
Parameters
==========
ifo : bilby.gw.interferometer.Interferometer
The interferometer object for which to compute SNRs
ifo_index : int
The index of the IFO within likelihood.interferometers, for indexing of new_samples
new_samples : list
The output of _compute_snrs which contains SNRs
sample : Any
The sample from the posterior for which SNRs are being computed
"""
matched_filter_snrs = list()
optimal_snrs = list()
mf_key = f'{ifo.name}_matched_filter_snr'
optimal_key = f'{ifo.name}_optimal_snr'
for new_sample in new_samples:
matched_filter_snrs.append(new_sample[ifo_index].complex_matched_filter_snr)
optimal_snrs.append(new_sample[ifo_index].optimal_snr_squared.real ** 0.5)
sample[mf_key] = matched_filter_snrs
sample[optimal_key] = optimal_snrs
Loading