首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AstroPy的语法?Python坐标转换时间

AstroPy的语法?Python坐标转换时间
EN

Stack Overflow用户
提问于 2017-09-29 18:15:57
回答 1查看 361关注 0票数 0

我试图使用AstroPy将卫星的坐标从ECI转换到给定时间的纬度、经度和高度。但是,我无法获得使用AstroPy obstime的时间部分。我不确定这是UTC时间的语法错误还是其他原因。

代码语言:javascript
复制
'New Method #1: ECI --> Lat, Lon, Alt'
from astropy import coordinates as coord
from astropy import units as u
from astropy import time
from astropy.time import Time

xyz = (orbitPineapple.r.x, orbitPineapple.r.y, orbitPineapple.r.z)      #position of satellite in GCRS or J2000 ECI
now = time.Time('2017-09-28 16:53:40') #Time in UTC for xyz
cartrep = coord.CartesianRepresentation(*xyz, unit=u.m) #adding units of [m] to xyz

gcrs = coord.GCRS(cartrep, obstime=now)
itrs = gcrs.transform_to(coord.ITRS, obstime=now)
loc = coord.EarthLocation(*itrs.cartesian.xyz)

print(orbitPineapple.r)
print('')
print(loc.lat, loc.lon, loc.height)

输入:(位置(x=-2686197.0596728502,y=-6402017.6107924329,z=10956.564679617248))

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-10-02 00:13:12

该解决方案类似于您先前问题How to convert Earth Centered Inertial (ECI) coordinates to Earth Centered Earth Fixed (ECEF) AstroPy? Other?的答案。

需要将obstime传递给ITRS()类:

代码语言:javascript
复制
itrs = gcrs.transform_to(coord.ITRS(obstime=now))

所以,完整地(我从您的问题中复制了xyz坐标,因为我没有看到orbitPineapple的定义)

代码语言:javascript
复制
from astropy import coordinates as coord
from astropy import units as u
from astropy import time
from astropy.time import Time

xyz = [-2686197.0596728502, -6402017.6107924329, 10956.564679617248]
now = time.Time('2017-09-28 16:53:40') #Time in UTC for xyz
cartrep = coord.CartesianRepresentation(*xyz, unit=u.m) #adding units of [m] to xyz

gcrs = coord.GCRS(cartrep, obstime=now)
itrs = gcrs.transform_to(coord.ITRS(obstime=now))
loc = coord.EarthLocation(*itrs.cartesian.xyz)

print('')
print(loc.lat, loc.lon, loc.height)
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46494755

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档