18"""Simple test to see if the PhenomX family models have changed: IMRPhenomXAS, IMRPhenomXHM, IMRPhenomXP, IMRPhenomXPHM, IMRPhenomXAS_NRTidalv2, IMRPhenomXP_NRTidalv2, and IMRPhenomXO4a.
31 phase = np.unwrap(np.angle(h))
35 return np.sqrt( np.sum( (x-y)**2 ) )
38def gen_test_data(spin1x, approximant, mode_array, lalparams = None, type='bbh', generic_spins=False,deltaF=1./4.,release=None):
40 compute the difference between two waveforms
41 and compare to expected value
43 type: should either be
'bbh' or 'bns'
44 generic_spins: Use generic spins (
with in-plane spins scaled
from spin1x, which must be at most ~0.69,
and aligned spins hard-coded)
if True;
45 otherwise the only potentially nonzero spin component
is spin1x
49 if(lalparams == None):
50 lalparams = lal.CreateDict()
53 ModeArray = lalsimulation.SimInspiralCreateModeArray()
54 for mode
in mode_array:
55 lalsimulation.SimInspiralModeArrayActivateMode(ModeArray, mode[0], mode[1])
56 lalsimulation.SimInspiralWaveformParamsInsertModeArray(lalparams, ModeArray)
58 if release
is not None:
59 lalsimulation.SimInspiralWaveformParamsInsertPhenomXHMReleaseVersion(lalparams, release)
62 m1_sel = 50*lal.MSUN_SI
63 m2_sel = 30*lal.MSUN_SI
64 m2_sel_prime = 20.*lal.MSUN_SI
67 m1_sel = 1.6*lal.MSUN_SI
68 m2_sel = 1.4*lal.MSUN_SI
69 m2_sel_prime = 1.3*lal.MSUN_SI
72 lalsimulation.SimInspiralWaveformParamsInsertTidalLambda1(lalparams, 200.)
73 lalsimulation.SimInspiralWaveformParamsInsertTidalLambda2(lalparams, 300.)
75 raise ValueError(
"Unknown binary type")
100 inclination=np.pi/3.,
110 approximant=approximant
113 pars1=common_pars.copy()
115 pars2=common_pars.copy()
116 pars2.update({
"m2":m2_sel_prime})
118 hp1, hc1 = lalsimulation.SimInspiralChooseFDWaveform(**pars1)
119 hp2, hc2 = lalsimulation.SimInspiralChooseFDWaveform(**pars2)
134 return hp_amp_diff, hp_phase_diff, hc_amp_diff, hc_phase_diff
142 This test checks that IMRPhenomXAS hasn't changed.
143 It does this by generating two PhenomXAS waveforms and computing
144 their difference (according to their amplitude
and phases)
145 and compares them to pre-computed values.
147 these pre-computed values were computed using the following line:
149 `expected_result = np.array(
gen_test_data(0., lalsimulation.IMRPhenomXAS,
None, generic_spins=
True))`
153 expected_result = np.array([787.00663452, 165.89210208, 629.60530761, 165.89210208])
155 new_result = np.array(gen_test_data(0., lalsimulation.IMRPhenomXAS, None, generic_spins=
True))
157 np.testing.assert_allclose(new_result, expected_result, rtol=1e-6, err_msg=
"IMRPhenomXAS test failed")
161 This test checks that IMRPhenomXHM hasn't changed.
162 It does this by generating two PhenomXHM waveforms and computing
163 their difference (according to their amplitude
and phases)
164 and compares them to pre-computed values.
166 these pre-computed values were computed using the following line:
168 `expected_result = np.array(
gen_test_data(0., lalsimulation.IMRPhenomXHM, mode_array))`
170 where mode_array
is [[2,2],[2,-2],[2,1],[2,-1],[3,3],[3,-3],[4,4],[4,-4]]
or [[3,2],[3,-2]]
175 expected_result = np.array([1005.16009183, 169.88197475, 768.18401876, 169.12711241])
177 new_result = np.array(gen_test_data(0., lalsimulation.IMRPhenomXHM, [[2,2],[2,-2],[2,1],[2,-1],[3,3],[3,-3],[4,4],[4,-4]], release=122019))
179 np.testing.assert_allclose(new_result, expected_result, rtol=1e-6, err_msg="IMRPhenomXHM (122019) no 32 mode test failed")
181 expected_result = np.array([ 32.17818789, 216.01992794, 4.02227349, 215.97103911])
183 new_result = np.array(
gen_test_data(0., lalsimulation.IMRPhenomXHM, [[3,2],[3,-2]], release=122019))
186 np.testing.assert_allclose(new_result, expected_result, rtol=3e-4, err_msg=
"IMRPhenomXHM (122019) 32 mode test failed")
188 expected_result = np.array([1005.01319319, 169.88945372, 768.34648494, 169.13261004])
190 new_result = np.array(
gen_test_data(0., lalsimulation.IMRPhenomXHM, [[2,2],[2,-2],[2,1],[2,-1],[3,3],[3,-3],[4,4],[4,-4]]))
192 np.testing.assert_allclose(new_result, expected_result, rtol=1e-6, err_msg=
"IMRPhenomXHM no 32 mode test failed")
194 expected_result = np.array([34.62153262, 218.09073730, 4.32769157, 218.09073730])
196 new_result = np.array(
gen_test_data(0., lalsimulation.IMRPhenomXHM, [[3,2],[3,-2]]))
199 np.testing.assert_allclose(new_result, expected_result, rtol=3.1e-4, err_msg=
"IMRPhenomXHM 32 mode test failed")
203 This test checks that IMRPhenomXP hasn't changed.
204 It does this by generating two PhenomXP waveforms and computing
205 their difference (according to their amplitude
and phases)
206 and compares them to pre-computed values.
208 these pre-computed values were computed using the following line:
210 `expected_result = np.array(
gen_test_data(0.5, lalsimulation.IMRPhenomXP,
None, generic_spins=
False))`
213 lalDict = lal.CreateDict()
214 lalsimulation.SimInspiralWaveformParamsInsertPhenomXPrecVersion(lalDict, 223)
215 lalsimulation.SimInspiralWaveformParamsInsertPhenomXPFinalSpinMod(lalDict, 2)
217 expected_result = np.array([1070.22089507, 271.62095671, 533.04876588, 268.4520146])
219 new_result = np.array(gen_test_data(0.5, lalsimulation.IMRPhenomXP, None, generic_spins=
False))
221 np.testing.assert_allclose(new_result, expected_result, rtol=1e-6, err_msg=
"IMRPhenomXP test failed")
226 This test checks that IMRPhenomXP with the NNLO precession option (version 102) hasn
't changed.
227 It does this by generating two PhenomXP waveforms and computing
228 their difference (according to their amplitude
and phases)
229 and compares them to pre-computed values.
231 these pre-computed values were computed using the following code:
233 `lalDict = lal.CreateDict()`
235 `lalsimulation.SimInspiralWaveformParamsInsertPhenomXPrecVersion(lalDict, 102)`
237 `expected_result = np.array(
gen_test_data(0.5, lalsimulation.IMRPhenomXP,
None, lalparams=lalDict, generic_spins=
False))`
241 lalDict = lal.CreateDict()
242 lalsimulation.SimInspiralWaveformParamsInsertPhenomXPrecVersion(lalDict, 102)
244 expected_result = np.array([1235.47048998, 226.22617618, 1049.4091208, 225.46870308])
246 new_result = np.array(gen_test_data(0.5, lalsimulation.IMRPhenomXP, None, lalparams=lalDict, generic_spins=
True))
248 np.testing.assert_allclose(new_result, expected_result, rtol=1e-6, err_msg=
"IMRPhenomXP_NNLO test failed")
254 This test checks that IMRPhenomXP hasn't changed.
255 It does this by generating two PhenomXP waveforms and computing
256 their difference (according to their amplitude
and phases)
257 and compares them to pre-computed values.
259 these pre-computed values were computed using the following line:
261 `expected_result = np.array(
gen_test_data(0.5, lalsimulation.IMRPhenomXP,
None, generic_spins=
True))`
263 FIXME: This description needs to be corrected
if this
is kept.
266 lalDict = lal.CreateDict()
267 lalsimulation.SimInspiralWaveformParamsInsertPhenomXPrecVersion(lalDict, 223)
269 expected_result = np.array([1468.09702243, 190.76614342, 972.51053189, 189.80404795])
271 new_result = np.array(gen_test_data(0.5, lalsimulation.IMRPhenomXPHM, [[2,2]], lalparams=lalDict, generic_spins=True))
273 np.testing.assert_allclose(new_result, expected_result, rtol=1e-6, err_msg=
"IMRPhenomXP_MB test failed")
278 This test checks that IMRPhenomXP with the SpinTaylor precession option (version 310) hasn
't changed.
279 It does this by generating two PhenomXP waveforms and computing
280 their difference (according to their amplitude
and phases)
281 and compares them to pre-computed values.
283 these pre-computed values were computed using the following code:
285 `lalDict = lal.CreateDict()`
287 `lalsimulation.SimInspiralWaveformParamsInsertPhenomXPrecVersion(lalDict, 310)`
289 `expected_result = np.array(
gen_test_data(0.5, lalsimulation.IMRPhenomXP,
None, lalparams=lalDict, generic_spins=
True))`
293 expected_result = np.array([1570.905974, 190.514064, 1107.696605, 195.697882])
295 lalDict = lal.CreateDict()
297 lalsimulation.SimInspiralWaveformParamsInsertPhenomXPrecVersion(lalDict, 310)
299 new_result = np.array(gen_test_data(0.5, lalsimulation.IMRPhenomXP, None, lalparams=lalDict, generic_spins=
True))
301 np.testing.assert_allclose(new_result, expected_result, rtol=1e-6, err_msg=
"IMRPhenomXP test failed")
306 This test checks that IMRPhenomXPHM hasn't changed.
307 It does this by generating two PhenomXPHM waveforms and computing
308 their difference (according to their amplitude
and phases)
309 and compares them to pre-computed values.
311 these pre-computed values were computed using the following line:
313 `expected_result = np.array(
gen_test_data(0.5, lalsimulation.IMRPhenomXPHM, mode_array, generic_spins=
True))`
315 where mode_array
is [[2,2],[2,1],[3,3],[4,4]]
or [[3,2]]
320 expected_result = np.array([1166.01091848, 334.5693217, 767.82099062, 326.09652364])
322 new_result = np.array(gen_test_data(0.5, lalsimulation.IMRPhenomXPHM, [[2,2],[2,1],[3,3],[4,4]], release=122019))
325 np.testing.assert_allclose(new_result, expected_result, rtol=1e-5, err_msg=
"IMRPhenomXPHM (122019) no 32 mode test failed")
328 expected_result = np.array([68.9282789725476, 240.20999880535206, 25.111569754767224, 234.7465084316962])
330 new_result = np.array(
gen_test_data(0.5, lalsimulation.IMRPhenomXPHM, [[3,2]], release=122019))
333 np.testing.assert_allclose(new_result, expected_result, rtol=3e-4, err_msg=
"IMRPhenomXPHM (122019) 32 mode test failed")
335 expected_result = np.array([1166.77270896, 334.86014307, 768.93672645, 326.38518250])
337 new_result = np.array(
gen_test_data(0.5, lalsimulation.IMRPhenomXPHM, [[2,2],[2,1],[3,3],[4,4]]))
340 np.testing.assert_allclose(new_result, expected_result, rtol=1.3e-5, err_msg=
"IMRPhenomXPHM no 32 mode test failed")
342 expected_result = np.array([71.43504434, 242.82287296, 26.54528442, 237.35077401])
344 new_result = np.array(
gen_test_data(0.5, lalsimulation.IMRPhenomXPHM, [[3,2]]))
347 np.testing.assert_allclose(new_result, expected_result, rtol=3e-4, err_msg=
"IMRPhenomXPHM 32 mode test failed")
351 This test checks that IMRPhenomXO4a hasn't changed.
352 It does this by generating two IMRPhenomXO4a waveforms and computing
354 `expected_result = np.array(
gen_test_data(0.5, lalsimulation.IMRPhenomXO4a))`
358 expected_result = np.array([1147.6076128830048, 202.16395516656954, 835.6550472580194, 322.56504443715437])
360 new_result = np.array(gen_test_data(0.5, lalsimulation.IMRPhenomXO4a, [[2,2],[2,1],[3,3],[4,4]]))
363 np.testing.assert_allclose(new_result, expected_result, rtol=1e-5, err_msg=
"IMRPhenomXO4a no 32 mode test failed")
366 expected_result = np.array([48.56332295620956, 236.22060412141988, 21.61676721381083, 232.43479133460966])
367 new_result = np.array(
gen_test_data(0.5, lalsimulation.IMRPhenomXO4a, [[3,2]]))
370 np.testing.assert_allclose(new_result, expected_result, rtol=3e-3, err_msg=
"IMRPhenomXO4a 32 mode test failed")
374 This test checks that IMRPhenomXPHM with the SpinTaylor precession option (version 310) hasn
't changed.
375 It does this by generating two PhenomXPHM waveforms and computing
376 their difference (according to their amplitude
and phases)
377 and compares them to pre-computed values.
379 these pre-computed values were computed using the following code:
381 `lalDict = lal.CreateDict()`
383 `lalsimulation.SimInspiralWaveformParamsInsertPhenomXPrecVersion(lalDict, 310)`
385 `expected_result = np.array(
gen_test_data(0.5, lalsimulation.IMRPhenomXPHM, mode_array, lalparams=lalDict, generic_spins=
True))`
387 where mode_array
is [[2,2],[2,1],[3,3],[4,4]]
or [[3,2]]
391 expected_result = np.array([1688.30370786, 274.96949069, 1248.22149474, 279.10374629])
393 lalDict = lal.CreateDict()
395 lalsimulation.SimInspiralWaveformParamsInsertPhenomXPrecVersion(lalDict, 310)
397 new_result = np.array(gen_test_data(0.5, lalsimulation.IMRPhenomXPHM, [[2,2],[2,1],[3,3],[4,4]], lalparams=lalDict, generic_spins=True,release=122019))
400 np.testing.assert_allclose(new_result, expected_result, rtol=1e-5, err_msg=
"IMRPhenomXPHM no 32 mode test failed")
403 expected_result = np.array([12.68276953, 170.44495875, 42.97960664, 142.53609984])
405 new_result = np.array(
gen_test_data(0.5, lalsimulation.IMRPhenomXPHM, [[3,2]], lalparams=lalDict, generic_spins=
True,release=122019))
408 np.testing.assert_allclose(new_result, expected_result, rtol=5e-4, err_msg=
"IMRPhenomXPHM 32 mode test failed")
413 This test checks that IMRPhenomXAS_NRTidalv2 hasn't changed.
414 It does this by generating two IMRPhenomXAS_NRTidalv2 waveforms and computing
415 their difference (according to their amplitude
and phases)
416 and compares them to pre-computed values.
418 these pre-computed values were computed using the following line:
420 `expected_result = np.array(
gen_test_data(0., lalsimulation.IMRPhenomXAS_NRTidalv2,
None, type=
"bns", generic_spins=
True))`
424 expected_result = np.array([10.04639297, 561.5921041 ,8.03711438, 561.62725166])
426 new_result = np.array(gen_test_data(0., lalsimulation.IMRPhenomXAS_NRTidalv2, None, type=
'bns', generic_spins=
True))
428 np.testing.assert_allclose(new_result, expected_result, rtol=1e-6, err_msg=
"IMRPhenomXAS_NRTidalv2 test failed")
433 This test checks that IMRPhenomXP_NRTidalv2 hasn't changed.
434 It does this by generating two IMRPhenomXP_NRTidalv2 waveforms and computing
435 their difference (according to their amplitude
and phases)
436 and compares them to pre-computed values.
438 these pre-computed values were computed using the following line:
440 `expected_result = np.array(
gen_test_data(0.2, lalsimulation.IMRPhenomXP_NRTidalv2,
None, type=
"bns", generic_spins=
True))`
444 lalDict = lal.CreateDict()
446 expected_result = np.array([ 13.9202092 , 561.0238095 , 19.05392711, 550.93840153])
448 new_result = np.array(gen_test_data(0.2, lalsimulation.IMRPhenomXP_NRTidalv2, None, type=
'bns', lalparams=lalDict, generic_spins=
True))
449 np.testing.assert_allclose(new_result, expected_result, rtol=1e-6, err_msg=
"IMRPhenomXP_NRTidalv2 test failed")
454 This test checks that IMRPhenomXP_NRTidalv2 with the SpinTaylor precession (version 310) hasn
't changed.
455 It does this by generating two IMRPhenomXP_NRTidalv2 waveforms and computing
456 their difference (according to their amplitude
and phases)
457 and compares them to pre-computed values.
459 these pre-computed values were computed using the following code:
461 `lalDict = lal.CreateDict()`
463 `lalsimulation.SimInspiralWaveformParamsInsertPhenomXPrecVersion(lalDict, 310)`
465 `expected_result = np.array(
gen_test_data(0.2, lalsimulation.IMRPhenomXP_NRTidalv2,
None, lalparams=lalDict, type=
"bns", generic_spins=
True))`
469 expected_result = np.array([11.92543681, 730.77807026, 13.69906426, 552.53065783])
471 lalDict = lal.CreateDict()
473 lalsimulation.SimInspiralWaveformParamsInsertPhenomXPrecVersion(lalDict, 310)
475 new_result = np.array(gen_test_data(0.2, lalsimulation.IMRPhenomXP_NRTidalv2, None, lalparams=lalDict, type=
'bns', generic_spins=
True))
477 np.testing.assert_allclose(new_result, expected_result, rtol=1e-6, err_msg=
"IMRPhenomXP_NRTidalv2 test failed")
482 This test checks that IMRPhenomXO4a hasn't changed.
483 It does this by generating two IMRPhenomXO4a waveforms and computing
485 `expected_result = np.array(
gen_test_data(0.5, lalsimulation.IMRPhenomXO4a))`
489 expected_result = np.array([1149.25272956272488, 201.90592114484070, 830.22645041272130, 321.89849276096191])
491 new_result = np.array(gen_test_data(0.5, lalsimulation.IMRPhenomXPNR, [[2,2],[2,1],[3,3],[4,4]]))
494 np.testing.assert_allclose(new_result, expected_result, rtol=1e-5, err_msg=
"IMRPhenomXPNR no 32 mode test failed")
497 expected_result = np.array([47.9973923614742546, 235.9677577246995384, 21.6471155649431743, 231.9826404417289041])
499 new_result = np.array(
gen_test_data(0.5, lalsimulation.IMRPhenomXPNR, [[3,2]]))
502 np.testing.assert_allclose(new_result, expected_result, rtol=3e-3, err_msg=
"IMRPhenomXPNR 32 mode test failed")
506if __name__ ==
'__main__':
507 args = sys.argv[1:]
or [
"-v",
"-rs",
"--junit-xml=junit-phenomX.xml"]
508 sys.exit(pytest.main(args=[__file__] + args))
def test_IMRPhenomXPHM_SpinTaylor()
This test checks that IMRPhenomXPHM with the SpinTaylor precession option (version 310) hasn't change...
def test_IMRPhenomXPHM()
This test checks that IMRPhenomXPHM hasn't changed.
def test_IMRPhenomXP_MB()
This test checks that IMRPhenomXP hasn't changed.
def test_IMRPhenomXPNR()
This test checks that IMRPhenomXO4a hasn't changed.
def test_IMRPhenomXO4a()
This test checks that IMRPhenomXO4a hasn't changed.
def test_IMRPhenomXAS_NRTidalv2()
This test checks that IMRPhenomXAS_NRTidalv2 hasn't changed.
def test_IMRPhenomXP_NRTidalv2()
This test checks that IMRPhenomXP_NRTidalv2 hasn't changed.
def test_IMRPhenomXP_NNLO()
This test checks that IMRPhenomXP with the NNLO precession option (version 102) hasn't changed.
def test_IMRPhenomXP()
This test checks that IMRPhenomXP hasn't changed.
def test_IMRPhenomXP_NRTidalv2_SpinTaylor()
This test checks that IMRPhenomXP_NRTidalv2 with the SpinTaylor precession (version 310) hasn't chang...
def test_IMRPhenomXP_SpinTaylor()
This test checks that IMRPhenomXP with the SpinTaylor precession option (version 310) hasn't changed.
def test_IMRPhenomXAS()
This test checks that IMRPhenomXAS hasn't changed.
def test_IMRPhenomXHM()
This test checks that IMRPhenomXHM hasn't changed.
def gen_test_data(spin1x, approximant, mode_array, lalparams=None, type='bbh', generic_spins=False, deltaF=1./4., release=None)
compute the difference between two waveforms and compare to expected value