gpt4 book ai didi

pyephem:无法计算极地地区的日出/日落

转载 作者:行者123 更新时间:2023-12-02 13:28:59 25 4
gpt4 key购买 nike

我正在尝试使用 pyephem 计算日出和日落,但该算法似乎从未在极地地区收敛?

观察下面的示例代码。它以 10 分钟为增量迭代一整年,询问下一次日出和日落。 pyephem 总是返回一个 AlwaysUpError 或 NeverUpError,但一年中太阳必须至少升起和落下一次吗?

import ephem
from datetime import datetime, timedelta

obs = ephem.Observer()
obs.lat = '89:30'
obs.long = '0'

start = datetime(2011, 1, 1)
end = datetime(2012, 1, 1)
step = timedelta(minutes=10)

sun = ephem.Sun()

timestamp = start
while timestamp < end:
obs.date = timestamp

try:
print obs.next_rising(sun)
except (ephem.AlwaysUpError, ephem.NeverUpError):
pass

try:
print obs.next_setting(sun)
except (ephem.AlwaysUpError, ephem.NeverUpError):
pass

try:
print obs.previous_rising(sun)
except (ephem.AlwaysUpError, ephem.NeverUpError):
pass

try:
print obs.previous_setting(sun)
except (ephem.AlwaysUpError, ephem.NeverUpError):
pass

timestamp += step

要么是我错误地使用了 api,pyephem 中存在错误,要么是我误解了一些基本的东西。有什么帮助吗?

最佳答案

我怀疑存在某种不正确的缓存。考虑:

import ephem 
atlanta = ephem.Observer()
atlanta.pressure = 0
atlanta.horizon = '-0:34'
atlanta.lat, atlanta.lon = '89:30', '0'
atlanta.date = '2011/03/18 12:00'
print atlanta.previous_rising(ephem.Sun())
print atlanta.next_setting(ephem.Sun())
atlanta.date = '2011/03/19 12:00'
print atlanta.previous_rising(ephem.Sun())
print atlanta.next_setting(ephem.Sun())
atlanta.date = '2011/03/20 12:00'
print atlanta.previous_rising(ephem.Sun())
# print atlanta.next_setting(ephem.Sun())
atlanta.date = '2011/09/24 12:00'
# print atlanta.previous_rising(ephem.Sun())
print atlanta.next_setting(ephem.Sun())
atlanta.date = '2011/09/25 12:00'
print atlanta.previous_rising(ephem.Sun())
print atlanta.next_setting(ephem.Sun())
atlanta.date = '2011/09/26 12:00'
print atlanta.previous_rising(ephem.Sun())
print atlanta.next_setting(ephem.Sun())

产生:

2011/3/18 07:49:34 
2011/3/18 17:44:50
2011/3/19 05:04:49
2011/3/19 21:49:23
2011/3/20 01:26:02
2011/9/24 19:59:09
2011/9/25 04:57:21
2011/9/25 17:14:10
2011/9/26 08:37:25
2011/9/26 14:03:20

与 USNO 结果匹配的分钟:

https://raw.github.com/barrycarter/bcapps/master/db/srss-895.txt

另请参阅链接问题中我的相关提示。

关于pyephem:无法计算极地地区的日出/日落,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6365182/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com