使用下面的代码,并使用pyephem和fastkml,我想从TLE中提取卫星的地面轨迹。代码如下:
import numpy as np
import ephem
import datetime as dt
from fastkml import kml
from shapely.geometry import Point, LineString, Polygon
name = "ISS (ZARYA)"
line1 = "1 25544U 98067A 16018.27038796 .00010095 00000-0 15715-3 0 9995"
line2 = "2 25544 51.6427 90.6544 0006335 30.9473 76.2262 15.54535921981506"
tle_rec = ephem.readtle(name, line1, line2)
start_dt = dt.datetime.today()
intervall = dt.timedelta(minutes=1)
timelist = []
for i in range(100):
timelist.append(start_dt + i*intervall)
positions = []
for t in timelist:
tle_rec.compute(t)
positions.append((tle_rec.sublong,tle_rec.sublat,tle_rec.elevation))
k = kml.KML()
ns = '{http://www.opengis.net/kml/2.2}'
p = kml.Placemark(ns, 'Sattrack', 'Test', '100 Minute Track')
p.geometry = LineString(positions)#, tesselate=1,altitudemode="absolute")
k.append(p)
with open("test.kml", 'w') as kmlfile:
kmlfile.write(k.to_string())
可悲的是,当我将kml加载到Google Earth时,该轨道如下所示:
任何出错的想法?
答案 0 :(得分:3)
你的地面轨道是0°N(在赤道上)和0°E(格林威治以南,靠近几内亚湾)的位置。这表明您使用以弧度表示的角度,最多可以达到约6.2的值,并将它们传递给绘图软件,将其作为度数读取。
你应该先尝试将它们转换为学位:
positions.append((tle_rec.sublong / ephem.degree,
tle_rec.sublat / ephem.degree,
tle_rec.elevation))