forked from vain/asciiworld
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasciiworld-sat-calc
executable file
·58 lines (46 loc) · 1.54 KB
/
asciiworld-sat-calc
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
51
52
53
54
55
56
57
58
#!/usr/bin/env python3
# Based on code and ideas of trehn's termtrack:
# https://github.com/trehn/termtrack
from math import acos, degrees
import datetime
import ephem
import sys
lines = sys.stdin.read().strip().splitlines()
sat = ephem.readtle(*lines)
sat.compute(datetime.datetime.utcnow())
lon = sat.sublong
lat = sat.sublat
ele = sat.elevation
print('points')
print('{:f} {:f}'.format(degrees(lat), degrees(lon)))
print('.')
print('track')
orbital_period = 60 * 60 * 24 / sat._n
orbit_offset = 0
while orbit_offset < orbital_period:
orbit_offset += orbital_period / 150
sat.compute(datetime.datetime.utcnow() +
datetime.timedelta(seconds=orbit_offset))
print('{:f} {:f}'.format(degrees(sat.sublat), degrees(sat.sublong)))
print('.')
print('track')
orbit_offset = 0
while orbit_offset > -0.05 * orbital_period:
orbit_offset -= orbital_period / 150
sat.compute(datetime.datetime.utcnow() +
datetime.timedelta(seconds=orbit_offset))
print('{:f} {:f}'.format(degrees(sat.sublat), degrees(sat.sublong)))
print('.')
if not (len(sys.argv) > 1 and sys.argv[1] == '-F'):
# The satellite's footprint is a small circle centered at (lat, lon)
# with radius r (spherical distance).
print('circles')
r_earth = 6371000
try:
r = acos(r_earth / (r_earth + ele))
print('{:f} {:f} {:f}'.format(degrees(lat), degrees(lon), degrees(r)))
except ValueError:
print('Something is wrong with the elevation of the satellite: {}'.format(ele),
file=sys.stderr
)
print('.')