Python ephem 计算日出日落提前一小时
Python ephem calculates sunrise and sunset one hour to early
Ephem 比日出和日落早了大约一个小时。这是我的代码,google 预测(我自己验证过)和 ephem 预测。几乎相差一小时左右。日期时间函数工作正常,所以我认为它与我的设置无关:
print(datetime.datetime.now())
2020-03-12 11:51
Ephem:浮动 - 日出:2020/3/13 05:24:15 日落:2020/3/12 17:06:23
Google 同一日期的结果:日出/日落:06:27 / 18:06
有人能发现我犯的错误吗?我在 Python 3.7 和 ephem-3.7.7.0.
的 debian 上使用 spyder3 和 anaconda
def isTheSunShining(mydate, mytime):
mycity = ephem.cities.city("Berlin")
floatime_rise = mycity.next_rising(ephem.Sun())
floatime_set = mycity.next_setting(ephem.Sun())
print("Float - Sunrise: " + str(floatime_rise) + " Sunset: " + str(floatime_set))
来自文档:
PyEphem’s Date type itself does not support time zones. All PyEphem dates are expressed in Universal Time (UTC), which is similar to Standard Time in Greenwich, England. But if you need a time displayed in your local timezone, then you can use the PyEphem localtime function, which takes a PyEphem date and returns a Python datetime giving your local time.
Ephem 比日出和日落早了大约一个小时。这是我的代码,google 预测(我自己验证过)和 ephem 预测。几乎相差一小时左右。日期时间函数工作正常,所以我认为它与我的设置无关:
print(datetime.datetime.now())
2020-03-12 11:51
Ephem:浮动 - 日出:2020/3/13 05:24:15 日落:2020/3/12 17:06:23
Google 同一日期的结果:日出/日落:06:27 / 18:06
有人能发现我犯的错误吗?我在 Python 3.7 和 ephem-3.7.7.0.
的 debian 上使用 spyder3 和 anacondadef isTheSunShining(mydate, mytime):
mycity = ephem.cities.city("Berlin")
floatime_rise = mycity.next_rising(ephem.Sun())
floatime_set = mycity.next_setting(ephem.Sun())
print("Float - Sunrise: " + str(floatime_rise) + " Sunset: " + str(floatime_set))
来自文档:
PyEphem’s Date type itself does not support time zones. All PyEphem dates are expressed in Universal Time (UTC), which is similar to Standard Time in Greenwich, England. But if you need a time displayed in your local timezone, then you can use the PyEphem localtime function, which takes a PyEphem date and returns a Python datetime giving your local time.