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

时间:2018-10-26 15:13:56

标签: pyephem skyfield

在下面的代码中,使用pyephem计算地球与太阳之间的距离与使用sun.compute(date)进行的从天空场进行的计算非常吻合,但是与使用obs在地球上的观察者进行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

编辑:

按照布兰登的建议,在天空中添加topos对象的结果与sun.compute(obsever)相同。

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 km差异随时间/位置而变化

1 个答案:

答案 0 :(得分:1)

是的,我希望两者之间的差异是因为该措施是根据观察者的位置进行的;您可以使用Skyfield的“ Topos”对象对Skyfield进行相同的测量并查看它们是否同意?