Conditions | 1 |
Total Lines | 29 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | from numba import jit |
||
6 | @jit("float64[:](float64, float64, float64[:], float64[:])", nopython=True) |
||
7 | def sphere_dist(ra1, dec1, ra2, dec2): # pragma: no cover |
||
8 | """ |
||
9 | Compute angular distance using the Haversine formula. Use this one when you know you will never ask for points at |
||
10 | their antipodes. If this is not the case, use the angular_distance function which is slower, but works also for |
||
11 | antipodes. |
||
12 | |||
13 | :param ra1: first RA (deg) |
||
14 | :param dec1: first Dec (deg) |
||
15 | :param ra2: second RA (deg) |
||
16 | :param dec2: second Dec (deg) |
||
17 | |||
18 | :returns: angular separation distance (deg) |
||
19 | """ |
||
20 | |||
21 | deg2rad = 0.017453292519943295 |
||
22 | rad2deg = 57.29577951308232 |
||
23 | |||
24 | lon1 = ra1 * deg2rad |
||
25 | lat1 = dec1 * deg2rad |
||
26 | lon2 = ra2 * deg2rad |
||
27 | lat2 = dec2 * deg2rad |
||
28 | dlon = lon2 - lon1 |
||
29 | dlat = lat2 - lat1 |
||
30 | |||
31 | a = np.sin(dlat/2.0)**2 + np.cos(lat1) * np.cos(lat2) * np.sin(dlon /2.0)**2 |
||
32 | c = 2 * np.arcsin(np.sqrt(a)) |
||
33 | |||
34 | return c * rad2deg |
||
35 |
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.