0

我想找出木星的日心位置,以及相应的黄道带,但我遇到了基本问题。

    from skyfield.api import sun, jupiter
    p = sun(utc=(1980, 1, 1)).observe(jupiter)
    lat, lon, d = p.ecliptic_latlon()
    print(lat)
    print(lon)

我得到的错误:

    Traceback (most recent call last):
      File "/home/panos/Desktop/skyfield test.py", line 1, in <module>
    from skyfield.api import sun, jupiter
    ImportError: cannot import name 'sun'

如果有人可以帮助我解决错误问题,然后向我建议如何将木星映射到星座,我将不胜感激。

4

1 回答 1

2

文件说,如果要获取太阳和木星的数据,首先需要加载星历文件。下载后,您可以从文件中获取日心位置。

代码示例如下:

from skyfield.api import load
ts = load.timescale()
t = ts.utc(1980, 1, 1)
#load "de421.bsp", which built at 2008 short size ephemeris files 
planets = load('de421.bsp')

sun = planets['Sun'] #get Sun data
jupiter = planets['jupiter_barycenter'] #get jupiter data, need to input full name

p = sun.at(t).observe(jupiter) #get jupiter position from zodiac
lat, lon, d = p.ecliptic_latlon()
print(lat)
print(lon)

结果如下:

<Angle +01deg 00' 46.7">
<Angle 151deg 19' 21.7">
于 2021-12-24T07:42:50.727 回答