【发布时间】:2015-01-31 14:36:51
【问题描述】:
我在使用 pyEphem 获取我所在位置的准确日出和日落时间时遇到了一些困难。我已经阅读了一些问题和答案,并查看了文档,但仍然不完全清楚我做错了什么。代码如下:
import datetime as dt
import ephem as ep
date = dt.datetime.now().strftime("%Y/%m/%d 00:00:00")
lat, lon = [<redacted>, -1.4147]
# Use lat and lon to create ephem observer instance and update with given
# values
my_location = ep.Observer()
my_location.lat = lat
my_location.lon = lon
my_location.date = date
# Get sunrise of the current day
sunrise = my_location.next_rising(ep.Sun())
sunset = my_location.next_setting(ep.Sun())
print "Given date: {0}".format(date)
print "Detected coordinates: {0}, {1}".format(lat, lon)
print "Sunrise at {0}".format(sunrise)
print " Sunset at {0}".format(sunset)
产生这个输出:
Given date: 2015/01/31 00:00:00
Detected coordinates: <redacted>, -1.4147
Sunrise at 2015/1/31 12:28:02
Sunset at 2015/1/31 22:47:39
我所期待的是获得午夜(今天早上)之后的第一次日出和之后的第一次日落的时间。现在我碰巧知道太阳在今天 12:30 之前升起(我在光天化日之下上午 9:30 走在路上),我不认为有 UTC 偏移,因为我知道我的时区。
我错过了什么?
【问题讨论】:
-
您的输出中似乎出现了 UTC 时间偏移
-
谢谢,虽然我确实生活在 UTC+00,但看起来确实如此。
-
这可能会有所帮助 - rhodesmill.org/pyephem/quick#transit-rising-setting - 特别是“observer.horizon”示例