gpt4 book ai didi

pyephem - 带有Pyrephem的月相的人类可读名称

转载 作者:行者123 更新时间:2023-11-30 23:55:52 25 4
gpt4 key购买 nike

看来pyephem应该能够给我您在月球周期中所处位置的标准人型名称,并指定日期-“第一季度”,“满月”,“打蜡新月”,“渐渐隆起, ”等

我说不对吗?

有谁知道标准解决方案吗?

最佳答案

这是我对自己的问题的快速而肮脏的解决方案。假定observer与系统时区位于同一时区,但这对我而言已经足够。

仍然让人感到惊讶的是,ephephem并没有比这更精致的东西,但是也许出于天文学的原因,我不够聪明,无法理解。

import ephem

def human_moon(observer):
target_date_utc = observer.date
target_date_local = ephem.localtime( target_date_utc ).date()
next_full = ephem.localtime( ephem.next_full_moon(target_date_utc) ).date()
next_new = ephem.localtime( ephem.next_new_moon(target_date_utc) ).date()
next_last_quarter = ephem.localtime( ephem.next_last_quarter_moon(target_date_utc) ).date()
next_first_quarter = ephem.localtime( ephem.next_first_quarter_moon(target_date_utc) ).date()
previous_full = ephem.localtime( ephem.previous_full_moon(target_date_utc) ).date()
previous_new = ephem.localtime( ephem.previous_new_moon(target_date_utc) ).date()
previous_last_quarter = ephem.localtime( ephem.previous_last_quarter_moon(target_date_utc) ).date()
previous_first_quarter = ephem.localtime( ephem.previous_first_quarter_moon(target_date_utc) ).date()
if target_date_local in (next_full, previous_full):
return 'Full'
elif target_date_local in (next_new, previous_new):
return 'New'
elif target_date_local in (next_first_quarter, previous_first_quarter):
return 'First Quarter'
elif target_date_local in (next_last_quarter, previous_last_quarter):
return 'Last Full Quarter'
elif previous_new < next_first_quarter < next_full < next_last_quarter < next_new:
return 'Waxing Crescent'
elif previous_first_quarter < next_full < next_last_quarter < next_new < next_first_quarter:
return 'Waxing Gibbous'
elif previous_full < next_last_quarter < next_new < next_first_quarter < next_full:
return 'Waning Gibbous'
elif previous_last_quarter < next_new < next_first_quarter < next_full < next_last_quarter:
return 'Waning Crescent'

关于pyephem - 带有Pyrephem的月相的人类可读名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26702144/

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