[Python] Calculate ECEF satellite position from TLE

Discussão em 'Python' iniciado por Stack, Março 1, 2025.

  1. Stack

    Stack Membro Participativo

    I'm calculating the position of satellities using mi location (in latitude-longitude), I want to know what satellities can I see (my receptor) from my position. For this I'm using the help of this blog, I'm using Pyphem, the library for python, and using the information of the TLE files. With this I can know the position but maximum the range of data that I can get with the file, the files are in this site. e.g. The file get info from 12-01-2017 1:00 to 13-01-2017 23:59, I want to know the position for 14-01-2017 13:05 The Question is Can I get a TLE file for tomorrow? or just I can get the file for the day of today?

    UPDATE 1.

    my code in python is this:

    TimeNow = datetime.datetime.now() #"10/01/2017"
    Longitude = -73.1198
    Latitude = 7.11392
    print TimeNow

    sat_alt, sat_az, sat_name = [], [], []

    observer = ephem.Observer()
    observer.long = '-73.1224429' # '-37.799423'
    observer.lat = '7.1388027' # '144.999979'
    observer.date = datetime.datetime.now()

    GPS_list = 'https://celestrak.org/NORAD/elements/gps-ops.txt'
    GPS2_list = 'http://www.tle.info/data/gps-ops.txt'
    GLONASS_list = 'https://celestrak.org/NORAD/elements/glo-ops.txt'
    GLONASS2_list = 'http://www.tle.info/data/glo-ops.txt'
    #'http://www.amsat.org/amsat/ftp/keps/current/nasabare.txt').readlines()


    tles = urllib2.urlopen(GPS_list).readlines()

    tles = [item.strip() for item in tles]
    tles = [(tles,tles[i+1],tles[i+2]) for i in xrange(0,len(tles)-2,3)]

    for tle in tles:

    try:
    sat = ephem.readtle(tle[0], tle[1], tle[2])
    rt, ra, tt, ta, st, sa = observer.next_pass(sat)

    if rt is not None and st is not None:
    #observer.date = rt
    sat.compute(observer)

    #if 'PRN 26' in tle[0]:
    #print "TRUE"
    if TimeNow <= ephem.localtime(st) and TimeNow >= ephem.localtime(rt):
    text = tle[0]
    sat_alt.append(np.rad2deg(sat.alt))
    sat_az.append(np.rad2deg(sat.az))

    text2 = text.rsplit(')', 1)[0]
    text3 = text2.rsplit('(', 1)[1]
    sat_name.append(text3)
    print text3, np.rad2deg(ra),np.rad2deg(sa)
    except ValueError as e:
    print e


    Results:

    PRN 19 228.755917041 148.703886987
    PRN 02 221.648736379 143.285115427
    PRN 17 221.556446863 146.188232693
    PRN 30 322.13237575 60.4800956664
    PRN 06 211.849518618 131.038791151


    In this exaple I have the information of today (28/02/2017) I in the link I have the TLE file of today, but if I want the information of tomorrow?

    thank you

    UPDATE 2:

    You can change the variable TimeNow for another date (for example now + 2 hours), but I do not find how is the error if with the TLE file of today I try to calculate the position (elevation / azimuth) of tomorrow, or past tomorrow, the error will be too big? how much? (i'm reading this trying to find the answer) I hope someone knows it. Thanks.

    Continue reading...

Compartilhe esta Página