Track The ISS Yourself Using PyEphem

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!

8 thoughts on “Track The ISS Yourself Using PyEphem”

  1. Cool that you’re using pyephem. I’ve been using it lately for a sundial project I’m working on, generating the tables of sun position data for a particular lat/lon.

  2. Did you ever complete this “pointer”? Very curios what that looked like. Did it point in 3 dimensions?

    By the way… I gave up waiting for ISS-Notify and I’m building my own with Raspberry Pi using the PyEphem library. I’ve ordered a Pi-Lite from the UK (pre-built LED Matix) which I’ll be using as my “pointing” device. I’ll also use to display details of upcoming passes.. and to indicate where the ISS is during a pass

  3. @Liam Kennedy: No, I’m afraid not. I’ve iterated the design, but only in my head. But I still want to get to it! The plan for the pointer is to have azimuth and elevation hobby servos that are calibrated to point to an object with a tolerance of a few degrees — good enough to help people identify objects of interest. It should be easy to implement, I just need to make time for it.

    I see Nate periodically — he lives in my town. I’ll needle him about ISS-Notify. :-) Good luck with your own project. Please do share what you’ve done, I’d love to see it and perhaps build on it, or contribute to your work.

  4. When I use your code (verbatim, no changes), I get the following output:

    iss: altitude -89.8 deg, azimuth 180.0 deg
    iss: altitude -89.8 deg, azimuth 180.0 deg
    iss: altitude -89.8 deg, azimuth 180.0 deg
    iss: altitude -89.8 deg, azimuth 360.0 deg
    iss: altitude -89.8 deg, azimuth 180.0 deg
    iss: altitude -89.8 deg, azimuth 360.0 deg
    iss: altitude -89.8 deg, azimuth 360.0 deg
    iss: altitude -89.8 deg, azimuth 0.0 deg
    iss: altitude -89.8 deg, azimuth 180.0 deg
    iss: altitude -89.8 deg, azimuth 180.0 deg
    iss: altitude -89.8 deg, azimuth 0.0 deg
    iss: altitude -89.8 deg, azimuth 180.0 deg

    The altitude is constant, and the azimuth jumps around between 0, 180 and 360.

    I can’t find anything in the pyephem bugs or help to explain this. Any ideas?

  5. James: I hope you found a solution. I have been away from stars and PyEphem for quite a while now, so I can’t intelligently answer your question right now.

  6. I wrote a Python program that points at satellites overhead and tracks them as they transit the sky using two servo motors. You can feed it any TLE dataset. I’ll be posting the project on teamgillen.com soon. Tweet @teamgillen if you are interested.

Comments are closed.