-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.py
50 lines (40 loc) · 1.25 KB
/
util.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import numpy as np
def stereographicProjection(alt, az):
"""Project stars onto a 2D plane stereographically.
Parameters
----------
alt : np.ndarray
The altitude of a star, relative to an observer.
Values are processed as radians.
az : np.ndarray
The azimuth of a star, relative to an observer.
Values are processed as radians.
Returns
-------
(np.ndarray, np.ndarray)
The (x, y) coordinates of each star, projected onto a 2D plane
stereographically.
"""
x = np.cos(alt) * np.sin(az)
y = np.cos(alt) * np.cos(az)
z = np.sin(alt)
return x/(1+z), y/(1+z)
def cylindricalProjection(alt, az):
"""Project stars onto an equirectangular plan.
Parameters
----------
alt : np.ndarray
The altitude of a star, relative to an observer.
Values are processed as radians.
az : np.ndarray
The azimuth of a star, relative to an observer.
Values are processed as radians.
Returns
-------
(np.ndarray, np.ndarray)
The (x, y) coordinates of each star, calculated using an
equirectangular projection, to maintain equal areas.
"""
x = np.interp(az, [0, 2*np.pi], [-1, +1])
y = np.sin(alt)
return x, y