Created
February 2, 2018 14:43
-
-
Save PierreZ/eea0d088d28606b39e8810936e9a7c3e to your computer and use it in GitHub Desktop.
satellite.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import requests | |
import ephem | |
from math import degrees | |
def process(lines): | |
try: | |
iss = ephem.readtle(str(lines[0]), str(lines[1]), str(lines[2])) | |
except: | |
return | |
# Compute for now | |
now = datetime.datetime.utcnow() | |
iss.compute(now) | |
name = lines[0].replace(" ", "").replace("'", "") | |
print(name) | |
lon = degrees(iss.sublong) | |
lat = degrees(iss.sublat) | |
elevation = iss.elevation | |
r = requests.get("http://www.celestrak.com/NORAD/elements/stations.txt") | |
lines = [] | |
for line in r.iter_lines(): | |
lines.append(line) | |
if len(lines) >= 3: | |
process(lines) | |
lines = [] | |
if len(lines) > 0: | |
process(lines) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment