Azimuth/Altitude PyEphem 和 Skyfield 之间的差异

Azimuth/Altitude discrepancy between PyEphem and Skyfield

我无法解决为什么 PyEphem 和 Skyfield 之间的彗星计算结果不同 azimuth/altitude,但赤经和赤纬匹配。

代码示例:

#!/usr/bin/env python3


# External verification:
# https://in-the-sky.org/data/object.php?id=0088P
# https://theskylive.com/88p-info
# https://heavens-above.com/comet.aspx?cid=88P
# https://www.calsky.com/cs.cgi/Comets/3?


import datetime, ephem, io, skyfield.api, skyfield.constants, skyfield.data.mpc


now = datetime.datetime.strptime( "2020-07-22", "%Y-%m-%d" )
latitude = -33
longitude = 151

cometName = "88P/Howell"

# https://minorplanetcenter.net/iau/Ephemerides/Comets/Soft03Cmt.txt
cometDataPyEphem = "88P/Howell,e,4.3838,56.6855,235.9159,3.105737,0.1800765,0.56433120,347.8225,07/21.0/2020,2000,g 11.0,6.0"

# https://minorplanetcenter.net/iau/Ephemerides/Comets/Soft00Cmt.txt
cometDataSkyfield = "0088P         2020 09 26.6241  1.353073  0.564331  235.9159   56.6855    4.3838  20200721  11.0  6.0  88P/Howell                                               MPEC 2019-JE2"


print( "PyEphem:", ephem.__version__ )
print( "Skyfield:", skyfield.__version__ )


# PyEphem
observer = ephem.Observer()
observer.date = ephem.Date( now )
observer.lat = latitude
observer.lon = longitude

body = ephem.readdb( cometDataPyEphem )
body.compute( observer )

print( "PyEphem comet", cometName,
       "\n\tLat:", observer.lat,
       "\n\tLon:", observer.lon,
       "\n\tAlt:", body.alt,
       "\n\tRA:", body.ra,
       "\n\tDec:", body.dec )


# Skyfield
timeScale = skyfield.api.load.timescale( builtin = True )
topos = skyfield.api.Topos( latitude_degrees = latitude, longitude_degrees = longitude )
ephemeris = skyfield.api.load( "de421.bsp" )

with io.BytesIO( cometDataSkyfield.encode() ) as f:
    dataframe = skyfield.data.mpc.load_comets_dataframe( f ).set_index( "designation", drop = False )

sun = ephemeris[ "sun" ]
earth = ephemeris[ "earth" ]
body = sun + skyfield.data.mpc.comet_orbit( dataframe.loc[ cometName ], timeScale, skyfield.constants.GM_SUN_Pitjeva_2005_km3_s2 )

t = timeScale.utc( now.year, now.month, now.day, now.hour, now.minute, now.second )
alt, az, bodyDistanceToEarth = ( earth + topos ).at( t ).observe( body ).apparent().altaz()
ra, dec, bodyDistanceToEarth = ( earth + topos ).at( t ).observe( body ).radec()

print( "Skyfield comet", cometName,
       "\n\tAz:", az, 
       "\n\tAlt:", alt, 
       "\n\tRA:", ra, 
       "\n\tDec:", dec )

PyEphem 和 Skfield 之间的 RA/Dec 匹配以及与几个网站的匹配(请参阅顶部的评论部分)。虽然 Az/Alt 的 Skyfield 值有点接近 Heavens Above 给出的值,但我无法确定为什么 Az/Alt.

的 PyEphem 和 Skyfield 之间存在差异

编辑:修改脚本以打印出 lat/lon 和示例(正确)结果:

PyEphem: 3.7.6.0
Skyfield: 1.24
PyEphem comet 88P/Howell 
    Lat: -33:00:00.0 
    Lon: 151:00:00.0 
    Az: 109:52:54.6 
    Alt: -11:19:11.4 
    RA: 13:27:08.32 
    Dec: -9:56:54.6 
Skyfield comet 88P/Howell 
    Lat: -33deg 00' 00.0" 
    Lon: 151deg 00' 00.0" 
    Az: 109deg 53' 03.4" 
    Alt: -11deg 19' 23.4" 
    RA: 13h 26m 04.51s 
    Dec: -09deg 50' 37.9" 

如果您尝试打印出 PyEphem 观察器位置:

print(observer.lat)
print(observer.lon)

你会发现你的观察者的坐标与你预期的不同:

-1890:45:38.6
8651:39:45.7

那是因为 PyEphem 将浮点角度解释为弧度,这就是您的数字 -33151 的解释方式。要让 PyEphem 将它们解释为度数,请改为发送字符串:

observer.lat = str(latitude)
observer.lon = str(longitude)

然后脚本应该显示两个库之间非常接近的一致性。

我现在认为 PyEphem 试图让它在度数和弧度之间切换如此“方便”是一个错误,但如果不破坏所有现有的 PyEphem 脚本就无法修复它。所以我写了 Skyfield,它从不根据类型做出奇怪的决定,并且总是尝试标记值 degreesradians 以便程序员清楚期望的单位是什么。