0

我正在尝试编写一个 python 脚本,该脚本将使用 SkyField 和 SciPy 库来查找五重行星合相......具体来说,我正在寻找 5 个可见行星都在白羊座内合相的日期。这种情况应该非常罕见,我只需要找出它是否以及何时发生在过去 10 万年左右......

PyEphem有这个脚本,这里有SkyField 解决方案来查找连词。

我能够修改天域解决方案以找到过去 5000 年的合相:

import scipy.optimize
from skyfield.api import load, pi, tau

ts = load.timescale()
eph = load('de422.bsp')
sun = eph['sun']
earth = eph['earth']
venus = eph['venus']
mercury = eph['mercury']
mars = eph['mars']
jupiter = eph['jupiter barycenter']
saturn = eph['saturn barycenter']

#aries = star['aries']

# Every month from year 2000 to 2050.
t = ts.utc(-2999, range(12 * 5000))

# Where in the sky were Venus and the Sun on those dates?
e = earth.at(t)

#lat, lon, distance = e.observe(aries).ecliptic_latlon()
#al = lon.radians

lat, lon, distance = e.observe(sun).ecliptic_latlon()
sl = lon.radians

lat, lon, distance = e.observe(venus).ecliptic_latlon()
vl = lon.radians

lat, lon, distance = e.observe(mercury).ecliptic_latlon()
ml = lon.radians

lat, lon, distance = e.observe(mars).ecliptic_latlon()
mal = lon.radians

lat, lon, distance = e.observe(jupiter).ecliptic_latlon()
jl = lon.radians

lat, lon, distance = e.observe(saturn).ecliptic_latlon()
sal = lon.radians

# Where was Mercury conjoined with Venus?  Compute their difference in
# longitude, wrapping the value into the range [-pi, pi) to avoid
# the discontinuity when one or the other object reaches 360 degrees
# and flips back to 0 degrees.
relative_lon = (vl - ml + pi) % tau - pi
relative_lon2 = (mal - ml + pi) % tau - pi
relative_lon3 = (jl - ml + pi) % tau - pi
relative_lon4 = (sal - ml + pi) % tau - pi

# Find where Venus passed from being ahead of the Sun to being behind.
conjunctions = (relative_lon >= 0)[:-1] & (relative_lon < 0)[1:] & (relative_lon2 >= 0)[:-1] & (relative_lon2 < 0)[1:] & (relative_lon3 >= 0)[:-1] & (relative_lon3 < 0)[1:] & (relative_lon4 >= 0)[:-1] & (relative_lon4 < 0)[1:]

# For each month that included a conjunction, ask SciPy exactly when
# the conjunction occurred.

def f(jd):
    "Compute how far away in longitude Venus and Mercury are."
    t = ts.tt(jd=jd)
    e = earth.at(t)
    lat, lon, distance = e.observe(venus).ecliptic_latlon()
    vl = lon.radians
    lat, lon, distance = e.observe(mercury).ecliptic_latlon()
    ml = lon.radians
    relative_lon = (vl - ml + pi) % tau - pi
    return relative_lon

for i in conjunctions.nonzero()[0]:
    t0 = t[i]
    t1 = t[i + 1]
    print("Starting search at", t0.utc_jpl())
    jd_conjunction = scipy.optimize.brentq(f, t[i].tt, t[i+1].tt)
    print("Found conjunction:", ts.tt(jd=jd_conjunction).utc_jpl())
    print()

这会输出 9 个日期......这似乎适合如此罕见的事情。

谁能确认我这样做对吗?

如何导入星星?我必须创建它还是有一个星历表?有公元前 3000 年之前的星历吗?

4

0 回答 0