Determine coordinates at conjunction times

时光怂恿深爱的人放手 提交于 2021-02-10 14:38:07

问题


The inferior conjunction of Venus today (while still being observable due to the northerly offset from the Sun) inspired the following research in pyEphem.

  1. Determine the date when Venus has an inferior conjunction with the Sun. Is there a search function for (inferior) conjunctions between Venus and the Sun in pyEphem?
  2. Determine the ecliptical latitude of Venus at the date. That should be easy.
  3. Do this for conjunctions for the last 100 and next 100 years. That's just a loop.

I was wondering how to do this in pyEphem.

Thanks, Gert


回答1:


Doing it in PyEphem would be awkward because of the maneuvers necessary to reduce its return values to numbers ­— but it would look something like the following code, which instead uses the more modern Skyfield library for astronomy in Python. (This code also needs SciPy installed, so that its solver can be used to find the exact moment of conjunction:)

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()

Whichever astronomy library you use, that's the general approach to take: big steps forward through time (in this example, 1 month steps) looking for when Venus passes from being ahead of the Sun to behind it in longitude. Then, return to each of those months and zero in on the exact moment when their longitudes are the same. Here are a few values printed by the above script, which you can spot-check against published values from the USNO or other sources:

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


来源:https://stackoverflow.com/questions/43024371/determine-coordinates-at-conjunction-times

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!