Coverage for pesummary/gw/conversions/time.py: 90.0%
20 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-12-09 22:34 +0000
« prev ^ index » next coverage.py v7.4.4, created at 2024-12-09 22:34 +0000
1# Licensed under an MIT style license -- see LICENSE.md
3import numpy as np
4from pesummary.utils.decorators import array_input
6__author__ = ["Charlie Hoy <charlie.hoy@ligo.org>"]
8try:
9 from lalsimulation import DetectorPrefixToLALDetector
10 from lal import C_SI
11 from astropy.time import Time
12except ImportError:
13 pass
16@array_input()
17def time_in_each_ifo(detector, ra, dec, time_gps):
18 """Return the event time in a given detector, given samples for ra, dec,
19 time
20 """
21 gmst = Time(time_gps, format='gps', location=(0, 0))
22 corrected_ra = gmst.sidereal_time('mean').rad - ra
24 i = np.cos(dec) * np.cos(corrected_ra)
25 j = np.cos(dec) * -1 * np.sin(corrected_ra)
26 k = np.sin(dec)
27 n = np.array([i, j, k])
29 dx = [0, 0, 0] - DetectorPrefixToLALDetector(detector).location
30 dt = dx.dot(n) / C_SI
31 return time_gps + dt