Skip to content
Snippets Groups Projects

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

All threads resolved!
2 files
+ 31
15
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -13,6 +13,10 @@ 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 TYPE_CHECKING, Any
if TYPE_CHECKING:
from bilby.gw.detector.interferometer import Interferometer
class GravitationalWaveTransient(Likelihood):
""" A gravitational-wave transient likelihood object
@@ -1129,3 +1133,28 @@ 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(). Attaches method to likelihood 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 = '{}_matched_filter_snr'.format(ifo.name)
optimal_key = '{}_optimal_snr'.format(ifo.name)
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
\ No newline at end of file
Loading