日地距离与计算(日期)和计算(观察者)的差异

Difference in sun-earth distance with compute(date) and compute(observer)

在下面的代码中,使用 pyephem 计算地日距离与使用 sun.compute(date) 时从 skyfield 进行的一次计算非常吻合,但在使用 sun.compute(obs) 时则不然在同一天观察地球上的观察者。

这是因为在 "ephem2" 的情况下 sun.earth_distance 是太阳到观察者的距离,而不是到地球中心的距离?

from datetime import datetime
import ephem
from skyfield.api import load, utc
from numpy import deg2rad

date = datetime(2012,12,10,20,tzinfo=utc)

# skyfield
planets = load('de421.bsp')
earth,sun = planets['earth'],planets['sun']
ts = load.timescale()
t = ts.utc(date)
astrometric = earth.at(t).observe(sun)
ra, dec, distance = astrometric.radec()
d_skyfield = distance.m

# ephem
sun = ephem.Sun()
sun.compute(date)
d_ephem = sun.earth_distance*ephem.meters_per_au

# ephem2
obs = ephem.Observer()
obs.date = date
obs.lon = deg2rad(-97.4856)
obs.lat = deg2rad(36.604)
obs.elevation = 320
obs.pressure = 0

sun = ephem.Sun()
sun.compute(obs)
d_ephem2 = sun.earth_distance*ephem.meters_per_au

print 'Skyfield, Ephem',d_skyfield,d_ephem
print 'diff',(d_skyfield-d_ephem)/1000.0,'km'
print 'ratio',d_skyfield/(d_ephem)

print '\nSkyfield, Ephem2',d_skyfield,d_ephem2
print 'diff',(d_skyfield-d_ephem2)/1000.0,'km'
print 'ratio',d_skyfield/(d_ephem2)

print '\nEphem, Ephem2',d_ephem,d_ephem2
print 'diff',(d_ephem-d_ephem2)/1000.0,'km'
print 'ratio',d_ephem/(d_ephem2)

输出:

Skyfield, Ephem 147310866157.34006 1.47310854128e+11
diff 12.029628997802734 km
ratio 1.000000081661525

Skyfield, Ephem2 147310866157.34006 1.47308027525e+11
diff 2838.632373474121 km
ratio 1.000019270045368

Ephem, Ephem2 1.47310854128e+11 1.47308027525e+11
diff 2826.60274448 km
ratio 1.00001918838

编辑:

按照 Brandon 的建议,添加带有天空场的 topos 对象会得到与 sun.compute(观察者)相同的结果。

from skyfield.toposlib import Topos

# skyfield2
lamont = Topos(latitude_degrees=36.604,longitude_degrees=-97.4856,elevation_m=320)
lamont = earth + lamont
astrometric = lamont.at(t).observe(sun)
ra, dec, distance = astrometric.radec()
d_skyfield2 = distance.m

输出:

Skyfield, Skyfield2 147310866157.34006 147308040439.59784
diff 2825.7177422180175 km
ratio 1.0000191823727598

Skyfield2, Ephem2 147308040439.59784 1.47308027525e+11
diff 12.914631256103515 km
ratio 1.0000000876709265

剩余约 12 公里的差异随 time/location

变化

是的,我希望差异是因为测量是针对观察者的位置进行的;你能用Skyfield "Topos" 对象对Skyfield 做同样的测量,看看他们是否同意?