PyEphem:无法获得正确答案(菜鸟)

PyEphem: Can't get correct answers (noob)

我从 this post 复制了脚本并针对我附近的位置进行了修改。但是当我 运行 它时,即使在调整了本地 UTC 偏移量 (-7h) 之后,我得到的日出、日落和天文暮光的时间也毫无意义。例如,它在 03:34:51 UTC 报告日出,也就是前一天的 20:34:51。实际上,lat/long 的日出应该是 06:37 PDT (UTC - 7h)。

我在下面包含了修改后的代码。我做错了什么?

from datetime import datetime
import ephem

# Make an observer
my = ephem.Observer()

# PyEphem takes and returns only UTC times.
now = datetime.now()
nowutc = datetime.utcnow()
my.date = nowutc.strftime("%Y-%m-%d %H:%M:%S")

# Location and elevation of TDS
my.lon = str(32.614)  # Note that lon should be in string format
my.lat = str(-116.333)  # Note that lat should be in string format
my.elev = 1140  # in meters

# To get U.S. Naval Astronomical Almanac values, use these settings
my.pressure = 0
my.horizon = '-0:34'

sunrise = my.previous_rising(ephem.Sun())  # Sunrise
noon = my.next_transit(ephem.Sun(), start=sunrise)  # Solar noon
sunset = my.next_setting(ephem.Sun())  # Sunset

# We relocate the horizon to get twilight times
my.horizon = '-18'  # -6=civil twilight, -12=nautical, -18=astronomical
beg_twilight = my.previous_rising(ephem.Sun(), use_center=True)  # Begin civil twilight
end_twilight = my.next_setting(ephem.Sun(), use_center=True)  # End civil twilight

请检查您是否将经纬度调反了。通过交换这些数字,您询问的地球表面位置与您预期的不同。