Visualizing TLE Orbital Elements with Python and matplotlib

A Two-Line Element Set (TLE) is a way of encoding orbital elements of Earth-orbiting objects at a given time. This is the format NORAD provides data on many satellites in space right now. It'd be nice to see that as a 3d visualization. We use python to parse text files pulled from NORAD, and plot with matplotlib.
Military Satellites
Military satellite orbits

For example the TLE for SpaceX's Dragon spacecraft during the CRS-2 mission was


dragon = """DRAGON CRS-2
1 39115U 13010A   13062.62492353  .00008823  00000-0  14845-3 0   188
2 39115  51.6441 272.5899 0012056 334.2535  68.5574 15.52501943   306"""

orbit.py contains the code to parse the TLE into components as well as call graphics to draw it.


print "Satellite Name                                            = %s" % title
print "Satellite number                                          = %g (%s)" % (satellite_number, "Unclassified" if classification == 'U' else "Classified")
print "International Designator                                  = YR: %02d, LAUNCH #%d, PIECE: %s" % (international_designator_year, international_designator_launch_number, international_designator_piece_of_launch)
print "Epoch Date                                                = %s  (YR:%02d DAY:%.11g)" % (epoch_date.strftime("%Y-%m-%d %H:%M:%S.%f %Z"), epoch_year, epoch)
print "First Time Derivative of the Mean Motion divided by two   = %g" % first_time_derivative_of_the_mean_motion_divided_by_two
print "Second Time Derivative of Mean Motion divided by six      = %g" % second_time_derivative_of_mean_motion_divided_by_six
print "BSTAR drag term                                           = %g" % bstar_drag_term
print "The number 0                                              = %g" % the_number_0
print "Element number                                            = %g" % element_number
print
print "Inclination [Degrees]                                     = %g°" % inclination
print "Right Ascension of the Ascending Node [Degrees]           = %g°" % right_ascension
print "Eccentricity                                              = %g" % eccentricity
print "Argument of Perigee [Degrees]                             = %g°" % argument_perigee
print "Mean Anomaly [Degrees] Anomaly                            = %g°" % mean_anomaly
print "Eccentric Anomaly                                         = %g°" % eccentric_anomaly
print "True Anomaly                                              = %g°" % true_anomaly
print "Mean Motion [Revs per day] Motion                         = %g" % mean_motion
print "Period                                                    = %s" % timedelta(seconds=period)
print "Revolution number at epoch [Revs]                         = %g" % revolution
print
print "semi_major_axis = %gkm" % semi_major_axis
print "eccentricity    = %g" % eccentricity
print "inclination     = %g°" % inclination
print "arg_perigee     = %g°" % argument_perigee
print "right_ascension = %g°" % right_ascension
print "true_anomaly    = %g°" % true_anomaly

Orbits of the ISS and Dragon CRS3
Dragon CRS-2 and ISS space station

Source code on Github

Popular posts from this blog

Strawberry DNA extraction and viewing with a cheap USB Microscope

Relearning web development by writing a clicking game using React, Npm and Browserify