Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALInference 4.1.9.1-8a6b96f
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
test_detframe.py
Go to the documentation of this file.
1# Test program for functions mapping between Equatorial and Detector-based coordinate systems
2# Copyright (C) 2016 John Veitch <john.veitch@ligo.org>
3#
4# This program is free software; you can redistribute it and/or modify it
5# under the terms of the GNU General Public License as published by the
6# Free Software Foundation; either version 2 of the License, or (at your
7# option) any later version.
8#
9# This program is distributed in the hope that it will be useful, but
10# WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
12# Public License for more details.
13#
14# You should have received a copy of the GNU General Public License along
15# with this program; if not, write to the Free Software Foundation, Inc.,
16# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17#
18
19import sys
20
21import numpy as np
22from numpy.testing import assert_allclose
23
24import pytest
25
26import lal
27import lalinference as li
28
29NTEST = 1000
30
31LHO = lal.CachedDetectors[lal.LALDetectorIndexLHODIFF]
32LLO = lal.CachedDetectors[lal.LALDetectorIndexLLODIFF]
33
34RAS = np.random.uniform(low=0, high=lal.TWOPI, size=NTEST)
35DECS = np.random.uniform(low=-lal.PI/2.0, high=lal.PI/2.0, size=NTEST)
36TIMES = np.random.uniform(low=0, high=lal.DAYSID_SI, size=NTEST)
37
38
40 res = np.empty((3, NTEST))
41 for i, (ra, dec, time) in enumerate(zip(RAS, DECS, TIMES)):
42 forward = li.EquatorialToDetFrame(LHO, LLO, time, ra, dec)
43 res[:, i] = li.DetFrameToEquatorial(LHO, LLO, *forward)
44 for a, b, tol in zip((TIMES, RAS, DECS), res, (1e-6, 1e-5, 1e-5)):
45 assert_allclose(a, b, atol=tol)
46
47
48if __name__ == '__main__':
49 args = sys.argv[1:] or ["-v", "-rs", "--junit-xml=junit-detframe.xml"]
50 sys.exit(pytest.main(args=[__file__] + args))
def test_invertable()