python 使用skyfield进行轨道计算
/*====安装 ======*/
pip install skyfield
依赖numpy,scipy, 建议安装anaconda
/*====使用======*/
计算火星在天空中的位置:
from skyfield.api import load # Create a timescale and ask the current time. ts = load.timescale() t = ts.now() # Load the JPL ephemeris DE421 (covers 1900-2050). planets = load('de421.bsp') earth, mars = planets['earth'], planets['mars'] # What's the position of Mars, viewed from Earth? astrometric = earth.at(t).observe(mars) ra, dec, distance = astrometric.radec() print(ra) print(dec) print(distance)
输出为:
10h 47m 56.24s +09deg 03' 23.1" 2.33251 au
/*====推荐======*/
相比较PyEphem 而言,skyfiled 全部由python编写,更容易发挥python的优势,在后续的版本升级和迭代支持优于PyEphem,毕竟PyEphem的官网也写了,如果是新研发的项目,建议使用skyfield。
参见Skyfield — documentationhttps://rhodesmill.org/skyfield/