LAL  7.5.0.1-b72065a
test_antenna.py
Go to the documentation of this file.
1 # Copyright (C) 2018 Matthew Pitkin
2 #
3 # This program is free software; you can redistribute it and/or modify it
4 # under the terms of the GNU General Public License as published by the
5 # Free Software Foundation; either version 2 of the License, or (at your
6 # option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful, but
9 # WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
11 # Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License along
14 # with this program; if not, write to the Free Software Foundation, Inc.,
15 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 
17 """
18 Test code for antenna.py.
19 """
20 
21 import sys
22 
23 import numpy as np
24 from numpy.testing import assert_allclose
25 
26 from lal import DAYSID_SI
27 from lal.antenna import AntennaResponse
28 
29 import pytest
30 
31 # set values
32 PSI = np.random.uniform(0., 2.*np.pi)
33 RA = np.random.uniform(0., 2.*np.pi)
34 DEC = np.random.uniform(-np.pi/2., np.pi/2.)
35 
36 # set times over one sidereal day
37 T0 = 1234567890.
38 TIMES = np.linspace(T0, T0 + DAYSID_SI, 1000)
39 
40 
41 @pytest.mark.parametrize("detector", ("H1", "L1", "V1"))
42 def test_antenna(detector):
43  """
44  Test that the default, LAL and lookup table implementations match.
45  """
46  # default antenna pattern (all tensor, vector and scalar modes)
47  A = AntennaResponse(detector, ra=RA, dec=DEC, psi=PSI, times=TIMES,
48  use_lal=False, scalar=True, vector=True)
49 
50  # LAL-wrapped antenna pattern
51  B = AntennaResponse(detector, ra=RA, dec=DEC, psi=PSI, times=TIMES,
52  use_lal=True, scalar=True, vector=True)
53 
54  # look-up table
55  C = AntennaResponse(detector, ra=RA, dec=DEC, psi=PSI, times=TIMES,
56  lookup=True, scalar=True, vector=True)
57 
58  for key in ['plus', 'cross', 'x', 'y', 'b', 'l']:
59  assert_allclose(A.response[key], B.response[key])
60  assert_allclose(A.response[key], C.response[key], atol=1e-3)
61 
62 
63 if __name__ == '__main__':
64  args = sys.argv[1:] or ["-v", "-rs", "--junit-xml=junit-antenna.xml"]
65  sys.exit(pytest.main(args=[__file__] + args))
def test_antenna(detector)
Test that the default, LAL and lookup table implementations match.
Definition: test_antenna.py:45