# calculating satellite position and velocity from TLE

I'm trying to calculate satellite orbit from the TLE set at first, I used several libraries including SGP4, Skyfiled to get the initial position and velocity of the satellite at the epoch time I know that both provide position and velocity in the TEME(True Equator Mean Equinox) reference frame then I used astropy to convert to ITRS reference frame(the target) but the final r,v is not as expected.

The expected state vector is:

(-5443.785402, 3893.913532, 0.005474) km
(   -2.493203,   -3.506504, 6.055634) km/sec


but I get:

(-5443.81607435, 3893.87064814, 0.01495843) km
(   -2.77711623,   -3.90350078, 6.0556312) km/sec


The code is as follow:

from skyfield.api import EarthSatellite, load, wgs84
import update_tle_v1 as tle
from astropy import coordinates as coord
from astropy import units as u
from astropy.time import Time

#gitting tle from file
file = 'satellite.txt'

tle = tle.UpdateTle()
lines = tle.from_txt(file, True)
analyzed = tle.analyze_tle(lines)

s, t = lines[-2], lines[-1]

epochyr = analyzed[1][4]
epochdays = analyzed[1][5]

year = int('20' + epochyr)

month, day, hour, minute, second = tle.epoch(epochyr, epochdays)

line1 = s
line2 = t

satellite = EarthSatellite(line1, line2, 'satellite', ts)
print(satellite.epoch.utc_jpl())

#---------------------position, velocity---------------------------

t = ts.utc(year, month, day, hour, minute, second)

geocentric = satellite.at(t)

r = geocentric.position.km
v = geocentric.velocity.km_per_s

print(r)
print(v)

#epoch time
now = Time('2021-11-5 7:59:44.801')

# position of satellite in GCRS or J20000 ECI:
cartrep = coord.CartesianRepresentation(x=r[0],
y=r[1],
z=r[2],
unit=u.km)
gcrs = coord.GCRS(cartrep, obstime=now)
position = gcrs.transform_to(coord.ITRS(obstime=now))

cartrep = coord.CartesianRepresentation(x=v[0],
y=v[1],
z=v[2],
unit=u.km)
gcrs = coord.GCRS(cartrep, obstime=now)
velocity = gcrs.transform_to(coord.ITRS(obstime=now))

print(position, '\n', velocity, sep='')

• It would be helpful if you could include the contents of the TLE file you read in, so people can run the computation in their own favorite software, and have something to compare to your result. Also, why exactly do you "expect" a particular answer? What other software makes you think that? TLEs and the TEME frame are tricky to handle correctly. Your position only differs from "expected" by 52 meters, which is actually very good by TLE standards, and your velocity "error" is entirely in the equatorial plane, which sounds a lot like a coordinate transformation bug. Commented Jan 4, 2022 at 23:22
• Interesting and kind-of weird! The difference in position is tens of meters only, and the difference in velocity in the z direction is also very small, but the magnitude of the velocities in the xy plane differ by 11% even though they point in the same direction to within 0.02 degrees. Something is buggy here; they can't both be the result of valid SGP propagation, look for typos or lines of code that should have been deleted.
– uhoh
Commented Jan 5, 2022 at 0:11
• @uhoh, oooh, that's interesting. with wrong speed but not wrong direction, coordinate system error seems less likely. typo in the mean motion, maybe? need more data. Commented Jan 5, 2022 at 0:15
• this is the TLE set i'm using: 1 44792U 98067QX 21309.33315742 .00311477 00000-0 12417-2 0 9999 2 44792 51.6322 309.1372 0007423 71.1960 288.9849 15.85183673111730 the position's values are somehow satisfying but the velocity is extremely away from what I need and I'm sure about the results that I get from STK what other info could i provide Commented Jan 5, 2022 at 1:25