Why am i getting a difference between matlab's "lla2eci" and "sgp4.propagate"?

428 Views Asked by At

I am not experienced in this area but over the past few days I've put together some code in python that tracks (hopefully) the ISS. I've done the math and have that side of things working, but only when I inject the satellite position using matlab's lla2eci. To get a correct answer, I take the latitude and longitude of the satellite's subpoint from live data and convert that to eci using matlab. This method gives me correct look angles (azimuth and elevation) for the ISS, and I've confirmed them with the pyephem method using iss.compute(home) where "home" is my lla.

I'm comparing matlab's lla2eci to what satellite.propagate(...) is getting me and at time = 2019 12 16 8 53 19, i get the following results:

Matlab lla2eci: x,y,z = (3873.9, -902.18, -4969.9) sgp4 propagate: x,y,z= (-4082.5, 3458.3, -4195.1)

I have to be missing something here! Any help would be greatly appreciated, and I'm glad to answer any questions to clarify.

1

There are 1 best solutions below

0
On

Looking at the question, seems like you are not taking Altitude into account?

Since your aim is to track the ISS using a python code may I suggest a slightly different approach?

  1. TLE values for space objects are available at: https://www.space-track.org/, so sign-up there.
  2. Then find the position of the satellite in python by using sgp4(https://pypi.org/project/sgp4/) and spacetrack(https://pypi.org/project/spacetrack/) libraries.

An example code would look like this:

from sgp4.earth_gravity import wgs84
from sgp4.io import twoline2rv
from spacetrack import SpaceTrackClient 
from datetime import datetime

#generate TLE from database    
st = SpaceTrackClient('YOUR_USERNAME', 'YOUR_PASSWORD')
tle = st.tle_latest(norad_cat_id=[<ISS_NORAD_CAT_ID>], ordinal=1, format='tle')

line1 = tle[:69]
line2 = tle[70:-7]

#create satellite object
satellite = twoline2rv(line1, line2, wgs84)

date_time = datetime.utcnow()

#find position
sat_position, sat_velocity = satellite.propagate(date_time.year, date_time.month,... 
                   date_time.day, date_time.hour, date_time.minute, date_time.second)

Use your own username, password and norad ID. welcome to stackoverflow :)