PyEphemでそれを行うには、理由の番号にその戻り値を減少させるために必要な操作の厄介になりますPythonの天文学のために。 (このコードはまた、そのソルバが連動:)の正確な瞬間を見つけるために使用することができるようにscipyのダウンロードは、インストール必要があり、使用天文学のライブラリは、それが一般的なアプローチを取ることですどちら
import scipy.optimize
from skyfield.api import load, pi, tau
ts = load.timescale()
eph = load('de421.bsp')
sun = eph['sun']
earth = eph['earth']
venus = eph['venus']
# Every month from year 2000 to 2050.
t = ts.utc(2000, range(12 * 50))
# Where in the sky were Venus and the Sun on those dates?
e = earth.at(t)
lat, lon, distance = e.observe(sun).ecliptic_latlon()
sl = lon.radians
lat, lon, distance = e.observe(venus).ecliptic_latlon()
vl = lon.radians
# Where was Venus relative to the Sun? 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 - sl + 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:]
# 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 the Sun are."
t = ts.tt(jd=jd)
e = earth.at(t)
lat, lon, distance = e.observe(sun).ecliptic_latlon()
sl = lon.radians
lat, lon, distance = e.observe(venus).ecliptic_latlon()
vl = lon.radians
relative_lon = (vl - sl + 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()
:大きなステップを前方時間を通じて(この例では、1ヶ月ステップ)、金星が太陽の前から経度の後ろを通過するときを探します。その後、それぞれの月に戻り、正確な瞬間をゼロにします。上記のスクリプトで印刷されたいくつかの値は、USNOや他の情報源から公表された値に対してスポットチェックすることができます:
Starting search at A.D. 2013-Dec-24 00:00:00.0000 UT
Found conjunction: A.D. 2014-Jan-11 12:24:30.8031 UT
Starting search at A.D. 2015-Jul-28 00:00:00.0000 UT
Found conjunction: A.D. 2015-Aug-15 19:21:55.1672 UT
Starting search at A.D. 2017-Mar-01 00:00:00.0000 UT
Found conjunction: A.D. 2017-Mar-25 10:17:27.5276 UT
Starting search at A.D. 2018-Oct-03 00:00:00.0000 UT
Found conjunction: A.D. 2018-Oct-26 14:16:19.3941 UT
Starting search at A.D. 2020-May-06 00:00:00.0000 UT
Found conjunction: A.D. 2020-Jun-03 17:43:37.7391 UT