pythonskyfieldsgp4

How can I use skyfied to convert SGP4 TEME coordinate to ECEF?


I want to plot the satellite tracking on a map. So I use SGP4 1.4 with python .Input the TLE data, but the outdata is not what I want. So I want to convert the output data to the ECEF data and get the longitude and latitude.

I know the skyfied can convert TEME to ECEF but Idon't know how to use it.

https://github.com/skyfielders/python-skyfield/blob/master/skyfield/sgp4lib.py

and I use the skyfield met the error:

from skyfield.api import load
ts=load.timescale()

error is:

File "D:\Anaconda2\lib\site-packages\skyfield\iokit.py", line 213, in timescale
    data = self('deltat.data')

File "D:\Anaconda2\lib\site-packages\skyfield\iokit.py", line 166, in __call__
    download(url, path, self.verbose)

File "D:\Anaconda2\lib\site-packages\skyfield\iokit.py", line 329, in download
    raise IOError('cannot get {0} because {1}'.format(url, e))

IOError: cannot get http://maia.usno.navy.mil/ser7/deltat.data because <urlopen error [Errno 10060] >

Solution

  • I have solved it by add some code. In the iokit.py 'function download() 335 line

     try:
        print (url)  #original
    
        try:
            connection = urlopen(url)
        except:
           import urllib2
           user_agent ='"Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.122 Safari/537.36"' #cxh
           headers = { 'User-Agent' : user_agent }
           proxy = urllib2.ProxyHandler({}) 
           opener = urllib2.build_opener(proxy) 
           urllib2.install_opener(opener) 
           req ,= urllib2.Request(url, headers = headers) 
           response = urllib2.urlopen(url) 
           connection= response
           print ('get data successfully')
    
    except Exception as e:
        raise IOError('cannot get {0} because {1}'.format(url, e))