I want to make a motorized pointer to follow the International Space Station (ISS) as it orbits over my house. To do that, I need to compute the altitude and heading of the ISS, based on the ISS orbit data, the current time, and my latitude, longitude, and altitude. I found a lot of stuff via Google that looked like what I wanted, but the math was too ugly and foreign and I got impatient trying to make it work.
About a month ago, I ran into Nathan Bergey, a space junkie and originator of ISS-Notify. I knew he’d have a good opinion on how to compute this stuff. Sure enough, he recommended PyEphem, which is a delight to use. Tracking the ISS as it goes over is pretty simple. Here’s the Python code I use:
import math import time from datetime import datetime import ephem degrees_per_radian = 180.0 / math.pi home = ephem.Observer() home.lon = '-122.63' # +E home.lat = '45.56' # +N home.elevation = 80 # meters # Always get the latest ISS TLE data from: # http://spaceflight.nasa.gov/realdata/sightings/SSapplications/Post/JavaSSOP/orbit/ISS/SVPOST.html iss = ephem.readtle('ISS', '1 25544U 98067A 11290.51528320 .00016717 00000-0 10270-3 0 9006', '2 25544 51.6378 264.9380 0016170 337.7557 22.2896 15.60833726 20019' ) while True: home.date = datetime.utcnow() iss.compute(home) print('iss: altitude %4.1f deg, azimuth %5.1f deg' % (iss.alt * degrees_per_radian, iss.az * degrees_per_radian)) time.sleep(1.0)
When run, this program prints the current altitude (in degrees above the horizon) and azimuth (heading in degrees “clockwise” from North).
iss: altitude 78.1 deg, azimuth 249.8 deg
iss: altitude 79.1 deg, azimuth 250.7 deg
iss: altitude 80.2 deg, azimuth 251.7 deg
iss: altitude 81.2 deg, azimuth 253.0 deg
iss: altitude 82.2 deg, azimuth 254.7 deg
iss: altitude 83.3 deg, azimuth 256.9 deg
iss: altitude 84.3 deg, azimuth 259.9 deg
Sweet! Now all I have to do is pump these numbers out a serial port to an Arduino controlling a couple of servos, and I should be good to go!