Skip to content

Commit 029f81c

Browse files
committed
Doc: add a test for match (22 and higher modes), limit to np<2.0.0 for pycbc
1 parent c8bec06 commit 029f81c

2 files changed

Lines changed: 93 additions & 1 deletion

File tree

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Requirements for most basic library
2-
numpy>=1.16.0,!=1.19.0
2+
numpy>=1.16.0,!=1.19.0,<2.0.0
33
scipy>=1.13.0
44
rich>=13.7.0
55
matplotlib>=3.7.3

tests/test_match.py

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
"""
2+
Test the Matcher class with a NR waveform
3+
"""
4+
5+
import numpy as np
6+
import matplotlib.pyplot as plt
7+
from PyART.catalogs import sxs
8+
from PyART.analysis.match import Matcher
9+
10+
sxs_id = '0180'
11+
nr = sxs.Waveform_SXS(ID=sxs_id, download=True, ignore_deprecation=True)
12+
nr_2 = sxs.Waveform_SXS(ID=sxs_id, download=False, ignore_deprecation=True)
13+
nr.cut(300)
14+
nr_2.cut(300)
15+
M = 100
16+
fmin = 5
17+
fmax = 2048
18+
srate = 8192
19+
20+
21+
22+
def test_self_match_ell_emms():
23+
"""
24+
Test that the self-match of the single modes
25+
is 1.0 within numerical accuracy.
26+
"""
27+
28+
settings={
29+
'kind':'single-mode',
30+
'initial_frequency_mm':fmin,
31+
'final_frequency_mm':fmax,
32+
'tlen':len(nr.u),
33+
'dt':1/srate,
34+
'M':M,
35+
'resize_factor':4,
36+
'modes-or-pol':'modes',
37+
'pad_end_frac':0.5,
38+
'taper_alpha':0.2,
39+
'taper_start':0.05,
40+
'taper':'sigmoid',
41+
'debug':False
42+
}
43+
44+
for mode in nr.hlm.keys():
45+
these_settings = settings.copy()
46+
these_settings['modes'] = [mode]
47+
m = Matcher(nr, nr_2, settings=settings)
48+
match = 1 - m.mismatch
49+
assert np.isclose(match, 1.0, atol=1e-7)
50+
51+
def test_self_match_pol():
52+
"""
53+
Test that the self-match of the two polarizations
54+
is 1.0 within numerical accuracy.
55+
"""
56+
57+
settings={
58+
'kind':'hm',
59+
'initial_frequency_mm':fmin,
60+
'final_frequency_mm':fmax,
61+
'tlen':len(nr.u),
62+
'dt':1/srate,
63+
'M':M,
64+
'resize_factor':4,
65+
'pad_end_frac':0.5,
66+
'taper_alpha':0.2,
67+
'taper_start':0.05,
68+
'taper':'sigmoid',
69+
'debug':True,
70+
}
71+
72+
def test_self_match_pol_helper(cp, ep):
73+
"""
74+
Helper function to test self-match for given
75+
coalescence phase and effective polarization.
76+
"""
77+
78+
settings_cp = settings.copy()
79+
settings_cp['coa_phase'] = [cp]
80+
settings_cp['eff_pols'] = [ep]
81+
82+
m = Matcher(nr, nr_2, settings=settings_cp)
83+
match = 1 - m.mismatch
84+
assert np.isclose(match, 1.0, atol=1e-7)
85+
print(f'cp: {cp:.2f}, ep: {ep:.2f}, match: {match}')
86+
87+
for cp in [0, np.pi/4, np.pi/2]:
88+
for ep in [0, np.pi/4, np.pi/2]:
89+
test_self_match_pol_helper(cp, ep)
90+
91+
pass
92+

0 commit comments

Comments
 (0)