-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobservations.py
45 lines (31 loc) · 1.08 KB
/
observations.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
import math
from typing import NamedTuple
from timestamp import Timestamp
def degangle_to_radians(angle: str):
s = angle.strip().split(" ")
sign = 1 if int(s[0]) >= 0 else -1
return (2.0*math.pi)/360.0 * (abs(int(s[0])) + int(s[1])/60.0 + float(s[2])/3600.0) * sign
def hourangle_to_radians(angle: str):
s = angle.strip().split(" ")
return (2.0 * math.pi) / 24.0 * (int(s[0]) + int(s[1]) / 60.0 + float(s[2]) / 3600.0)
class ObservationPoint(NamedTuple):
timestamp: Timestamp
RA: float # radians
DEC: float # radians
interpolated: bool
class Observations:
points: [ObservationPoint]
def __init__(self, fname):
self.points = []
f = open(fname)
while(f.readline() != "$$SOE\n"):
pass
while((r := f.readline()) != "$$EOE\n"):
s = r.split(",")
self.points.append(ObservationPoint(
Timestamp.create_from_ut(s[0]),
float(hourangle_to_radians(s[3])),
float(degangle_to_radians(s[4])),
False
))
f.close()