PyEphem에서 지내요 때문에 번호의 반환 값을 감소하는 데 필요한 기동의 어색한 것 -하지만 대신 더 현대적인 Skyfield 라이브러리를 사용하는 다음 코드처럼 보일 것입니다 파이썬에서의 천문학. (이 코드는 또한 솔버가 함께 :)의 정확한 순간을 찾기 위해 사용할 수 있도록 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 개월 단위로) 금성이 태양보다 먼저 지나가고 경도로 뒤에서 지나갈 때를 찾습니다. 그런 다음, 각각의 달로 돌아가서 경도가 동일한 정확한 순간을 0으로하십시오. 위의 스크립트에서 인쇄 한 몇 가지 값은 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