Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALSimulation 6.2.0.1-8a6b96f
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
test_phenomPv3HM.py
Go to the documentation of this file.
1# -*- coding: utf-8 -*-
2#
3# Copyright (C) 2020 Sebastian Khan
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation, either version 3 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program. If not, see <http: //www.gnu.org/licenses/>.
17
18"""Simple test to see if PhenomPv3HM has changed
19"""
20
21import sys
22import pytest
23import lal
24import lalsimulation
25import numpy as np
26
27# -- utility functions ---------------------
28
30 amp = np.abs(h)
31 phase = np.unwrap(np.angle(h))
32 return amp, phase
33
34def sum_sqr_diff(x, y):
35 return np.sqrt( np.sum( (x-y)**2 ) )
36
37def gen_test_data():
38 """
39 compute the difference between two waveforms
40 and compare to expected value
41 """
42
43 common_pars=dict(
44 m1=50*lal.MSUN_SI,
45 m2=30*lal.MSUN_SI,
46 S1x=0.5,
47 S1y=0.,
48 S1z=0.,
49 S2x=0.,
50 S2y=0.,
51 S2z=0.,
52 distance=1,
53 inclination=0.,
54 phiRef=0.,
55 longAscNodes=0.,
56 eccentricity=0.,
57 meanPerAno=0.,
58 deltaF=1./4.,
59 f_min=30.,
60 f_max=512.,
61 f_ref=30.,
62 LALpars=None,
63 approximant=lalsimulation.IMRPhenomPv3HM
64 )
65
66 pars1=common_pars.copy()
67
68 pars2=common_pars.copy()
69 pars2.update({"m2":20.*lal.MSUN_SI})
70
71 hp1, hc1 = lalsimulation.SimInspiralChooseFDWaveform(**pars1)
72 hp2, hc2 = lalsimulation.SimInspiralChooseFDWaveform(**pars2)
73
74 # compute amp and phase
75 hp1_amp, hp1_phase = get_amp_phase(hp1.data.data)
76 hc1_amp, hc1_phase = get_amp_phase(hc1.data.data)
77
78 hp2_amp, hp2_phase = get_amp_phase(hp2.data.data)
79 hc2_amp, hc2_phase = get_amp_phase(hc2.data.data)
80
81 hp_amp_diff = sum_sqr_diff(hp1_amp, hp2_amp)
82 hp_phase_diff = sum_sqr_diff(hp1_phase, hp2_phase)
83
84 hc_amp_diff = sum_sqr_diff(hc1_amp, hc2_amp)
85 hc_phase_diff = sum_sqr_diff(hc1_phase, hc2_phase)
86
87 return hp_amp_diff, hp_phase_diff, hc_amp_diff, hc_phase_diff
88
89
90
91# -- test functions ---------------------
92
94 """
95 This test checks that IMRPhenomPv3HM hasn't changed.
96 It does this by generating two PhenomPv3HM waveforms and computing
97 their difference (according to their amplitude and phases)
98 and compares them to pre-computed values.
99
100 these pre-computed values were computed using the following line:
101
102 `expected_result = np.array(gen_test_data())`
103
104 """
105
106 expected_result = np.array([1533.69290062, 324.65008927, 1541.09248084, 323.69338373])
107
108 new_result = np.array(gen_test_data())
109
110 np.testing.assert_almost_equal(new_result, expected_result, 7, "IMRPhenomPv3HM test failed")
111
112
113
114# -- run the tests ------------------------------
115
116if __name__ == '__main__':
117 args = sys.argv[1:] or ["-v", "-rs", "--junit-xml=junit-phenomPv3HM.xml"]
118 sys.exit(pytest.main(args=[__file__] + args))
def test_IMRPhenomPv3HM()
This test checks that IMRPhenomPv3HM hasn't changed.
def sum_sqr_diff(x, y)
def gen_test_data()
compute the difference between two waveforms and compare to expected value