我在使用天空场时遇到问题 python
I am having problems with skyfield python
我想知道木星的日心位置,以及对应的黄道带
但我遇到了一些基本问题。
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'
如果有人能帮我解决错误问题,然后建议我如何将木星映射到星座,我将不胜感激。
如document所说,如果要获取太阳和木星的数据,需要先加载星历文件。下载后,可以从文件中获取日心位置。
代码示例如下:
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">
我想知道木星的日心位置,以及对应的黄道带 但我遇到了一些基本问题。
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'
如果有人能帮我解决错误问题,然后建议我如何将木星映射到星座,我将不胜感激。
如document所说,如果要获取太阳和木星的数据,需要先加载星历文件。下载后,可以从文件中获取日心位置。
代码示例如下:
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">