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
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"
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
In [8]:
# Find Kepler period
T = AstFn.fnKeplerOrbitalPeriod(a);
print "the Kepler period is %f min" %(T/60.)
In [ ]: