title: Calculate ECEF satellite position from TLE
body: <p>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 <a href="http://libjoe.blogspot.com.co/2009/10/where-is-my-satellite-in-python.html" rel="nofollow noreferrer">blog</a>, I'm using <strong>Pyphem</strong>, the library for python, and using the information of the <strong>TLE</strong> 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 <a href="http://www.celestrak.com/NORAD/elements/gps-ops.txt" rel="nofollow noreferrer">this</a> 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?</p>
  
  <p><strong>UPDATE 1.</strong></p>
  
  <p><a href="https://github.com/mikesneider/SatellitalPosition/blob/master/Calculating%20satellites%20with%20Pyphem.ipynb" rel="nofollow noreferrer">my code</a> in python is this:</p>
  
  <pre><code>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 = 'http://www.celestrak.com/NORAD/elements/gps-ops.txt'
  GPS2_list = 'http://www.tle.info/data/gps-ops.txt'
  GLONASS_list = 'http://www.celestrak.com/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[i],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 &lt;= ephem.localtime(st) and TimeNow &gt;= 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
  </code></pre>
  
  <p>Results:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>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?</p>
  
  <p>thank you</p>
  
  <p><strong>UPDATE 2:</strong></p>
  
  <p>You can change the variable <code>TimeNow</code> for another date (for example <code>now + 2 hours</code>), 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 <a href="http://www.celestrak.com/NORAD/elements/supplemental/" rel="nofollow noreferrer">this</a> trying to find the answer) I hope someone knows it. Thanks. </p>