使用spg4,pyephem进行Python卫星跟踪-位置不匹配 [英] Python satellite tracking with spg4, pyephem - positions not matching

查看:278
本文介绍了使用spg4,pyephem进行Python卫星跟踪-位置不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个基本的python脚本,该脚本将在给定位置跟踪由tle定义的给定卫星.我不是一个惯性/轨道的人,但是正在努力变得更聪明.

I'm trying to write a basic python scrip that will track a given satellite, defined with tle's, from a given location. I'm not a asto/orbital person but am trying to become smarter on it.

我遇到了一个问题,我使用的不同模型给我的位置答案非常不同.我试过使用: pyEphem spg4 预测(通过脚本执行系统调用)

I am running into a problem where the different models I'm using are giving me very different position answers. I have tried using: pyEphem spg4 predict (exec system call from script)

我正在测试的卫星是ISS和directv10(一颗固定的一颗正在移动,可通过互联网跟踪进行验证)

The satellites I'm testing with are the ISS and directv10 (one fixed, one moving- with internet tracking available for verification):

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

我已经修改了预测来源,为我提供了eci位置,因此我可以使用它来知道真实位置.我还给出了用于验证观测值的az,el范围.我正在使用spg4获取真实位置.对于观察到的位置,我使用的是PyEphem.

I have modified the predict source to give me the eci location so I can use that to know the real location. I also have it give the az, el, range for using to verify observations. I'm using spg4 for getting the real location. For the observed location, I'm using PyEphem.

我通过以下方式从spg4获取ECEF职位:

I'm getting the ECEF position from spg4 with:

def get_real(epoch, sv):
    satellite = twoline2rv(sv.tle1, sv.tle2, wgs84)

    #epoch = time.time()
    obsTime = datetime.datetime.utcfromtimestamp(epoch)
    position, velocity = satellite.propagate(obsTime.year,
                                             obsTime.month,
                                             obsTime.day,
                                             obsTime.hour,
                                             obsTime.minute,
                                             obsTime.second)


    x = position[0]
    y = position[1]
    z = position[2]

    x *= 1000
    y *= 1000
    z *= 1000

我对基于火星虫的观测的代码是:

My code for pyephem based observations is:

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

    #TODO: switch to using az,el,range for observed location calculation
    #x, y, z    = aer2ecef(az,el,range,38.95,-104.77,80 / 1000)
    x,y,z  = llh2ecef(sat_lat, sat_long, sat_elev)

llh2ecef转换:

The llh2ecef conversion:

def llh2ecef (flati,floni, altkmi ):
    #         lat,lon,height to xyz vector
    #
    # input:
    # flat      geodetic latitude in deg
    # flon      longitude in deg
    # altkm     altitude in km
    # output:
    # returns vector x 3 long ECEF in km

    dtr =  pi/180.0;

    flat  = float(flati);
    flon  = float(floni);
    altkm = float(altkmi);

    clat = cos(dtr*flat);
    slat = sin(dtr*flat);
    clon = cos(dtr*flon);
    slon = sin(dtr*flon);

    rrnrm  = radcur (flat);
    rn     = rrnrm[1];
    re     = rrnrm[0];

    ecc1    = ecc;
    esq1    = ecc1*ecc1

    x      =  (rn + altkm) * clat * clon;
    y      =  (rn + altkm) * clat * slon;
    z      =  ( (1-esq1)*rn + altkm ) * slat;

    return x,y,z

aer2ecef:

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

当我比较并绘制3D地球上的位置(使用ecef位置)时,我到处都在寻找答案.预测的eci位置(转换为ecef)与我在ISS跟踪网站上看到的一致( http://www .n2yo.com/?s = 25544 )

When I compare and plot the locations on a 3D globe (using ecef positions), I'm getting answers all over the place. The predict eci position (converted to ecef) matchs what I see on ISS Tracking websites (http://www.n2yo.com/?s=25544)

get_real()的结果在规模和位置上都相差甚远. get_ob()的结果在比例上正确,但是在地球上的位置上错误

The result from get_real() is way off in scale and location. The result from get_ob() are right in scale, but wrong in location on globe

示例结果:

基于预测:

sv: ISS predict observed response    @ epoch: 1365630559.000000 : [111.485527, -69.072949, 12351.471383]
sv: ISS predict aer2ecef position(m) @ epoch: 1365630559.000000 : [4731598.706291642, 1844098.7384999825, -4521102.9225004213]
sv: ISS predict ecef position(m) @ epoch: 1365630559.000000 : [-3207559.6840419229, -3937040.5048992992, -4521102.9110000003]
sv: ISS predict ecef2llh(m)      @ epoch: 1365630559.000000 : [-41.67839724680753, -129.170165912171, 6792829.6884068651]
sv: Direct10 predict observed response    @ epoch: 1365630559.000000 : [39.692138, -49.219935, 46791.914833]
sv: Direct10 predict aer2ecef position(m) @ epoch: 1365630559.000000 : [28401835.38849232, 31161334.784188181, 3419.5400331273049]
sv: Direct10 predict ecef position(m) @ epoch: 1365630559.000000 : [-9348629.6463202238, -41113211.570621684, 3419.8620000000005]
sv: Direct10 predict ecef2llh(m)      @ epoch: 1365630559.000000 : [0.0046473273713214715, -102.81051792373036, 42156319.281573996]

基于python的

sv: ISS ephem observed response    @ epoch: 1365630559.000000 : [344.067992722211, -72.38297754053431, 12587123.0][degrees(sat.az), degrees(sat.alt), sat.range]
sv: ISS ephem llh location(m)      @ epoch: 1365630559.000000 : [-41.678271938092195, -129.16682754513502, 421062.90625][degrees(sat.sublat0, degrees(sat.sublong), sat.elevation]
sv: ISS ephem xyz location(m)      @ epoch: 1365630559.000000 :[-201637.5647039332, -247524.53652043006, -284203.56557438202][llh2ecef(lat,long,elev)]
sv: ISS spg84 ecef position(m) @ epoch: 1365630559.000000 : [4031874.0758277094, 3087193.8810081254, -4521293.538866323]
sv: ISS spg84 ecef2llh(m)      @ epoch: 1365630559.000000 : [-41.68067424524357, 37.4411722245808, 6792812.8704163525]
sv: Direct10 ephem observed response    @ epoch: 1365630559.000000 : [320.8276456938389, -19.703680198781303, 43887572.0][degrees(sat.az), degrees(sat.alt), sat.range]
sv: Direct10 ephem llh location(m)      @ epoch: 1365630559.000000 : [0.004647324660923812, -102.8070784813048, 35784688.0][degrees(sat.sublat0, degrees(sat.sublong), sat.elevation]
sv: Direct10 ephem xyz location(m)      @ epoch: 1365630559.000000 :[-7933768.6901137345, -34900655.02490133, 2903.0498773286708][llh2ecef(lat,long,elev)]
sv: Direct10 spg84 ecef position(m) @ epoch: 1365630559.000000 : [18612307.532456037, 37832170.97306267, -14060.29781505302]
sv: Direct10 spg84 ecef2llh(m)      @ epoch: 1365630559.000000 : [-0.019106864351793953, 63.80418030988552, 42156299.077687643]

两个观测值之间的az,el和range不匹配.位置与真实"位置不匹配. (经纬度和纬度会发生变化,但是ecef2llh转换后不会出现高度变化.

The az,el and range don't match between the two observations. The positions don't match for the "true" locations. (The lat and long does but height doesn't after a ecef2llh conversion.

与基于Web的跟踪器相比,我注意到预测的真实" llh位置与网站匹配.对于directv10,pyEphem匹配方位角和仰角,但不匹配ISS

When compared with the web based tracker, I notice the predict "true" llh locations match the website. For directv10, pyEphem matchs the azimuth and elevation- but not for the ISS

当我将它们绘制在地球上时,预测的eci真实"位置在正确的位置-匹配跟踪器网站). spg84 ecef位置(我认为应该与预测位置相同,位于地球的另一侧.预测的观察到"位置靠近spg84位置.pyEphem在高度上完全不显示,并且也不会显示(也是如此)低,在地球内部).

When I plot them on globe, the predict eci "true" location is in the right spot - matches tracker website). The spg84 ecef position (which I thought should be the same as predict, is on the other side of globe. The predict "observed" location, is close to the spg84 location. The pyEphem is completely off in altitude and not displayed (way too low, inside earth).

所以我的问题是我在哪里使用python模型错误?我的理解是,调用spg84property()应该返回卫星的执行位置(以米为单位).我本以为eci2efec转换后at应该与预测位置匹配.当使用sat.sublat,sat.sublong,sat.elevation时,我也会期望匹配然后是llh2ecef().

So my question is where am I using the python models wrong? My understanding was that spg84 propagate() call, should return the exec position of the satellite in meters. I would have thought at should match the predict position after the eci2efec conversion. I also would have expected that the match then the llh2ecef() when using sat.sublat,sat.sublong,sat.elevation.

正如我所说,我对轨道上的所有事物都是陌生的,所以我确定自己正在做一个简单的数学错误或东西.我尝试过搜索并尽可能多地搜索答案,示例和教程,但到目前为止没有任何帮助(我尝试了多种ecef2llh和llh2ecef方法来尝试找出这些错误.

As I said, I'm new to all things orbiting so I'm sure I an making a simple math error or soemthing. I have tried to google and search for answers, examples and tutorials as much as possible but nothing has helped so far (I have tried multiple ecef2llh and llh2ecef methods to try to work out those bugs.

任何向正确方向提出的建议,建议和指示,将不胜感激.我可以发布/发送我正在使用的完整编码,如果这对某人有用.我试图确保我在此处发布了重要的部分,并且不想把这个(已经非常)长的帖子发布更长的时间.

Any suggestions, advice, pointers in the right direction would be greatly appreciated. I can post/send the complete cod eI'm using if that would be helpful for someone. I tried to make sure I posted the important parts here and didn't want to make this (already very) long post and longer.

感谢您的帮助.

亚伦

更新:

我发现问题的至少一部分. spg84.propagate()返回ECI中的位置,而不是ECEF中的位置.快速运行eci2ecef,它与预测响应完美契合.

I found atleast part of the issue. spg84.propagate() returns the location in ECI, not ECEF. Quick run through eci2ecef and it lines up perfectly with the predict response.

发布帮助后,我似乎总是能找到解决方法;)

I always seem to find solutions after posting for help ;)

现在需要弄清楚观察者位置的状况.归结为: 如何从pyEphem.compute()中获取结果并获取卫星的ecef位置?最好使用az,el,范围值,而不是纬度,经度,高程.

Now need to figure out what is going on with the observer locations. This boils down to: How can I take the result from pyEphem.compute() and get the ecef position for the satellite? Prefer to do it with az,el, range values, not latitude, longitude, elevation.

我正在猜测aer2ecef通话中的错误.

I'm guessing the bug in my aer2ecef call.

谢谢.

更新2:

使观察结果与真实"位置对齐.看来我有单位问题.工作代码:

Got the observation to line up with the "true" position. Looks like I had a units issue. The working code:

az       = degrees(sat.az)
el       = degrees(sat.alt)
#range in km
range    = sat.range
sat_lat  = degrees(sat.sublat)
sat_long = degrees(sat.sublong)
# elevation of sat in km
sat_elev = sat.elevation


#x, y, z    = aer2ecef(az,el,range,obsLoc.lat,obsLoc.long,obsLoc.alt)
x,y,z  = llh2ecef(sat_lat, sat_long, sat_elev / 1000)

x *= 1000
y *= 1000
z *= 1000
return x,y,z

现在只需要aer2ecef()方法即可返回正确的位置...

Now just need aer2ecef() method to return proper position...

推荐答案

如果您可以提供已打开的新问题的链接,并用绿色复选框标记该答案,则该问题将不再显示为在Stack Overflow上未解决的PyEphem问题,并挤满了我们中那些在该领域中寻找未解决问题的控制台.感谢您与可能会跟随您的人们分享您的大量工作!

If you could provide a link to the new question you have opened, and also mark this answer with the green checkbox, then this question will no longer show up as an unanswered PyEphem question on Stack Overflow and crowd the consoles of those of us who look out for unanswered questions in this area. Thanks for sharing so much of your work for those who will might follow in your footsteps!

这篇关于使用spg4,pyephem进行Python卫星跟踪-位置不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆