今天金星的低级连接(虽然由于偏离太阳而仍然可以观察到)激发了pyEphem的以下研究。
我想知道如何在pyEphem中做到这一点。
谢谢, 格特
答案 0 :(得分:1)
在PyEphem中执行它会很尴尬,因为必须将其返回值减少到数字 - 但它看起来像下面的代码,而是使用更现代的Skyfield库来进行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