问题描述
我正在尝试编写一个程序来计算在给定时间有哪些行星在地平线以上,以及行星在天空中的方向,但我得到的结果不正确。我的代码在下面,有人知道可能是什么问题吗?
import numpy as np
import skyfield
from skyfield.api import load
planets = load('de441.bsp')
ts = load.timescale()
earth = planets['earth']
other_planets = [planets['mercury barycenter'],planets['venus barycenter'],planets['mars barycenter'],planets['jupiter barycenter'],planets['saturn barycenter']]
other_planet_names = ["Mercury","Venus","Mars","Jupiter","Saturn"]
directions = ["North","Northeast","East","Southeast","South","Southwest","West","Northwest"]
def planets_visible(time):
numPlanetsViewed = 0
for i in range (0,5):
az,dec,distance = earth.at(time).observe(other_planets[i]).radec()
if dec._degrees > 0:
numPlanetsViewed = numPlanetsViewed + 1
string = other_planet_names[i] + " is " + str(int((round(dec._degrees,0)))) + " degrees above the horizon!"
print(string)
direction = int(np.floor(((az._degrees - 22.5) % 360) / 45))
string2 = " It is visible to the " + directions[direction] + "."
print(string2)
print(" ")
if numPlanetsViewed == 0:
print("Sorry,none of the four major planets are visible at this time!")
now = ts.now()
planets_visible(now)
我一直在说,现在(2021 年 4 月 7 日,下午 4:00),正确的行星是可见的 - 是的! – 但是方位角都关闭了,例如,当它是 SE 时说火星是 NE(我不能说正确的提升,因为我现在不知道它们,但我认为这些也是关闭的。)有人知道怎么回事吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)