Skip to content
Snippets Groups Projects
Commit 13f4c77d authored by Rhiannon Udall's avatar Rhiannon Udall Committed by Colm Talbot
Browse files

ENH: Add template-template inner product to Interferometer

parent a90aaaa2
No related branches found
No related tags found
1 merge request!1345ENH: Add template-template inner product to Interferometer
Pipeline #645849 passed
......@@ -597,6 +597,26 @@ class Interferometer(object):
power_spectral_density=self.power_spectral_density_array[self.strain_data.frequency_mask],
duration=self.strain_data.duration)
def template_template_inner_product(self, signal_1, signal_2):
"""A noise weighted inner product between two templates, using this ifo's PSD.
Parameters
==========
signal_1 : array_like
An array containing the first signal
signal_2 : array_like
an array containing the second signal
Returns
=======
float: The noise weighted inner product of the two templates
"""
return gwutils.noise_weighted_inner_product(
aa=signal_1[self.strain_data.frequency_mask],
bb=signal_2[self.strain_data.frequency_mask],
power_spectral_density=self.power_spectral_density_array[self.strain_data.frequency_mask],
duration=self.strain_data.duration)
def matched_filter_snr(self, signal):
"""
......
......@@ -321,6 +321,18 @@ class TestInterferometer(unittest.TestCase):
self.assertTrue(np.array_equal(expected[2], actual[2]))
self.assertEqual(expected[3], actual[3])
def test_template_template_inner_product(self):
signal_1 = np.ones_like(self.ifo.power_spectral_density_array)
signal_2 = np.ones_like(self.ifo.power_spectral_density_array) * 2
signal_1_optimal = self.ifo.optimal_snr_squared(signal=signal_1)
signal_1_optimal_by_template_template = self.ifo.template_template_inner_product(
signal_1=signal_1,
signal_2=signal_1
)
self.assertTrue(np.array_equal(signal_1_optimal, signal_1_optimal_by_template_template))
signal_1_signal_2_inner_product = self.ifo.template_template_inner_product(signal_1=signal_1, signal_2=signal_2)
self.assertTrue(np.array_equal(signal_1_optimal * 2, signal_1_signal_2_inner_product))
def test_repr(self):
expected = (
"Interferometer(name='{}', power_spectral_density={}, minimum_frequency={}, "
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment