From 8634b6f696793213d631c5e026901acc3c10486c Mon Sep 17 00:00:00 2001 From: Ann-Kristin Malz <77342869+akjm99@users.noreply.github.com> Date: Fri, 24 Jan 2025 07:19:05 -0800 Subject: [PATCH 01/11] TST: change all likelihood and waveform tests to use more recent waveforms --- test/gw/likelihood/marginalization_test.py | 12 ++-- test/gw/likelihood_test.py | 60 +++++++++---------- test/gw/plot_test.py | 2 +- test/gw/result_test.py | 2 +- test/gw/source_test.py | 16 ++--- test/gw/utils_test.py | 2 +- test/integration/make_standard_data.py | 2 +- .../integration/sample_from_the_prior_test.py | 2 +- test/integration/test_waveforms.py | 16 ++--- 9 files changed, 57 insertions(+), 57 deletions(-) diff --git a/test/gw/likelihood/marginalization_test.py b/test/gw/likelihood/marginalization_test.py index d5b1d4004..9ac61bb13 100644 --- a/test/gw/likelihood/marginalization_test.py +++ b/test/gw/likelihood/marginalization_test.py @@ -216,7 +216,7 @@ def setUp(self): waveform_arguments=dict( reference_frequency=20.0, minimum_frequency=20.0, - waveform_approximant="IMRPhenomPv2", + waveform_approximant="IMRPhenomXPHM", ) ) self.interferometers.inject_signal( @@ -231,8 +231,8 @@ def setUp(self): trial_roq_paths = [ "/roq_basis", - os.path.join(os.path.expanduser("~"), "ROQ_data/IMRPhenomPv2/4s"), - "/home/cbc/ROQ_data/IMRPhenomPv2/4s", + os.path.join(os.path.expanduser("~"), "ROQ_data/IMRPhenomXPHM/4s"), + "/home/cbc/ROQ_data/IMRPhenomXPHM/4s", ] roq_dir = None for path in trial_roq_paths: @@ -249,7 +249,7 @@ def setUp(self): start_time=1126259640, waveform_arguments=dict( reference_frequency=20.0, - waveform_approximant="IMRPhenomPv2", + waveform_approximant="IMRPhenomXPHM", frequency_nodes_linear=np.load(f"{roq_dir}/fnodes_linear.npy"), frequency_nodes_quadratic=np.load(f"{roq_dir}/fnodes_quadratic.npy"), ) @@ -265,7 +265,7 @@ def setUp(self): waveform_arguments=dict( reference_frequency=20.0, minimum_frequency=20.0, - waveform_approximant="IMRPhenomPv2", + waveform_approximant="IMRPhenomXPHM", ) ) @@ -276,7 +276,7 @@ def setUp(self): start_time=1126259640, waveform_arguments=dict( reference_frequency=20.0, - waveform_approximant="IMRPhenomPv2", + waveform_approximant="IMRPhenomXPHM", ) ) diff --git a/test/gw/likelihood_test.py b/test/gw/likelihood_test.py index 84298e1d9..67f7698de 100644 --- a/test/gw/likelihood_test.py +++ b/test/gw/likelihood_test.py @@ -283,8 +283,8 @@ def setUp(self): # Possible locations for the ROQ: in the docker image, local, or on CIT trial_roq_paths = [ "/roq_basis", - os.path.join(os.path.expanduser("~"), "ROQ_data/IMRPhenomPv2/4s"), - "/home/cbc/ROQ_data/IMRPhenomPv2/4s", + os.path.join(os.path.expanduser("~"), "ROQ_data/IMRPhenomXPHM/4s"), + "/home/cbc/ROQ_data/IMRPhenomXPHM/4s", ] roq_dir = None for path in trial_roq_paths: @@ -331,7 +331,7 @@ def setUp(self): self.priors = bilby.gw.prior.BBHPriorDict() self.priors.pop("mass_1") self.priors.pop("mass_2") - # Testing is done with the 4s IMRPhenomPV2 ROQ basis + # Testing is done with the 4s IMRPhenomXPHM ROQ basis self.priors["chirp_mass"] = bilby.core.prior.Uniform(12.299703, 45) self.priors["mass_ratio"] = bilby.core.prior.Uniform(0.125, 1) self.priors["geocent_time"] = bilby.core.prior.Uniform(1.19, 1.21) @@ -343,7 +343,7 @@ def setUp(self): waveform_arguments=dict( reference_frequency=20.0, minimum_frequency=20.0, - waveform_approximant="IMRPhenomPv2", + waveform_approximant="IMRPhenomXPHM", ), ) @@ -361,7 +361,7 @@ def setUp(self): frequency_nodes_linear=fnodes_linear, frequency_nodes_quadratic=fnodes_quadratic, reference_frequency=20.0, - waveform_approximant="IMRPhenomPv2", + waveform_approximant="IMRPhenomXPHM", ), ) @@ -546,8 +546,8 @@ def test_rescaling(self): # Possible locations for the ROQ: in the docker image, local, or on CIT trial_roq_paths = [ "/roq_basis", - os.path.join(os.path.expanduser("~"), "ROQ_data/IMRPhenomPv2/4s"), - "/home/cbc/ROQ_data/IMRPhenomPv2/4s", + os.path.join(os.path.expanduser("~"), "ROQ_data/IMRPhenomXPHM/4s"), + "/home/cbc/ROQ_data/IMRPhenomXPHM/4s", ] roq_dir = None for path in trial_roq_paths: @@ -583,7 +583,7 @@ def test_rescaling(self): self.priors = bilby.gw.prior.BBHPriorDict() self.priors.pop("mass_1") self.priors.pop("mass_2") - # Testing is done with the 4s IMRPhenomPV2 ROQ basis + # Testing is done with the 4s IMRPhenomXPHM ROQ basis self.priors["chirp_mass"] = bilby.core.prior.Uniform( 12.299703 / scale_factor, 45 / scale_factor ) @@ -598,7 +598,7 @@ def test_rescaling(self): frequency_nodes_linear=fnodes_linear, frequency_nodes_quadratic=fnodes_quadratic, reference_frequency=20.0, - waveform_approximant="IMRPhenomPv2", + waveform_approximant="IMRPhenomXPHM", ), ) @@ -631,7 +631,7 @@ def setUp(self): self.sampling_frequency = 2048 self.duration = 16 self.reference_frequency = 20.0 - self.waveform_approximant = "IMRPhenomD" + self.waveform_approximant = "IMRPhenomXAS" # The SNRs of injections are 130-160 for roq_scale_factor=1 and 70-80 for roq_scale_factor=2 self.injection_parameters = dict( mass_ratio=0.8, @@ -942,7 +942,7 @@ def test_from_hdf5(self, basis_linear, basis_quadratic): duration = 16 geocent_time = 1.2 reference_frequency = 20.0 - waveform_approximant = "IMRPhenomD" + waveform_approximant = "IMRPhenomXAS" mc_range = [8, 14] priors = bilby.gw.prior.BBHPriorDict() @@ -980,8 +980,8 @@ def test_from_npy(self, from_array): # Possible locations for the ROQ: in the docker image, local, or on CIT trial_roq_paths = [ "/roq_basis", - os.path.join(os.path.expanduser("~"), "ROQ_data/IMRPhenomPv2/4s"), - "/home/cbc/ROQ_data/IMRPhenomPv2/4s", + os.path.join(os.path.expanduser("~"), "ROQ_data/IMRPhenomXPHM/4s"), + "/home/cbc/ROQ_data/IMRPhenomXPHM/4s", ] roq_dir = None for path in trial_roq_paths: @@ -1006,7 +1006,7 @@ def test_from_npy(self, from_array): duration = 4 geocent_time = 1.2 reference_frequency = 20.0 - waveform_approximant = "IMRPhenomPv2" + waveform_approximant = "IMRPhenomXPHM" mc_range = [12.299703, 45] priors = bilby.gw.prior.BBHPriorDict() @@ -1132,8 +1132,8 @@ def create_likelihood_single_basis(self): # Possible locations for the ROQ: in the docker image, local, or on CIT trial_roq_paths = [ "/roq_basis", - os.path.join(os.path.expanduser("~"), "ROQ_data/IMRPhenomPv2/4s"), - "/home/cbc/ROQ_data/IMRPhenomPv2/4s", + os.path.join(os.path.expanduser("~"), "ROQ_data/IMRPhenomXPHM/4s"), + "/home/cbc/ROQ_data/IMRPhenomXPHM/4s", ] roq_dir = None for path in trial_roq_paths: @@ -1153,7 +1153,7 @@ def create_likelihood_single_basis(self): duration = 4 geocent_time = 1.2 reference_frequency = 20.0 - waveform_approximant = "IMRPhenomPv2" + waveform_approximant = "IMRPhenomXPHM" mc_range = [12.299703, 45] priors = bilby.gw.prior.BBHPriorDict() @@ -1194,7 +1194,7 @@ def create_likelihood_multiple_bases(self, multiband): duration = 16 geocent_time = 1.2 reference_frequency = 20.0 - waveform_approximant = "IMRPhenomD" + waveform_approximant = "IMRPhenomXAS" mc_range = [8, 14] priors = bilby.gw.prior.BBHPriorDict() @@ -1310,10 +1310,10 @@ def tearDown(self): ) @parameterized.expand([ - ("IMRPhenomD", True, 2, False, 1.5e-2), - ("IMRPhenomD", True, 2, True, 1.5e-2), - ("IMRPhenomD", False, 2, False, 5e-3), - ("IMRPhenomD", False, 2, True, 6e-3), + ("IMRPhenomXAS", True, 2, False, 1.5e-2), + ("IMRPhenomXAS", True, 2, True, 1.5e-2), + ("IMRPhenomXAS", False, 2, False, 5e-3), + ("IMRPhenomXAS", False, 2, True, 6e-3), ("IMRPhenomHM", False, 4, False, 8e-4), ("IMRPhenomHM", False, 4, True, 1e-3) ]) @@ -1362,7 +1362,7 @@ def test_large_accuracy_factor(self): """ Check if larger accuracy factor increases the accuracy. """ - waveform_approximant = "IMRPhenomD" + waveform_approximant = "IMRPhenomXAS" wfg = bilby.gw.WaveformGenerator( duration=self.duration, sampling_frequency=self.sampling_frequency, frequency_domain_source_model=bilby.gw.source.lal_binary_black_hole, @@ -1408,7 +1408,7 @@ def test_reference_chirp_mass_from_prior(self): duration=self.duration, sampling_frequency=self.sampling_frequency, frequency_domain_source_model=bilby.gw.source.binary_black_hole_frequency_sequence, waveform_arguments=dict( - reference_frequency=self.fmin, waveform_approximant="IMRPhenomD" + reference_frequency=self.fmin, waveform_approximant="IMRPhenomXAS" ) ) likelihood1 = bilby.gw.likelihood.MBGravitationalWaveTransient( @@ -1430,7 +1430,7 @@ def test_no_reference_chirp_mass(self): duration=self.duration, sampling_frequency=self.sampling_frequency, frequency_domain_source_model=bilby.gw.source.binary_black_hole_frequency_sequence, waveform_arguments=dict( - reference_frequency=self.fmin, waveform_approximant="IMRPhenomD" + reference_frequency=self.fmin, waveform_approximant="IMRPhenomXAS" ) ) with self.assertRaises(TypeError): @@ -1446,7 +1446,7 @@ def test_cannot_determine_reference_chirp_mass(self): duration=self.duration, sampling_frequency=self.sampling_frequency, frequency_domain_source_model=bilby.gw.source.binary_black_hole_frequency_sequence, waveform_arguments=dict( - reference_frequency=self.fmin, waveform_approximant="IMRPhenomD" + reference_frequency=self.fmin, waveform_approximant="IMRPhenomXAS" ) ) for key in ["chirp_mass", "mass_1", "mass_2"]: @@ -1463,7 +1463,7 @@ def test_inout_weights(self, linear_interpolation): Check if multiband weights can be saved as a file, and a likelihood object constructed from the weights file produces the same likelihood value. """ - waveform_approximant = "IMRPhenomD" + waveform_approximant = "IMRPhenomXAS" wfg = bilby.gw.WaveformGenerator( duration=self.duration, sampling_frequency=self.sampling_frequency, frequency_domain_source_model=bilby.gw.source.lal_binary_black_hole, @@ -1519,7 +1519,7 @@ def test_from_dict_weights(self, linear_interpolation): """ Check if a likelihood object constructed from dictionary-like weights produce the same likelihood value """ - waveform_approximant = "IMRPhenomD" + waveform_approximant = "IMRPhenomXAS" wfg = bilby.gw.WaveformGenerator( duration=self.duration, sampling_frequency=self.sampling_frequency, frequency_domain_source_model=bilby.gw.source.lal_binary_black_hole, @@ -1565,8 +1565,8 @@ def test_from_dict_weights(self, linear_interpolation): self.assertAlmostEqual(llr, llr_from_weights) @parameterized.expand([ - ("IMRPhenomD", True, 2, False, 1e-2), - ("IMRPhenomD", True, 2, True, 1e-2), + ("IMRPhenomXAS", True, 2, False, 1e-2), + ("IMRPhenomXAS", True, 2, True, 1e-2), ("IMRPhenomHM", False, 4, False, 5e-3), ]) def test_matches_original_likelihood_low_maximum_frequency( diff --git a/test/gw/plot_test.py b/test/gw/plot_test.py index bd9414212..81a1ca084 100644 --- a/test/gw/plot_test.py +++ b/test/gw/plot_test.py @@ -21,7 +21,7 @@ def setUp(self): frequency_domain_source_model=bilby.gw.source.lal_binary_black_hole, time_domain_source_model=None, waveform_arguments=dict( - reference_frequency=20.0, waveform_approximant="IMRPhenomPv2" + reference_frequency=20.0, waveform_approximant="IMRPhenomXPHM" ), interferometers=dict( H1=dict(optimal_SNR=1, parameters=injection_parameters), diff --git a/test/gw/result_test.py b/test/gw/result_test.py index 73780174f..7496ee579 100644 --- a/test/gw/result_test.py +++ b/test/gw/result_test.py @@ -20,7 +20,7 @@ def setUp(self): time_marginalization=True, frequency_domain_source_model=bilby.gw.source.lal_binary_black_hole, waveform_arguments=dict( - reference_frequency=20.0, waveform_approximant="IMRPhenomPv2" + reference_frequency=20.0, waveform_approximant="IMRPhenomXPHM" ), interferometers=dict( H1=dict(optimal_SNR=1, parameters=injection_parameters), diff --git a/test/gw/source_test.py b/test/gw/source_test.py index be9072fb8..c9fc5b6c9 100644 --- a/test/gw/source_test.py +++ b/test/gw/source_test.py @@ -26,7 +26,7 @@ def setUp(self): phase=0.0, ) self.waveform_kwargs = dict( - waveform_approximant="IMRPhenomPv2", + waveform_approximant="IMRPhenomXPHM", reference_frequency=50.0, minimum_frequency=20.0, catch_waveform_errors=True, @@ -212,7 +212,7 @@ def setUp(self): lambda_2=100.0, ) self.waveform_kwargs = dict( - waveform_approximant="IMRPhenomPv2_NRTidal", + waveform_approximant="IMRPhenomPv2_NRTidalv2", reference_frequency=50.0, minimum_frequency=20.0, ) @@ -325,7 +325,7 @@ def setUp(self): frequency_nodes_linear=fnodes_linear, frequency_nodes_quadratic=fnodes_quadratic, reference_frequency=50.0, - waveform_approximant="IMRPhenomPv2", + waveform_approximant="IMRPhenomXPHM", ) self.frequency_array = bilby.core.utils.create_frequency_series(2048, 4) @@ -479,7 +479,7 @@ def setUp(self): self.full_frequencies_to_sequence = self.frequency_array >= self.minimum_frequency self.frequencies = self.frequency_array[self.full_frequencies_to_sequence] self.waveform_kwargs = dict( - waveform_approximant="IMRPhenomPv2_NRTidal", + waveform_approximant="IMRPhenomPv2_NRTidalv2", reference_frequency=50.0, ) @@ -538,14 +538,14 @@ def setUp(self): phase=0.0, ) self.waveform_kwargs_fiducial = dict( - waveform_approximant="IMRPhenomPv2", + waveform_approximant="IMRPhenomXPHM", reference_frequency=50.0, minimum_frequency=20.0, catch_waveform_errors=True, fiducial=True, ) self.waveform_kwargs_binned = dict( - waveform_approximant="IMRPhenomPv2", + waveform_approximant="IMRPhenomXPHM", reference_frequency=50.0, minimum_frequency=20.0, catch_waveform_errors=True, @@ -653,13 +653,13 @@ def setUp(self): lambda_2=100.0, ) self.waveform_kwargs_fiducial = dict( - waveform_approximant="IMRPhenomPv2_NRTidal", + waveform_approximant="IMRPhenomPv2_NRTidalv2", reference_frequency=50.0, minimum_frequency=20.0, fiducial=True, ) self.waveform_kwargs_binned = dict( - waveform_approximant="IMRPhenomPv2_NRTidal", + waveform_approximant="IMRPhenomPv2_NRTidalv2", reference_frequency=50.0, minimum_frequency=20.0, fiducial=False, diff --git a/test/gw/utils_test.py b/test/gw/utils_test.py index bb842cc80..6b1ca1d03 100644 --- a/test/gw/utils_test.py +++ b/test/gw/utils_test.py @@ -189,7 +189,7 @@ def test_lalsim_SimInspiralChooseFDWaveform(self): 1000, 20, None, - lalsim.IMRPhenomPv2, + lalsim.IMRPhenomXPHM, ) self.assertEqual(len(a), 2) self.assertEqual(type(a[0]), lal.COMPLEX16FrequencySeries) diff --git a/test/integration/make_standard_data.py b/test/integration/make_standard_data.py index 4f5d4073d..c24f3e985 100644 --- a/test/integration/make_standard_data.py +++ b/test/integration/make_standard_data.py @@ -22,7 +22,7 @@ luminosity_distance=100.0, theta_jn=0.4, phase=1.3, - waveform_approximant="IMRPhenomPv2", + waveform_approximant="IMRPhenomXPHM", reference_frequency=50.0, ra=1.375, dec=-1.2108, diff --git a/test/integration/sample_from_the_prior_test.py b/test/integration/sample_from_the_prior_test.py index 7fce8b162..0882e352f 100644 --- a/test/integration/sample_from_the_prior_test.py +++ b/test/integration/sample_from_the_prior_test.py @@ -42,7 +42,7 @@ def test_fifteen_dimensional_cbc(self): bilby.core.utils.random.seed(8817021) waveform_arguments = dict( - waveform_approximant="IMRPhenomPv2", + waveform_approximant="IMRPhenomXPHM", reference_frequency=50.0, minimum_frequency=20.0, ) diff --git a/test/integration/test_waveforms.py b/test/integration/test_waveforms.py index c564c1052..9b026ff65 100644 --- a/test/integration/test_waveforms.py +++ b/test/integration/test_waveforms.py @@ -46,20 +46,20 @@ def setUp(self): lambda_2=1500, ) - def test_IMRPhenomPv2(self): - waveform_approximant = "IMRPhenomPv2" + def test_IMRPhenomXPHM(self): + waveform_approximant = "IMRPhenomXPHM" self.run_for_approximant(waveform_approximant, source="bbh") - def test_IMRPhenomD(self): - waveform_approximant = "IMRPhenomD" + def test_IMRPhenomXAS(self): + waveform_approximant = "IMRPhenomXAS" self.run_for_approximant(waveform_approximant, source="bbh") - def test_IMRPhenomPv2_NRTidal(self): - waveform_approximant = "IMRPhenomPv2_NRTidal" + def test_IMRPhenomPv2_NRTidalv2(self): + waveform_approximant = "IMRPhenomPv2_NRTidalv2" self.run_for_approximant(waveform_approximant, source="bns") - def test_IMRPhenomD_NRTidal(self): - waveform_approximant = "IMRPhenomD_NRTidal" + def test_IMRPhenomD_NRTidalv2(self): + waveform_approximant = "IMRPhenomD_NRTidalv2" self.run_for_approximant(waveform_approximant, source="bns") def test_TaylorF2(self): From ae0863095fd7d5aa2e522088f82950711530defe Mon Sep 17 00:00:00 2001 From: Ann-Kristin Malz <77342869+akjm99@users.noreply.github.com> Date: Fri, 24 Jan 2025 07:19:05 -0800 Subject: [PATCH 02/11] TST: change all likelihood and waveform tests to use more recent waveforms --- test/gw/likelihood/marginalization_test.py | 12 ++-- test/gw/likelihood_test.py | 60 +++++++++---------- test/gw/plot_test.py | 2 +- test/gw/result_test.py | 2 +- test/gw/source_test.py | 16 ++--- test/gw/utils_test.py | 2 +- test/integration/make_standard_data.py | 2 +- .../integration/sample_from_the_prior_test.py | 2 +- test/integration/test_waveforms.py | 16 ++--- 9 files changed, 57 insertions(+), 57 deletions(-) diff --git a/test/gw/likelihood/marginalization_test.py b/test/gw/likelihood/marginalization_test.py index d5b1d4004..9ac61bb13 100644 --- a/test/gw/likelihood/marginalization_test.py +++ b/test/gw/likelihood/marginalization_test.py @@ -216,7 +216,7 @@ def setUp(self): waveform_arguments=dict( reference_frequency=20.0, minimum_frequency=20.0, - waveform_approximant="IMRPhenomPv2", + waveform_approximant="IMRPhenomXPHM", ) ) self.interferometers.inject_signal( @@ -231,8 +231,8 @@ def setUp(self): trial_roq_paths = [ "/roq_basis", - os.path.join(os.path.expanduser("~"), "ROQ_data/IMRPhenomPv2/4s"), - "/home/cbc/ROQ_data/IMRPhenomPv2/4s", + os.path.join(os.path.expanduser("~"), "ROQ_data/IMRPhenomXPHM/4s"), + "/home/cbc/ROQ_data/IMRPhenomXPHM/4s", ] roq_dir = None for path in trial_roq_paths: @@ -249,7 +249,7 @@ def setUp(self): start_time=1126259640, waveform_arguments=dict( reference_frequency=20.0, - waveform_approximant="IMRPhenomPv2", + waveform_approximant="IMRPhenomXPHM", frequency_nodes_linear=np.load(f"{roq_dir}/fnodes_linear.npy"), frequency_nodes_quadratic=np.load(f"{roq_dir}/fnodes_quadratic.npy"), ) @@ -265,7 +265,7 @@ def setUp(self): waveform_arguments=dict( reference_frequency=20.0, minimum_frequency=20.0, - waveform_approximant="IMRPhenomPv2", + waveform_approximant="IMRPhenomXPHM", ) ) @@ -276,7 +276,7 @@ def setUp(self): start_time=1126259640, waveform_arguments=dict( reference_frequency=20.0, - waveform_approximant="IMRPhenomPv2", + waveform_approximant="IMRPhenomXPHM", ) ) diff --git a/test/gw/likelihood_test.py b/test/gw/likelihood_test.py index 84298e1d9..67f7698de 100644 --- a/test/gw/likelihood_test.py +++ b/test/gw/likelihood_test.py @@ -283,8 +283,8 @@ def setUp(self): # Possible locations for the ROQ: in the docker image, local, or on CIT trial_roq_paths = [ "/roq_basis", - os.path.join(os.path.expanduser("~"), "ROQ_data/IMRPhenomPv2/4s"), - "/home/cbc/ROQ_data/IMRPhenomPv2/4s", + os.path.join(os.path.expanduser("~"), "ROQ_data/IMRPhenomXPHM/4s"), + "/home/cbc/ROQ_data/IMRPhenomXPHM/4s", ] roq_dir = None for path in trial_roq_paths: @@ -331,7 +331,7 @@ def setUp(self): self.priors = bilby.gw.prior.BBHPriorDict() self.priors.pop("mass_1") self.priors.pop("mass_2") - # Testing is done with the 4s IMRPhenomPV2 ROQ basis + # Testing is done with the 4s IMRPhenomXPHM ROQ basis self.priors["chirp_mass"] = bilby.core.prior.Uniform(12.299703, 45) self.priors["mass_ratio"] = bilby.core.prior.Uniform(0.125, 1) self.priors["geocent_time"] = bilby.core.prior.Uniform(1.19, 1.21) @@ -343,7 +343,7 @@ def setUp(self): waveform_arguments=dict( reference_frequency=20.0, minimum_frequency=20.0, - waveform_approximant="IMRPhenomPv2", + waveform_approximant="IMRPhenomXPHM", ), ) @@ -361,7 +361,7 @@ def setUp(self): frequency_nodes_linear=fnodes_linear, frequency_nodes_quadratic=fnodes_quadratic, reference_frequency=20.0, - waveform_approximant="IMRPhenomPv2", + waveform_approximant="IMRPhenomXPHM", ), ) @@ -546,8 +546,8 @@ def test_rescaling(self): # Possible locations for the ROQ: in the docker image, local, or on CIT trial_roq_paths = [ "/roq_basis", - os.path.join(os.path.expanduser("~"), "ROQ_data/IMRPhenomPv2/4s"), - "/home/cbc/ROQ_data/IMRPhenomPv2/4s", + os.path.join(os.path.expanduser("~"), "ROQ_data/IMRPhenomXPHM/4s"), + "/home/cbc/ROQ_data/IMRPhenomXPHM/4s", ] roq_dir = None for path in trial_roq_paths: @@ -583,7 +583,7 @@ def test_rescaling(self): self.priors = bilby.gw.prior.BBHPriorDict() self.priors.pop("mass_1") self.priors.pop("mass_2") - # Testing is done with the 4s IMRPhenomPV2 ROQ basis + # Testing is done with the 4s IMRPhenomXPHM ROQ basis self.priors["chirp_mass"] = bilby.core.prior.Uniform( 12.299703 / scale_factor, 45 / scale_factor ) @@ -598,7 +598,7 @@ def test_rescaling(self): frequency_nodes_linear=fnodes_linear, frequency_nodes_quadratic=fnodes_quadratic, reference_frequency=20.0, - waveform_approximant="IMRPhenomPv2", + waveform_approximant="IMRPhenomXPHM", ), ) @@ -631,7 +631,7 @@ def setUp(self): self.sampling_frequency = 2048 self.duration = 16 self.reference_frequency = 20.0 - self.waveform_approximant = "IMRPhenomD" + self.waveform_approximant = "IMRPhenomXAS" # The SNRs of injections are 130-160 for roq_scale_factor=1 and 70-80 for roq_scale_factor=2 self.injection_parameters = dict( mass_ratio=0.8, @@ -942,7 +942,7 @@ def test_from_hdf5(self, basis_linear, basis_quadratic): duration = 16 geocent_time = 1.2 reference_frequency = 20.0 - waveform_approximant = "IMRPhenomD" + waveform_approximant = "IMRPhenomXAS" mc_range = [8, 14] priors = bilby.gw.prior.BBHPriorDict() @@ -980,8 +980,8 @@ def test_from_npy(self, from_array): # Possible locations for the ROQ: in the docker image, local, or on CIT trial_roq_paths = [ "/roq_basis", - os.path.join(os.path.expanduser("~"), "ROQ_data/IMRPhenomPv2/4s"), - "/home/cbc/ROQ_data/IMRPhenomPv2/4s", + os.path.join(os.path.expanduser("~"), "ROQ_data/IMRPhenomXPHM/4s"), + "/home/cbc/ROQ_data/IMRPhenomXPHM/4s", ] roq_dir = None for path in trial_roq_paths: @@ -1006,7 +1006,7 @@ def test_from_npy(self, from_array): duration = 4 geocent_time = 1.2 reference_frequency = 20.0 - waveform_approximant = "IMRPhenomPv2" + waveform_approximant = "IMRPhenomXPHM" mc_range = [12.299703, 45] priors = bilby.gw.prior.BBHPriorDict() @@ -1132,8 +1132,8 @@ def create_likelihood_single_basis(self): # Possible locations for the ROQ: in the docker image, local, or on CIT trial_roq_paths = [ "/roq_basis", - os.path.join(os.path.expanduser("~"), "ROQ_data/IMRPhenomPv2/4s"), - "/home/cbc/ROQ_data/IMRPhenomPv2/4s", + os.path.join(os.path.expanduser("~"), "ROQ_data/IMRPhenomXPHM/4s"), + "/home/cbc/ROQ_data/IMRPhenomXPHM/4s", ] roq_dir = None for path in trial_roq_paths: @@ -1153,7 +1153,7 @@ def create_likelihood_single_basis(self): duration = 4 geocent_time = 1.2 reference_frequency = 20.0 - waveform_approximant = "IMRPhenomPv2" + waveform_approximant = "IMRPhenomXPHM" mc_range = [12.299703, 45] priors = bilby.gw.prior.BBHPriorDict() @@ -1194,7 +1194,7 @@ def create_likelihood_multiple_bases(self, multiband): duration = 16 geocent_time = 1.2 reference_frequency = 20.0 - waveform_approximant = "IMRPhenomD" + waveform_approximant = "IMRPhenomXAS" mc_range = [8, 14] priors = bilby.gw.prior.BBHPriorDict() @@ -1310,10 +1310,10 @@ def tearDown(self): ) @parameterized.expand([ - ("IMRPhenomD", True, 2, False, 1.5e-2), - ("IMRPhenomD", True, 2, True, 1.5e-2), - ("IMRPhenomD", False, 2, False, 5e-3), - ("IMRPhenomD", False, 2, True, 6e-3), + ("IMRPhenomXAS", True, 2, False, 1.5e-2), + ("IMRPhenomXAS", True, 2, True, 1.5e-2), + ("IMRPhenomXAS", False, 2, False, 5e-3), + ("IMRPhenomXAS", False, 2, True, 6e-3), ("IMRPhenomHM", False, 4, False, 8e-4), ("IMRPhenomHM", False, 4, True, 1e-3) ]) @@ -1362,7 +1362,7 @@ def test_large_accuracy_factor(self): """ Check if larger accuracy factor increases the accuracy. """ - waveform_approximant = "IMRPhenomD" + waveform_approximant = "IMRPhenomXAS" wfg = bilby.gw.WaveformGenerator( duration=self.duration, sampling_frequency=self.sampling_frequency, frequency_domain_source_model=bilby.gw.source.lal_binary_black_hole, @@ -1408,7 +1408,7 @@ def test_reference_chirp_mass_from_prior(self): duration=self.duration, sampling_frequency=self.sampling_frequency, frequency_domain_source_model=bilby.gw.source.binary_black_hole_frequency_sequence, waveform_arguments=dict( - reference_frequency=self.fmin, waveform_approximant="IMRPhenomD" + reference_frequency=self.fmin, waveform_approximant="IMRPhenomXAS" ) ) likelihood1 = bilby.gw.likelihood.MBGravitationalWaveTransient( @@ -1430,7 +1430,7 @@ def test_no_reference_chirp_mass(self): duration=self.duration, sampling_frequency=self.sampling_frequency, frequency_domain_source_model=bilby.gw.source.binary_black_hole_frequency_sequence, waveform_arguments=dict( - reference_frequency=self.fmin, waveform_approximant="IMRPhenomD" + reference_frequency=self.fmin, waveform_approximant="IMRPhenomXAS" ) ) with self.assertRaises(TypeError): @@ -1446,7 +1446,7 @@ def test_cannot_determine_reference_chirp_mass(self): duration=self.duration, sampling_frequency=self.sampling_frequency, frequency_domain_source_model=bilby.gw.source.binary_black_hole_frequency_sequence, waveform_arguments=dict( - reference_frequency=self.fmin, waveform_approximant="IMRPhenomD" + reference_frequency=self.fmin, waveform_approximant="IMRPhenomXAS" ) ) for key in ["chirp_mass", "mass_1", "mass_2"]: @@ -1463,7 +1463,7 @@ def test_inout_weights(self, linear_interpolation): Check if multiband weights can be saved as a file, and a likelihood object constructed from the weights file produces the same likelihood value. """ - waveform_approximant = "IMRPhenomD" + waveform_approximant = "IMRPhenomXAS" wfg = bilby.gw.WaveformGenerator( duration=self.duration, sampling_frequency=self.sampling_frequency, frequency_domain_source_model=bilby.gw.source.lal_binary_black_hole, @@ -1519,7 +1519,7 @@ def test_from_dict_weights(self, linear_interpolation): """ Check if a likelihood object constructed from dictionary-like weights produce the same likelihood value """ - waveform_approximant = "IMRPhenomD" + waveform_approximant = "IMRPhenomXAS" wfg = bilby.gw.WaveformGenerator( duration=self.duration, sampling_frequency=self.sampling_frequency, frequency_domain_source_model=bilby.gw.source.lal_binary_black_hole, @@ -1565,8 +1565,8 @@ def test_from_dict_weights(self, linear_interpolation): self.assertAlmostEqual(llr, llr_from_weights) @parameterized.expand([ - ("IMRPhenomD", True, 2, False, 1e-2), - ("IMRPhenomD", True, 2, True, 1e-2), + ("IMRPhenomXAS", True, 2, False, 1e-2), + ("IMRPhenomXAS", True, 2, True, 1e-2), ("IMRPhenomHM", False, 4, False, 5e-3), ]) def test_matches_original_likelihood_low_maximum_frequency( diff --git a/test/gw/plot_test.py b/test/gw/plot_test.py index bd9414212..81a1ca084 100644 --- a/test/gw/plot_test.py +++ b/test/gw/plot_test.py @@ -21,7 +21,7 @@ def setUp(self): frequency_domain_source_model=bilby.gw.source.lal_binary_black_hole, time_domain_source_model=None, waveform_arguments=dict( - reference_frequency=20.0, waveform_approximant="IMRPhenomPv2" + reference_frequency=20.0, waveform_approximant="IMRPhenomXPHM" ), interferometers=dict( H1=dict(optimal_SNR=1, parameters=injection_parameters), diff --git a/test/gw/result_test.py b/test/gw/result_test.py index 98a7ce52f..c9eb0ce67 100644 --- a/test/gw/result_test.py +++ b/test/gw/result_test.py @@ -27,7 +27,7 @@ def setUp(self): time_marginalization=True, frequency_domain_source_model=bilby.gw.source.lal_binary_black_hole, waveform_arguments=dict( - reference_frequency=20.0, waveform_approximant="IMRPhenomPv2" + reference_frequency=20.0, waveform_approximant="IMRPhenomXPHM" ), interferometers=dict( H1=dict(optimal_SNR=1, parameters=injection_parameters), diff --git a/test/gw/source_test.py b/test/gw/source_test.py index be9072fb8..c9fc5b6c9 100644 --- a/test/gw/source_test.py +++ b/test/gw/source_test.py @@ -26,7 +26,7 @@ def setUp(self): phase=0.0, ) self.waveform_kwargs = dict( - waveform_approximant="IMRPhenomPv2", + waveform_approximant="IMRPhenomXPHM", reference_frequency=50.0, minimum_frequency=20.0, catch_waveform_errors=True, @@ -212,7 +212,7 @@ def setUp(self): lambda_2=100.0, ) self.waveform_kwargs = dict( - waveform_approximant="IMRPhenomPv2_NRTidal", + waveform_approximant="IMRPhenomPv2_NRTidalv2", reference_frequency=50.0, minimum_frequency=20.0, ) @@ -325,7 +325,7 @@ def setUp(self): frequency_nodes_linear=fnodes_linear, frequency_nodes_quadratic=fnodes_quadratic, reference_frequency=50.0, - waveform_approximant="IMRPhenomPv2", + waveform_approximant="IMRPhenomXPHM", ) self.frequency_array = bilby.core.utils.create_frequency_series(2048, 4) @@ -479,7 +479,7 @@ def setUp(self): self.full_frequencies_to_sequence = self.frequency_array >= self.minimum_frequency self.frequencies = self.frequency_array[self.full_frequencies_to_sequence] self.waveform_kwargs = dict( - waveform_approximant="IMRPhenomPv2_NRTidal", + waveform_approximant="IMRPhenomPv2_NRTidalv2", reference_frequency=50.0, ) @@ -538,14 +538,14 @@ def setUp(self): phase=0.0, ) self.waveform_kwargs_fiducial = dict( - waveform_approximant="IMRPhenomPv2", + waveform_approximant="IMRPhenomXPHM", reference_frequency=50.0, minimum_frequency=20.0, catch_waveform_errors=True, fiducial=True, ) self.waveform_kwargs_binned = dict( - waveform_approximant="IMRPhenomPv2", + waveform_approximant="IMRPhenomXPHM", reference_frequency=50.0, minimum_frequency=20.0, catch_waveform_errors=True, @@ -653,13 +653,13 @@ def setUp(self): lambda_2=100.0, ) self.waveform_kwargs_fiducial = dict( - waveform_approximant="IMRPhenomPv2_NRTidal", + waveform_approximant="IMRPhenomPv2_NRTidalv2", reference_frequency=50.0, minimum_frequency=20.0, fiducial=True, ) self.waveform_kwargs_binned = dict( - waveform_approximant="IMRPhenomPv2_NRTidal", + waveform_approximant="IMRPhenomPv2_NRTidalv2", reference_frequency=50.0, minimum_frequency=20.0, fiducial=False, diff --git a/test/gw/utils_test.py b/test/gw/utils_test.py index cf78849c7..8f2749ebf 100644 --- a/test/gw/utils_test.py +++ b/test/gw/utils_test.py @@ -189,7 +189,7 @@ def test_lalsim_SimInspiralChooseFDWaveform(self): 1000, 20, None, - lalsim.IMRPhenomPv2, + lalsim.IMRPhenomXPHM, ) self.assertEqual(len(a), 2) self.assertEqual(type(a[0]), lal.COMPLEX16FrequencySeries) diff --git a/test/integration/make_standard_data.py b/test/integration/make_standard_data.py index 4f5d4073d..c24f3e985 100644 --- a/test/integration/make_standard_data.py +++ b/test/integration/make_standard_data.py @@ -22,7 +22,7 @@ luminosity_distance=100.0, theta_jn=0.4, phase=1.3, - waveform_approximant="IMRPhenomPv2", + waveform_approximant="IMRPhenomXPHM", reference_frequency=50.0, ra=1.375, dec=-1.2108, diff --git a/test/integration/sample_from_the_prior_test.py b/test/integration/sample_from_the_prior_test.py index 7fce8b162..0882e352f 100644 --- a/test/integration/sample_from_the_prior_test.py +++ b/test/integration/sample_from_the_prior_test.py @@ -42,7 +42,7 @@ def test_fifteen_dimensional_cbc(self): bilby.core.utils.random.seed(8817021) waveform_arguments = dict( - waveform_approximant="IMRPhenomPv2", + waveform_approximant="IMRPhenomXPHM", reference_frequency=50.0, minimum_frequency=20.0, ) diff --git a/test/integration/test_waveforms.py b/test/integration/test_waveforms.py index c564c1052..9b026ff65 100644 --- a/test/integration/test_waveforms.py +++ b/test/integration/test_waveforms.py @@ -46,20 +46,20 @@ def setUp(self): lambda_2=1500, ) - def test_IMRPhenomPv2(self): - waveform_approximant = "IMRPhenomPv2" + def test_IMRPhenomXPHM(self): + waveform_approximant = "IMRPhenomXPHM" self.run_for_approximant(waveform_approximant, source="bbh") - def test_IMRPhenomD(self): - waveform_approximant = "IMRPhenomD" + def test_IMRPhenomXAS(self): + waveform_approximant = "IMRPhenomXAS" self.run_for_approximant(waveform_approximant, source="bbh") - def test_IMRPhenomPv2_NRTidal(self): - waveform_approximant = "IMRPhenomPv2_NRTidal" + def test_IMRPhenomPv2_NRTidalv2(self): + waveform_approximant = "IMRPhenomPv2_NRTidalv2" self.run_for_approximant(waveform_approximant, source="bns") - def test_IMRPhenomD_NRTidal(self): - waveform_approximant = "IMRPhenomD_NRTidal" + def test_IMRPhenomD_NRTidalv2(self): + waveform_approximant = "IMRPhenomD_NRTidalv2" self.run_for_approximant(waveform_approximant, source="bns") def test_TaylorF2(self): From bb82c36e7ee326b2651562849df477c908e8c855 Mon Sep 17 00:00:00 2001 From: Ann-Kristin Malz <77342869+akjm99@users.noreply.github.com> Date: Tue, 4 Feb 2025 05:13:23 -0800 Subject: [PATCH 03/11] TST: update waveforms --- test/gw/likelihood/marginalization_test.py | 4 ++-- test/gw/likelihood_test.py | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/test/gw/likelihood/marginalization_test.py b/test/gw/likelihood/marginalization_test.py index 9ac61bb13..c615e9e34 100644 --- a/test/gw/likelihood/marginalization_test.py +++ b/test/gw/likelihood/marginalization_test.py @@ -231,8 +231,8 @@ def setUp(self): trial_roq_paths = [ "/roq_basis", - os.path.join(os.path.expanduser("~"), "ROQ_data/IMRPhenomXPHM/4s"), - "/home/cbc/ROQ_data/IMRPhenomXPHM/4s", + os.path.join(os.path.expanduser("~"), "ROQ_data/IMRPhenomPv2/4s"), + "/home/cbc/ROQ_data/IMRPhenomPv2/4s", ] roq_dir = None for path in trial_roq_paths: diff --git a/test/gw/likelihood_test.py b/test/gw/likelihood_test.py index 67f7698de..f0e3023f7 100644 --- a/test/gw/likelihood_test.py +++ b/test/gw/likelihood_test.py @@ -283,8 +283,8 @@ def setUp(self): # Possible locations for the ROQ: in the docker image, local, or on CIT trial_roq_paths = [ "/roq_basis", - os.path.join(os.path.expanduser("~"), "ROQ_data/IMRPhenomXPHM/4s"), - "/home/cbc/ROQ_data/IMRPhenomXPHM/4s", + os.path.join(os.path.expanduser("~"), "ROQ_data/IMRPhenomPv2/4s"), + "/home/cbc/ROQ_data/IMRPhenomPv2/4s", ] roq_dir = None for path in trial_roq_paths: @@ -546,8 +546,8 @@ def test_rescaling(self): # Possible locations for the ROQ: in the docker image, local, or on CIT trial_roq_paths = [ "/roq_basis", - os.path.join(os.path.expanduser("~"), "ROQ_data/IMRPhenomXPHM/4s"), - "/home/cbc/ROQ_data/IMRPhenomXPHM/4s", + os.path.join(os.path.expanduser("~"), "ROQ_data/IMRPhenomPv2/4s"), + "/home/cbc/ROQ_data/IMRPhenomPv2/4s", ] roq_dir = None for path in trial_roq_paths: @@ -980,8 +980,8 @@ def test_from_npy(self, from_array): # Possible locations for the ROQ: in the docker image, local, or on CIT trial_roq_paths = [ "/roq_basis", - os.path.join(os.path.expanduser("~"), "ROQ_data/IMRPhenomXPHM/4s"), - "/home/cbc/ROQ_data/IMRPhenomXPHM/4s", + os.path.join(os.path.expanduser("~"), "ROQ_data/IMRPhenomPv2/4s"), + "/home/cbc/ROQ_data/IMRPhenomPv2/4s", ] roq_dir = None for path in trial_roq_paths: @@ -1132,8 +1132,8 @@ def create_likelihood_single_basis(self): # Possible locations for the ROQ: in the docker image, local, or on CIT trial_roq_paths = [ "/roq_basis", - os.path.join(os.path.expanduser("~"), "ROQ_data/IMRPhenomXPHM/4s"), - "/home/cbc/ROQ_data/IMRPhenomXPHM/4s", + os.path.join(os.path.expanduser("~"), "ROQ_data/IMRPhenomPv2/4s"), + "/home/cbc/ROQ_data/IMRPhenomPv2/4s", ] roq_dir = None for path in trial_roq_paths: From 9451577a285cd4bab4f3bad359a854fe0a857040 Mon Sep 17 00:00:00 2001 From: Ann-Kristin Malz <77342869+akjm99@users.noreply.github.com> Date: Tue, 4 Feb 2025 05:35:55 -0800 Subject: [PATCH 04/11] TST: update waveforms --- test/gw/likelihood/marginalization_test.py | 4 ++-- test/gw/likelihood_test.py | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/test/gw/likelihood/marginalization_test.py b/test/gw/likelihood/marginalization_test.py index 9ac61bb13..c615e9e34 100644 --- a/test/gw/likelihood/marginalization_test.py +++ b/test/gw/likelihood/marginalization_test.py @@ -231,8 +231,8 @@ def setUp(self): trial_roq_paths = [ "/roq_basis", - os.path.join(os.path.expanduser("~"), "ROQ_data/IMRPhenomXPHM/4s"), - "/home/cbc/ROQ_data/IMRPhenomXPHM/4s", + os.path.join(os.path.expanduser("~"), "ROQ_data/IMRPhenomPv2/4s"), + "/home/cbc/ROQ_data/IMRPhenomPv2/4s", ] roq_dir = None for path in trial_roq_paths: diff --git a/test/gw/likelihood_test.py b/test/gw/likelihood_test.py index 67f7698de..f0e3023f7 100644 --- a/test/gw/likelihood_test.py +++ b/test/gw/likelihood_test.py @@ -283,8 +283,8 @@ def setUp(self): # Possible locations for the ROQ: in the docker image, local, or on CIT trial_roq_paths = [ "/roq_basis", - os.path.join(os.path.expanduser("~"), "ROQ_data/IMRPhenomXPHM/4s"), - "/home/cbc/ROQ_data/IMRPhenomXPHM/4s", + os.path.join(os.path.expanduser("~"), "ROQ_data/IMRPhenomPv2/4s"), + "/home/cbc/ROQ_data/IMRPhenomPv2/4s", ] roq_dir = None for path in trial_roq_paths: @@ -546,8 +546,8 @@ def test_rescaling(self): # Possible locations for the ROQ: in the docker image, local, or on CIT trial_roq_paths = [ "/roq_basis", - os.path.join(os.path.expanduser("~"), "ROQ_data/IMRPhenomXPHM/4s"), - "/home/cbc/ROQ_data/IMRPhenomXPHM/4s", + os.path.join(os.path.expanduser("~"), "ROQ_data/IMRPhenomPv2/4s"), + "/home/cbc/ROQ_data/IMRPhenomPv2/4s", ] roq_dir = None for path in trial_roq_paths: @@ -980,8 +980,8 @@ def test_from_npy(self, from_array): # Possible locations for the ROQ: in the docker image, local, or on CIT trial_roq_paths = [ "/roq_basis", - os.path.join(os.path.expanduser("~"), "ROQ_data/IMRPhenomXPHM/4s"), - "/home/cbc/ROQ_data/IMRPhenomXPHM/4s", + os.path.join(os.path.expanduser("~"), "ROQ_data/IMRPhenomPv2/4s"), + "/home/cbc/ROQ_data/IMRPhenomPv2/4s", ] roq_dir = None for path in trial_roq_paths: @@ -1132,8 +1132,8 @@ def create_likelihood_single_basis(self): # Possible locations for the ROQ: in the docker image, local, or on CIT trial_roq_paths = [ "/roq_basis", - os.path.join(os.path.expanduser("~"), "ROQ_data/IMRPhenomXPHM/4s"), - "/home/cbc/ROQ_data/IMRPhenomXPHM/4s", + os.path.join(os.path.expanduser("~"), "ROQ_data/IMRPhenomPv2/4s"), + "/home/cbc/ROQ_data/IMRPhenomPv2/4s", ] roq_dir = None for path in trial_roq_paths: From f57ad688ccbb44e6ea2e1f9e54ecf10650ce23d4 Mon Sep 17 00:00:00 2001 From: Ann-Kristin Malz <77342869+akjm99@users.noreply.github.com> Date: Mon, 15 Dec 2025 04:38:13 -0800 Subject: [PATCH 05/11] BUG: update waveforms to IMRPhenomPv2 for ROQ tests --- test/gw/likelihood/marginalization_test.py | 2 +- test/gw/likelihood_test.py | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/gw/likelihood/marginalization_test.py b/test/gw/likelihood/marginalization_test.py index c615e9e34..af085082e 100644 --- a/test/gw/likelihood/marginalization_test.py +++ b/test/gw/likelihood/marginalization_test.py @@ -249,7 +249,7 @@ def setUp(self): start_time=1126259640, waveform_arguments=dict( reference_frequency=20.0, - waveform_approximant="IMRPhenomXPHM", + waveform_approximant="IMRPhenomPv2", frequency_nodes_linear=np.load(f"{roq_dir}/fnodes_linear.npy"), frequency_nodes_quadratic=np.load(f"{roq_dir}/fnodes_quadratic.npy"), ) diff --git a/test/gw/likelihood_test.py b/test/gw/likelihood_test.py index f0e3023f7..299e36179 100644 --- a/test/gw/likelihood_test.py +++ b/test/gw/likelihood_test.py @@ -331,7 +331,7 @@ def setUp(self): self.priors = bilby.gw.prior.BBHPriorDict() self.priors.pop("mass_1") self.priors.pop("mass_2") - # Testing is done with the 4s IMRPhenomXPHM ROQ basis + # Testing is done with the 4s IMRPhenomPv2 ROQ basis self.priors["chirp_mass"] = bilby.core.prior.Uniform(12.299703, 45) self.priors["mass_ratio"] = bilby.core.prior.Uniform(0.125, 1) self.priors["geocent_time"] = bilby.core.prior.Uniform(1.19, 1.21) @@ -343,7 +343,7 @@ def setUp(self): waveform_arguments=dict( reference_frequency=20.0, minimum_frequency=20.0, - waveform_approximant="IMRPhenomXPHM", + waveform_approximant="IMRPhenomPv2", ), ) @@ -361,7 +361,7 @@ def setUp(self): frequency_nodes_linear=fnodes_linear, frequency_nodes_quadratic=fnodes_quadratic, reference_frequency=20.0, - waveform_approximant="IMRPhenomXPHM", + waveform_approximant="IMRPhenomPv2", ), ) @@ -583,7 +583,7 @@ def test_rescaling(self): self.priors = bilby.gw.prior.BBHPriorDict() self.priors.pop("mass_1") self.priors.pop("mass_2") - # Testing is done with the 4s IMRPhenomXPHM ROQ basis + # Testing is done with the 4s IMRPhenomPv2 ROQ basis self.priors["chirp_mass"] = bilby.core.prior.Uniform( 12.299703 / scale_factor, 45 / scale_factor ) @@ -598,7 +598,7 @@ def test_rescaling(self): frequency_nodes_linear=fnodes_linear, frequency_nodes_quadratic=fnodes_quadratic, reference_frequency=20.0, - waveform_approximant="IMRPhenomXPHM", + waveform_approximant="IMRPhenomPv2", ), ) @@ -1006,7 +1006,7 @@ def test_from_npy(self, from_array): duration = 4 geocent_time = 1.2 reference_frequency = 20.0 - waveform_approximant = "IMRPhenomXPHM" + waveform_approximant = "IMRPhenomPv2" mc_range = [12.299703, 45] priors = bilby.gw.prior.BBHPriorDict() @@ -1153,7 +1153,7 @@ def create_likelihood_single_basis(self): duration = 4 geocent_time = 1.2 reference_frequency = 20.0 - waveform_approximant = "IMRPhenomXPHM" + waveform_approximant = "IMRPhenomPv2" mc_range = [12.299703, 45] priors = bilby.gw.prior.BBHPriorDict() From 94cc6dde061aaddbb17fd5818aa74c56d7f51bbc Mon Sep 17 00:00:00 2001 From: Ann-Kristin Malz <77342869+akjm99@users.noreply.github.com> Date: Tue, 16 Dec 2025 04:49:04 -0800 Subject: [PATCH 06/11] BUG: update waveforms to IMRPhenomPv2 for ROQ tests --- test/gw/source_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/gw/source_test.py b/test/gw/source_test.py index c9fc5b6c9..bf29d07e7 100644 --- a/test/gw/source_test.py +++ b/test/gw/source_test.py @@ -325,7 +325,7 @@ def setUp(self): frequency_nodes_linear=fnodes_linear, frequency_nodes_quadratic=fnodes_quadratic, reference_frequency=50.0, - waveform_approximant="IMRPhenomXPHM", + waveform_approximant="IMRPhenomPv2", ) self.frequency_array = bilby.core.utils.create_frequency_series(2048, 4) From 3b8272351b45c2b3b37320a99abbbd6563df598b Mon Sep 17 00:00:00 2001 From: Ann-Kristin Malz <77342869+akjm99@users.noreply.github.com> Date: Tue, 16 Dec 2025 07:45:06 -0800 Subject: [PATCH 07/11] BUG: update waveforms to IMRPhenomPv2 for ROQ tests --- test/gw/likelihood/marginalization_test.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/gw/likelihood/marginalization_test.py b/test/gw/likelihood/marginalization_test.py index af085082e..d5b1d4004 100644 --- a/test/gw/likelihood/marginalization_test.py +++ b/test/gw/likelihood/marginalization_test.py @@ -216,7 +216,7 @@ def setUp(self): waveform_arguments=dict( reference_frequency=20.0, minimum_frequency=20.0, - waveform_approximant="IMRPhenomXPHM", + waveform_approximant="IMRPhenomPv2", ) ) self.interferometers.inject_signal( @@ -265,7 +265,7 @@ def setUp(self): waveform_arguments=dict( reference_frequency=20.0, minimum_frequency=20.0, - waveform_approximant="IMRPhenomXPHM", + waveform_approximant="IMRPhenomPv2", ) ) @@ -276,7 +276,7 @@ def setUp(self): start_time=1126259640, waveform_arguments=dict( reference_frequency=20.0, - waveform_approximant="IMRPhenomXPHM", + waveform_approximant="IMRPhenomPv2", ) ) From 5653d53b598552a9db415ab49b7d242131e9b57c Mon Sep 17 00:00:00 2001 From: Gregory Ashton Date: Thu, 15 Oct 2026 10:17:17 +0100 Subject: [PATCH 08/11] BUG: catch XPHM/X-family waveform domain errors and fix unit test Switching the test suite to IMRPhenomXPHM (PR #897) exposed two issues: - catch_waveform_errors only matched the exact IMRPhenomPv2 EDOM string, so out-of-domain errors from XPHM (XLAL_EFUNC) and XAS/D (XLAL_EINVAL) leaked out instead of returning None. Add a shared _is_waveform_domain_error helper recognising all three LAL domain-error codes, applied at all three catch_waveform_errors sites. - test_lalsim_SimInspiralChooseFDWaveform passed raw SI numbers as masses (~35 kg). Pv2 tolerated this but XPHM aborts the process. Scale the masses by lal.MSUN_SI so the inputs are physical. Co-Authored-By: Claude Opus 4.8 (1M context) --- bilby/gw/source.py | 40 ++++++++++++++++++++++++++++++---------- test/gw/utils_test.py | 7 +++++-- 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/bilby/gw/source.py b/bilby/gw/source.py index 97ad51b51..ff380484a 100644 --- a/bilby/gw/source.py +++ b/bilby/gw/source.py @@ -17,6 +17,33 @@ Unused waveform_kwargs: {waveform_kwargs} """ +# LAL error-code messages that indicate the requested parameters are outside +# the model's domain of validity (e.g. a sampler proposing an unphysical +# point) rather than a genuine bug. Different approximants surface an +# out-of-domain point through different XLAL error codes: +# XLAL_EDOM -> "Input domain error" (e.g. IMRPhenomPv2/XP) +# XLAL_EFUNC -> "Internal function call failed" (e.g. IMRPhenomXPHM via +# the frequency sequence) +# XLAL_EINVAL -> "Invalid argument" (e.g. IMRPhenomXAS/D) +# When ``catch_waveform_errors`` is enabled these are converted to a -inf +# likelihood instead of being raised. +WAVEFORM_DOMAIN_ERROR_MESSAGES = ( + "Input domain error", + "Internal function call failed", + "Invalid argument", +) + + +def _is_waveform_domain_error(exception): + """Return True if ``exception`` looks like an out-of-domain waveform error. + + See :data:`WAVEFORM_DOMAIN_ERROR_MESSAGES` for the recognised messages. + """ + if not exception.args: + return False + message = str(exception.args[0]) + return any(msg in message for msg in WAVEFORM_DOMAIN_ERROR_MESSAGES) + def gwsignal_binary_black_hole(frequency_array, mass_1, mass_2, luminosity_distance, a_1, tilt_1, phi_12, a_2, tilt_2, phi_jl, theta_jn, phase, **kwargs): @@ -217,12 +244,7 @@ def gwsignal_binary_black_hole(frequency_array, mass_1, mass_2, luminosity_dista if not catch_waveform_errors: raise else: - EDOM = ( - "Internal function call failed: Input domain error" in e.args[0] - ) or "Input domain error" in e.args[ - 0 - ] - if EDOM: + if _is_waveform_domain_error(e): failed_parameters = dict(mass_1=mass_1, mass_2=mass_2, spin_1=(spin_1x, spin_1y, spin_1z), spin_2=(spin_2x, spin_2y, spin_2z), @@ -645,8 +667,7 @@ def _base_lal_cbc_fd_waveform( if not catch_waveform_errors: raise else: - EDOM = (e.args[0] == 'Internal function call failed: Input domain error') - if EDOM: + if _is_waveform_domain_error(e): failed_parameters = dict(mass_1=mass_1, mass_2=mass_2, spin_1=(spin_1x, spin_1y, spin_1z), spin_2=(spin_2x, spin_2y, spin_2z), @@ -1131,8 +1152,7 @@ def _base_waveform_frequency_sequence( if not catch_waveform_errors: raise else: - EDOM = (e.args[0] == 'Internal function call failed: Input domain error') - if EDOM: + if _is_waveform_domain_error(e): failed_parameters = dict(mass_1=mass_1, mass_2=mass_2, spin_1=(spin_1x, spin_1y, spin_1z), spin_2=(spin_2x, spin_2y, spin_2z), diff --git a/test/gw/utils_test.py b/test/gw/utils_test.py index 00479ba11..c4601eec8 100644 --- a/test/gw/utils_test.py +++ b/test/gw/utils_test.py @@ -203,9 +203,12 @@ def test_get_approximant(self): gwutils.lalsim_GetApproximantFromString(10) def test_lalsim_SimInspiralChooseFDWaveform(self): + # Masses are passed to LALSimulation in SI units, so use solar masses + # here. IMRPhenomXPHM (unlike IMRPhenomPv2) cannot handle unphysical + # sub-solar-mass values and aborts the process for them. a = gwutils.lalsim_SimInspiralChooseFDWaveform( - 35.2, - 20.4, + 35.2 * lal.MSUN_SI, + 20.4 * lal.MSUN_SI, 0.1, 0.2, 0.2, From f500fb9cec74abd2eb2f673f9e007ccb79a58104 Mon Sep 17 00:00:00 2001 From: Gregory Ashton Date: Thu, 15 Oct 2026 10:26:18 +0100 Subject: [PATCH 09/11] STY: apply pretty-format-toml autofix to pyproject.toml and pixi.toml The pre-commit pretty-format-toml hook (v2.14.0) now adds spaces inside inline-table braces. These files predated that style, causing the pre-commit CI job to fail. Purely cosmetic; no semantic changes. Co-Authored-By: Claude Opus 4.8 (1M context) --- pixi.toml | 4 ++-- pyproject.toml | 26 +++++++++++++------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/pixi.toml b/pixi.toml index faad40e3b..4234b3d85 100644 --- a/pixi.toml +++ b/pixi.toml @@ -47,7 +47,7 @@ nestle-bilby = "*" zeus-bilby = "*" [feature.dynesty.pypi-dependencies] -dynesty = {git = "https://github.com/joshspeagle/dynesty.git", branch = "master"} +dynesty = { git = "https://github.com/joshspeagle/dynesty.git", branch = "master" } [feature.gw.dependencies] astropy = ">=5.0.0" @@ -98,7 +98,7 @@ schwimmbad = "*" scikit-learn = "*" [feature.test.pypi-dependencies] -bilby = {path = ".", editable = true} +bilby = { path = ".", editable = true } [feature.torch.dependencies] pytorch = "*" diff --git a/pyproject.toml b/pyproject.toml index 167dfedd8..8ae2e4139 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ requires = [ [project] authors = [ - {name = "Bilby Developers"} + { name = "Bilby Developers" } ] classifiers = [ "Development Status :: 5 - Production/Stable", @@ -22,13 +22,13 @@ classifiers = [ ] description = "A user-friendly Bayesian inference library" dynamic = ["dependencies", "optional-dependencies", "version"] -license = {file = "LICENSE.md"} +license = { file = "LICENSE.md" } maintainers = [ - {name = "Greg Ashton"}, - {name = "Sylvia Biscoveanu"}, - {name = "Colm Talbot"}, - {name = "Aditya Vijaykumar"}, - {name = "Michael J. Williams"} + { name = "Greg Ashton" }, + { name = "Sylvia Biscoveanu" }, + { name = "Colm Talbot" }, + { name = "Aditya Vijaykumar" }, + { name = "Michael J. Williams" } ] name = "bilby" readme = "README.rst" @@ -122,18 +122,18 @@ packages = [ ] [tool.setuptools.dynamic] -dependencies = {file = ["requirements.txt"]} +dependencies = { file = ["requirements.txt"] } [tool.setuptools.dynamic.optional-dependencies] -all = {file = [ +all = { file = [ "gw_requirements.txt", "jax_requirements.txt", "mcmc_requirements.txt", "optional_requirements.txt" -]} -gw = {file = ["gw_requirements.txt"]} -jax = {file = ["jax_requirements.txt"]} -mcmc = {file = ["mcmc_requirements.txt"]} +] } +gw = { file = ["gw_requirements.txt"] } +jax = { file = ["jax_requirements.txt"] } +mcmc = { file = ["mcmc_requirements.txt"] } [tool.setuptools.package-data] "bilby.gw" = ["prior_files/*"] From 6bea0499ad1942fb6bebf6d560535ed1c3edab44 Mon Sep 17 00:00:00 2001 From: Gregory Ashton Date: Thu, 15 Oct 2026 21:34:32 +0100 Subject: [PATCH 10/11] TST: use assertAlmostEqual for ROQ weights-with-params comparison The two log-likelihood ratios can differ at the level of floating-point round-off, causing the exact equality check to fail on CI. Co-Authored-By: Claude Opus 5.5 (1M context) --- test/gw/likelihood/roq_test.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/gw/likelihood/roq_test.py b/test/gw/likelihood/roq_test.py index 34fa5504f..412181b9e 100644 --- a/test/gw/likelihood/roq_test.py +++ b/test/gw/likelihood/roq_test.py @@ -188,9 +188,9 @@ def test_create_roq_weights_with_params(self): priors=self.priors, ) roq_llr = roq.log_likelihood_ratio(self.test_parameters) - self.assertEqual( - roq_llr, - self.roq.log_likelihood_ratio(self.test_parameters) + self.assertAlmostEqual( + float(roq_llr), + float(self.roq.log_likelihood_ratio(self.test_parameters)), ) self.assertEqual(aac.get_namespace(roq_llr), self.xp) From db2a3325298478be5f2117fae7219516a055522f Mon Sep 17 00:00:00 2001 From: Gregory Ashton Date: Fri, 16 Oct 2026 08:55:03 +0100 Subject: [PATCH 11/11] BUG: stop catching Invalid argument waveform errors and add tests Co-Authored-By: Claude Opus 5.5 (1M context) --- bilby/gw/source.py | 6 ++- test/gw/source_test.py | 110 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 114 insertions(+), 2 deletions(-) diff --git a/bilby/gw/source.py b/bilby/gw/source.py index ff380484a..f09e0b16c 100644 --- a/bilby/gw/source.py +++ b/bilby/gw/source.py @@ -24,13 +24,15 @@ # XLAL_EDOM -> "Input domain error" (e.g. IMRPhenomPv2/XP) # XLAL_EFUNC -> "Internal function call failed" (e.g. IMRPhenomXPHM via # the frequency sequence) -# XLAL_EINVAL -> "Invalid argument" (e.g. IMRPhenomXAS/D) # When ``catch_waveform_errors`` is enabled these are converted to a -inf # likelihood instead of being raised. +# +# XLAL_EINVAL ("Invalid argument") is deliberately not included: LAL raises +# it when, e.g., precessing spins are passed to an aligned-spin approximant, +# which is a configuration error that should not be silently ignored. WAVEFORM_DOMAIN_ERROR_MESSAGES = ( "Input domain error", "Internal function call failed", - "Invalid argument", ) diff --git a/test/gw/source_test.py b/test/gw/source_test.py index 38c539fdb..427935b64 100644 --- a/test/gw/source_test.py +++ b/test/gw/source_test.py @@ -8,6 +8,7 @@ import numpy as np from copy import copy +from parameterized import parameterized class TestLalBBH(unittest.TestCase): @@ -769,5 +770,114 @@ def test_binned_fails_without_tidal_parameters(self): ) +PRECESSING_APPROXIMANTS = ["IMRPhenomPv2", "IMRPhenomXP", "IMRPhenomXPHM"] +ALIGNED_APPROXIMANTS = ["IMRPhenomXAS", "IMRPhenomD", "IMRPhenomHM"] +SOURCE_MODELS = ["lal", "frequency_sequence", "relbin_fiducial", "relbin_binned"] + + +class TestWaveformErrorCatchingByApproximant(unittest.TestCase): + """ + Check which LAL errors ``catch_waveform_errors`` converts to ``None``. + + Out-of-domain parameters (here a negative mass) should be caught for all + approximants and source models. Precessing spins passed to an aligned-spin + approximant are a configuration error and should always be raised, even + with ``catch_waveform_errors=True``. + """ + + def setUp(self): + self.precessing_parameters = dict( + mass_1=30.0, + mass_2=30.0, + luminosity_distance=400.0, + a_1=0.4, + tilt_1=0.2, + phi_12=1.0, + a_2=0.8, + tilt_2=2.7, + phi_jl=2.9, + theta_jn=0.3, + phase=0.0, + ) + self.aligned_parameters = copy(self.precessing_parameters) + self.aligned_parameters.update(tilt_1=0.0, tilt_2=0.0, phi_12=0.0, phi_jl=0.0) + self.frequency_array = bilby.core.utils.create_frequency_series(2048, 4) + + def call_source(self, source_model, approximant, parameters, catch_waveform_errors=True): + kwargs = dict( + waveform_approximant=approximant, + reference_frequency=50.0, + catch_waveform_errors=catch_waveform_errors, + **parameters, + ) + if source_model == "lal": + return bilby.gw.source.lal_binary_black_hole( + self.frequency_array, minimum_frequency=20.0, **kwargs + ) + elif source_model == "frequency_sequence": + frequencies = self.frequency_array[self.frequency_array >= 20.0] + return bilby.gw.source.binary_black_hole_frequency_sequence( + self.frequency_array, frequencies=frequencies, **kwargs + ) + elif source_model == "relbin_fiducial": + return bilby.gw.source.lal_binary_black_hole_relative_binning( + self.frequency_array, minimum_frequency=20.0, fiducial=True, **kwargs + ) + elif source_model == "relbin_binned": + return bilby.gw.source.lal_binary_black_hole_relative_binning( + self.frequency_array, + minimum_frequency=20.0, + fiducial=False, + frequency_bin_edges=np.arange(20, 1500, 50), + **kwargs, + ) + raise ValueError(f"Unknown source model {source_model}") + + @parameterized.expand( + [(model, approx) for model in SOURCE_MODELS for approx in PRECESSING_APPROXIMANTS] + ) + def test_precessing_negative_mass_is_caught(self, source_model, approximant): + parameters = copy(self.precessing_parameters) + parameters["mass_1"] = -30.0 + self.assertIsNone(self.call_source(source_model, approximant, parameters)) + + @parameterized.expand( + [(model, approx) for model in SOURCE_MODELS for approx in ALIGNED_APPROXIMANTS] + ) + def test_aligned_negative_mass_is_caught(self, source_model, approximant): + parameters = copy(self.aligned_parameters) + parameters["mass_1"] = -30.0 + self.assertIsNone(self.call_source(source_model, approximant, parameters)) + + @parameterized.expand( + [(model, approx) for model in SOURCE_MODELS + for approx in PRECESSING_APPROXIMANTS + ALIGNED_APPROXIMANTS] + ) + def test_negative_mass_raises_when_not_catching(self, source_model, approximant): + parameters = copy(self.aligned_parameters) + parameters["mass_1"] = -30.0 + with self.assertRaises(RuntimeError): + self.call_source( + source_model, approximant, parameters, catch_waveform_errors=False + ) + + @parameterized.expand( + [(model, approx) for model in SOURCE_MODELS for approx in ALIGNED_APPROXIMANTS] + ) + def test_aligned_approximant_with_precessing_spins_raises(self, source_model, approximant): + with self.assertRaises(RuntimeError) as context: + self.call_source(source_model, approximant, self.precessing_parameters) + self.assertIn("Invalid argument", str(context.exception)) + + @parameterized.expand( + [(model, approx) for model in SOURCE_MODELS for approx in PRECESSING_APPROXIMANTS] + ) + def test_precessing_approximant_with_precessing_spins_works(self, source_model, approximant): + self.assertIsInstance( + self.call_source(source_model, approximant, self.precessing_parameters), + dict, + ) + + if __name__ == "__main__": unittest.main()