我正在尝试编写一个基本的python脚本,它将跟踪给定位置的给定卫星,该卫星由tle's定义。我不是一个非常/轨道的人,但我正试图变得更聪明。
当我尝试将方位角,高程,范围值转换为ECEF位置时,我遇到了问题。我正在使用PyEphem来获取观察值,并使用spg4来获取真实位置以进行验证。我也在使用网站http://www.n2yo.com/?s=25544,验证值。
我通过以下方式获得观测到的方位角,仰角和范围:
def get_ob(epoch, sv, obsLoc):
site = ephem.Observer()
site.lon = str(obsLoc.lat) # +E -104.77 here
site.lat = str(obsLoc.lon) # +N 38.95 here
site.elevation = obsLoc.alt # meters 0 here
#epoch = time.time()
site.date = datetime.datetime.utcfromtimestamp(epoch)
sat = ephem.readtle(sv.name,sv.tle1,sv.tle2)
sat.compute(site)
az = degrees(sat.az)
el = degrees(sat.alt)
#range in m
range = sat.range
sat_lat = degrees(sat.sublat)
sat_long = degrees(sat.sublong)
# elevation of sat in m
sat_elev = sat.elevation
x, y, z = aer2ecef(az,el,range,38.95,-104.77,80 / 1000)
报告的方位角,高度和范围与网站相匹配。我正在转换到ECEF职位:
def aer2ecef(azimuthDeg, elevationDeg, slantRange, obs_lat, obs_long, obs_alt):
#site ecef in meters
sitex, sitey, sitez = llh2ecef(obs_lat,obs_long,obs_alt)
#some needed calculations
slat = sin(radians(obs_lat))
slon = sin(radians(obs_long))
clat = cos(radians(obs_lat))
clon = cos(radians(obs_long))
azRad = radians(azimuthDeg)
elRad = radians(elevationDeg)
# az,el,range to sez convertion
south = -slantRange * cos(elRad) * cos(azRad)
east = slantRange * cos(elRad) * sin(azRad)
zenith = slantRange * sin(elRad)
x = ( slat * clon * south) + (-slon * east) + (clat * clon * zenith) + sitex
y = ( slat * slon * south) + ( clon * east) + (clat * slon * zenith) + sitey
z = (-clat * south) + ( slat * zenith) + sitez
return x, y, z
当我描绘时,位置是偏离的(地球的错误一面)。我从网站和spg4匹配的位置,所以我相信那些是正确的。
我不确定错误是在我的转换方法中还是我使用错误的数据进行转换。我在这里的答案中找到了这个方法:Get ECEF XYZ given starting coordinates, range, azimuth, and elevation
对于我下车的地方有任何建议或建议,我们将不胜感激。以下是测试输入/输出:
我正在测试的卫星是ISS和directv10(一个固定,一个移动 - 可以通过互联网跟踪进行验证):
0 Direct10
1 31862U 07032A 13099.15996183 -.00000126 00000-0 10000-3 0 1194
2 31862 000.0489 046.9646 0000388 001.7833 103.5813 01.00271667 21104
0 ISS
1 25544U 98067A 13112.50724749 .00016717 00000-0 10270-3 0 9148
2 25544 51.6465 24.5919 0009906 171.1474 188.9854 15.52429950 26067
观察站点lla:
[38.95 -104.77 0.0]
结果:
sv: ISS ephem observed response(km) @ epoch: 1365630559.000000 : [344.067992722211, -72.38297754053431, 12587.123][degrees(sat.az), degrees(sat.alt), sat.range]
sv: ISS ephem reported llh location(km) @ epoch: 1365630559.000000 : [-41.678271938092195, -129.16682754513502, 421.06290625][degrees(sat.sublat0, degrees(sat.sublong), sat.elevation]
sv: ISS ephem calculated xyz location(km) @ epoch: 1365630559.000000 : [688.24385373837845, 6712.2004971137103, -704.83633267710866][aer2ecef(az,el,range,obsLoc.lat,obsLoc.lon,obsLoc.alt)]
sv: ISS ephem llh from calc xyz location(km) @ epoch: 1365630559.000000 : [-6.001014287867631, 84.1455657632957, 12587.123][ecef2llh()]
sv: ISS ephem xyz from reported llh location(km) @ epoch: 1365630559.000000 :[-3211.7910504146325, -3942.7032969856118, -4498.9656030253745][llh2ecef(lat,long,elev)]
sv: ISS spg84 ecef position(m) @ epoch: 1365630559.000000 : [-3207667.3380003194, -3936704.823960199, -4521293.5388663234]
sv: ISS spg84 ecef2llh(m) @ epoch: 1365630559.000000 : [-41.68067424524357, -129.17349987675482, 6792812.8704163525]
sv: Direct10 ephem observed response(km) @ epoch: 1365630559.000000 : [320.8276456938389, -19.703680198781303, 43887.572][degrees(sat.az), degrees(sat.alt), sat.range]
sv: Direct10 ephem reported llh location(km) @ epoch: 1365630559.000000 : [0.004647324660923812, -102.8070784813048, 35784.688][degrees(sat.sublat0, degrees(sat.sublong), sat.elevation]
sv: Direct10 ephem calculated xyz location(km) @ epoch: 1365630559.000000 : [-18435.237655222769, 32449.238763035213, 19596.893001978762][aer2ecef(az,el,range,obsLoc.lat,obsLoc.lon,obsLoc.alt)]
sv: Direct10 ephem llh from calc xyz location(km) @ epoch: 1365630559.000000 : [27.727834453026748, 119.60200825103102, 43887.572][ecef2llh()]
sv: Direct10 ephem xyz from reported llh location(km) @ epoch: 1365630559.000000 :[-9346.1899009219123, -41113.897098582587, 3.4164105611003754][llh2ecef(lat,long,elev)]
sv: Direct10 spg84 ecef position(m) @ epoch: 1365630559.000000 : [-9348605.9260040354, -41113193.982686974, -14060.29781505302]
sv: Direct10 spg84 ecef2llh(m) @ epoch: 1365630559.000000 : [-0.019106864351793953, -102.81049179145006, 42156299.077687651]
答案 0 :(得分:4)
我觉得自己很傻但发现了这个问题...
我将经纬度从现场转换为PyEphem模型(见第3-4行)......目前转换工作正在进行。
让这成为孩子们的一课。使用好的变量名称......不要像我一样懒惰,并且浪费时间试图找到一个不存在的数学错误....