Based on main_000_readtle.py

Demonstrate reading a TLE file.

Example: ISS TLE file downloaded from celestrak.com on 3 August 2017

ISS (ZARYA)

1 25544U 98067A 17213.83387828 .00000874 00000-0 20415-4 0 9996

2 25544 51.6427 170.7730 0006301 93.4612 353.3163 15.54246517 68858

@author: Ashiv Dhondea

Created on 03 August 2017


In [1]:
# Load the libraries required
import AstroFunctions as AstFn

import math
import datetime as dt
import pytz

In [2]:
# Place the contents of the TLE file here.
## ISS (ZARYA)                        
tle_line1 = '1 25544U 98067A   17213.83387828  .00000874  00000-0  20415-4 0  9996';
tle_line2 = '2 25544  51.6427 170.7730 0006301  93.4612 353.3163 15.54246517 68858';

In [3]:
# Read the Keplerians as well as the epoch of validity of the TLE file
a,e,i,BigOmega,omega,E,nu,epoch  = AstFn.fnTLEtoKeps(tle_line1,tle_line2);

In [4]:
print 'semi-major axis in [km]' 
print a
print 'eccentricity' 
print e
print 'inclination in [deg]' 
print i
print 'RAAN in [deg]' 
print BigOmega
print 'argument of perigee in [deg]' 
print omega
print 'true anomaly in [deg]' 
print math.degrees(nu)
print 'epoch' 
print epoch


semi-major axis in [km]
6782.48079627
eccentricity
0.0006301
inclination in [deg]
51.6427
RAAN in [deg]
170.773
argument of perigee in [deg]
93.4612
true anomaly in [deg]
96.4355054078
epoch
17213.83387828

In [5]:
# Calculate epoch at which the TLE was valid
year,dayy, hrs, mins, secs, millisecs = AstFn.fn_Calculate_Epoch_Time(epoch);
todays_date = AstFn.fn_epoch_date(year,dayy);
print "TLE epoch date is", todays_date
print "UTC time = ",hrs,"h",mins,"min",secs+millisecs,"s"


TLE epoch date is 2017-08-01
UTC time =  20 h 0 min 47.083392 s

In [6]:
# Create a datetime object for the epoch of validity
timestamp_tle_epoch = dt.datetime(year=todays_date.year,month=todays_date.month,day=todays_date.day,hour=hrs,minute=mins,second=secs,microsecond=int(millisecs),tzinfo= pytz.utc);

In [7]:
# Convert Keplerians to Cartesian state vector
xstate = AstFn.fnKepsToCarts(a,e, math.radians(i), math.radians(omega),math.radians(BigOmega),nu);
print 'ECI state vector read from TLE file'
print xstate


ECI state vector read from TLE file
[  6.71156486e+03  -3.57343479e+02  -9.14171985e+02  -5.44290159e-01
   4.83654902e+00  -5.92219633e+00]

In [8]:
# Find Kepler period
T = AstFn.fnKeplerOrbitalPeriod(a);
print "the Kepler period is %f min" %(T/60.)


the Kepler period is 92.649395 min

In [ ]: