forked from mjip/trashgazing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobserve.py
executable file
Β·57 lines (50 loc) Β· 1.43 KB
/
observe.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
51
52
53
54
55
56
57
from sgp4.earth_gravity import wgs84
from sgp4.io import twoline2rv
from sgp4.ext import jday
from geocart import geo2cart, cart2geo
from spacetrack import SpaceTrackClient
import os
import getpass
from datetime import datetime
satellites = []
def download_tle():
"""
Because the API is unstable, we can download it for testing
"""
user = ""
password = ""
c = SpaceTrackClient(user, password)
c.authenticate()
data = c.get_space_debris()
with open('tle.txt', 'w') as f:
f.write(data)
c.close()
def load_tle_data():
now = datetime.now()
with open('tle.txt', 'r') as f:
while True:
try:
line1 = f.readline()
line2 = f.readline()
debris = twoline2rv(line1, line2, wgs84)
position, velocity = debris.propagate(
now.year, now.month, now.day, now.hour+1)
d = {
'satellite' : debris,
'position' : position,
'velocity' : velocity
}
satellites.append(d)
except:
return
def get_current_location():
pass
def find_nearby_debris(current_location: tuple):
'''
This function takes a tuple of x,y,z coordinates of current location,
and return a list of nearby 'visible' debris
'''
download_tle()
#load_tle_data()
#print(satellites)
#print(len(satellites))