-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathautotrack.py
49 lines (44 loc) · 2.13 KB
/
autotrack.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
import calcorbit as co
import time
from datetime import datetime, timedelta
from serial.tools import list_ports
import serial
import pyorbital
from pyorbital import orbital
gela=( 24.5730,41.6500015, 1.463) # Coordinates of Gela, Bulgaria
gelaLon, gelaLat, gelaAlt = gela
try:
port = [x for x in list(serial.tools.list_ports.comports())[0] if 'ACM' in x][0]
ser = serial.Serial(port, 9600)
time.sleep(.1) # does not work without the delay
except:
print('no serial ports available')
# pyorbital.tlefile.fetch('tle.txt')
while 1:
name = co.norad_to_name(input("Sat Name: "))
print(name)
try:
az,el = co.get_next_sat_coordinates(name,datetime.utcnow())
az=az if az <=180 else 360-az
except:
print("sat not found")
continue
if(el>0):
try:
print("apogey time:",str(orbital.Orbital(name,tle_file="tle.txt").get_next_passes(datetime.utcnow()-timedelta(hours=12), 12, gelaLon, gelaLat, gelaAlt)[-1][2]+timedelta(hours=3))[11:19])
print("setting time:",str(orbital.Orbital(name,tle_file="tle.txt").get_next_passes(datetime.utcnow()-timedelta(hours=12), 12, gelaLon, gelaLat, gelaAlt)[-1][1]+timedelta(hours=3))[11:19])
except:
pass
while el > 0:
az,el = co.get_next_sat_coordinates(name,datetime.utcnow())
az=az if az <=180 else 360-az
s=f'AZ{round(-az,1)} EL{round(el,1)}\n'.encode()
print(round(az,1), round(el,1))
ser.write(s)
time.sleep(1)
print("sat is below horizon")
print("rising time:",str(orbital.Orbital(name,tle_file="tle.txt").get_next_passes(datetime.utcnow(), 12, gelaLon, gelaLat, gelaAlt)[0][0]+timedelta(hours=3))[11:19])
print("apogey time:",str(orbital.Orbital(name,tle_file="tle.txt").get_next_passes(datetime.utcnow(), 12, gelaLon, gelaLat, gelaAlt)[0][2]+timedelta(hours=3))[11:19])
print("setting time:",str(orbital.Orbital(name,tle_file="tle.txt").get_next_passes(datetime.utcnow(), 12, gelaLon, gelaLat, gelaAlt)[0][1]+timedelta(hours=3))[11:19])
print("max elevation",orbital.Orbital(name,tle_file="tle.txt").get_observer_look(orbital.Orbital(name,tle_file="tle.txt").get_next_passes(datetime.utcnow(), 12, gelaLon, gelaLat, gelaAlt)[0][2], gelaLon, gelaLat, gelaAlt)[1])
# input('press any key to exit')