I would like to pull and parse the data for individual satellites from the TLE files at celestrak.com using Python. I found code to do so with pyephem using "readtle" but this does not work in skyfield. How can I pull the data from the tle files in skyfield?
pyephem is essentially deprecated. So, new to pyephem/skyfield, I have chosen to use skyfield.
I am trying to automatically pull the TLE information from the files at celestrak.com. I found code from several years ago that did so using pyephem under python 2.x.x. So, I am converting the code to Python 3.7.x.
However, the readtle aspect of the code used to pull the individual entries from the TLE files will not work on skyfield. I am accessing the files from the celestrak.com server.
I tried also to install pyephem, but obtained errors. And, I would like to stay with skyfield in any case.
The code I found reads:
class Satellite:
def __init__(self, name, l1, l2):
self.e = ephem.readtle(name, l1, l2)
def compute(self):
self.e.compute(datetime.datetime.utcnow())
self.long = math.degrees(float(self.e.sublong))
self.lat = math.degrees(float(self.e.sublat))
self.height = abs(int(self.e.elevation))
r = 6378150 + self.height
self.r = r / 1000000.0
self.x = -cos(radians(self.lat)) * cos(radians(self.long)) * self.r
self.y = sin(radians(self.lat)) * self.r
self.z = cos(radians(self.lat)) * sin(radians(self.long)) * self.r
self.vlists = sat_shape
self.label = pyglet.text.Label(self.e.name, y=15, anchor_x="center", color=(255,255,255,200))
def draw(self):
glLoadIdentity()
glTranslatef(0,0,-zoom+6.37815)
glRotatef(ro, 1, 0, 0)
glRotatef(rocc, 0, 0, 1)
glTranslatef(0,0,-6.37815)
glRotatef(-angle_y, 1, 0, 0)
glRotatef(angle_x, 0, 1, 0)
glTranslatef(self.x,self.y,self.z)
glColor3f(1,0,0)
glScalef(zoom/100.0, zoom/100.0, zoom/100.0)
for v in self.vlists:
v.draw(GL_TRIANGLE_STRIP)
glScalef(0.02, 0.02, 0.02)
glRotatef(-angle_x, 0, 1, 0)
glRotatef(angle_y, 1, 0, 0)
glRotatef(-rocc, 0, 0, 1)
glRotatef(-ro, 1, 0, 0)
self.label.draw()
self.draw_line()
Does anyone have any ideas?