diff --git a/bilby/gw/detector/networks.py b/bilby/gw/detector/networks.py index 4efd3d8db..b56306b52 100644 --- a/bilby/gw/detector/networks.py +++ b/bilby/gw/detector/networks.py @@ -358,6 +358,8 @@ def __init__( if isinstance(maximum_frequency, float) or isinstance(maximum_frequency, int): maximum_frequency = [maximum_frequency] * 3 + brng = 90 - xarm_azimuth + for ii in range(3): self.append( Interferometer( @@ -376,29 +378,23 @@ def __init__( ) ) - xarm_azimuth += 240 - yarm_azimuth += 240 - - latitude += ( - np.arctan( - length - * np.sin(xarm_azimuth * np.pi / 180) - * 1e3 - / utils.radius_of_earth - ) - * 180 - / np.pi + phi1 = np.radians(latitude) + phi2 = np.arcsin( + np.sin(phi1) * np.cos(length * 1e3 / utils.radius_of_earth) + + np.cos(phi1) * np.sin(length * 1e3 / utils.radius_of_earth) * np.cos(np.radians(brng)) ) - longitude += ( - np.arctan( - length - * np.cos(xarm_azimuth * np.pi / 180) - * 1e3 - / utils.radius_of_earth - ) - * 180 - / np.pi + latitude = np.degrees(phi2) + + lam1 = np.radians(longitude) + lam2 = lam1 + np.arctan2( + np.sin(np.radians(brng)) * np.sin(length * 1e3 / utils.radius_of_earth) * np.cos(phi1), + np.cos(length * 1e3 / utils.radius_of_earth) - np.sin(phi1) * np.sin(phi2) ) + longitude = np.degrees(lam2) + + brng += 240 + xarm_azimuth += 240 + yarm_azimuth += 240 def get_empty_interferometer(name): diff --git a/test/gw/detector/networks_test.py b/test/gw/detector/networks_test.py index 6f7b211d3..942bd882f 100644 --- a/test/gw/detector/networks_test.py +++ b/test/gw/detector/networks_test.py @@ -387,7 +387,7 @@ def c(a): for pair in list(combinations(self.triangular_ifo, 2)): delta_lat = np.radians(pair[1].latitude - pair[0].latitude) delta_long = np.radians(pair[1].longitude - pair[0].longitude) - pair_a = a(delta_lat, delta_long, pair[0].latitude, pair[1].latitude) + pair_a = a(delta_lat, delta_long, np.radians(pair[0].latitude), np.radians(pair[1].latitude)) pair_c = c(pair_a) distance = bilby.core.utils.radius_of_earth * pair_c self.assertAlmostEqual(distance / 1000, pair[0].length, delta=1)