Skip to content

Commit e8001bb

Browse files
Fix a small error in the construction of the circular sky grid (#5175)
1 parent 6ebc2ce commit e8001bb

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

bin/pycbc_make_sky_grid

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ gravitational wave triggers and calculate the coherent SNRs and related
88
statistics.
99
1010
The grid is constructed following the method described in Section V of
11-
https://arxiv.org/abs/1410.6042.
11+
Williamson et al 2014, https://arxiv.org/abs/1410.6042.
1212
1313
Please refer to help(pycbc.types.angle_as_radians) for the recommended
1414
configuration file syntax for angle arguments.
@@ -84,24 +84,31 @@ def make_multi_det_grid(args):
8484
]
8585
angular_spacing = min(ang_spacings)
8686

87-
sky_points = np.zeros((1, 2))
87+
# The first point is always exactly at the North pole
88+
sky_points = [
89+
[0, np.pi / 2]
90+
]
8891

92+
# Generate the sky grid centered at the North pole
8993
number_of_rings = int(args.sky_error / angular_spacing)
94+
for i in range(1, number_of_rings + 1):
95+
# Note: Williamson et al 2014 states that the number of points in the
96+
# i-th ring is 2πi / x, with x the angular spacing. This is not correct.
97+
# In the approximation where the error radius is tiny (i.e. the initial
98+
# grid stays close to the North pole) the correct number is 2πi.
99+
# However, here we implement the general case, correct over the whole
100+
# extent of the polar angle, for which the number is instead
101+
# 2π cos(π/2 - ix) / x.
102+
polar_angle = np.pi / 2 - i * angular_spacing
103+
number_of_points = round(
104+
2 * np.pi * np.cos(polar_angle) / angular_spacing
105+
)
106+
sky_points += [
107+
[2 * np.pi * j / number_of_points, polar_angle]
108+
for j in range(number_of_points)
109+
]
90110

91-
# Generate the sky grid centered at the North pole
92-
for i in range(number_of_rings + 1):
93-
if i == 0:
94-
sky_points[0][0] = 0
95-
sky_points[0][1] = np.pi / 2
96-
else:
97-
number_of_points = int(2 * np.pi * i)
98-
for j in range(number_of_points):
99-
sky_points = np.row_stack(
100-
(
101-
sky_points,
102-
np.array([j / i, np.pi / 2 - i * angular_spacing]),
103-
)
104-
)
111+
sky_points = np.array(sky_points)
105112

106113
# Convert spherical coordinates to cartesian coordinates
107114
cart = spher_to_cart(sky_points)

0 commit comments

Comments
 (0)