Astropy中是否有日落/日出功能?

时间:2016-01-22 17:23:51

标签: python coordinates pyephem astropy

我在这里看到了几个关于PyEphem的答案以及它如何产生日落/日出时间,但是如果我能找到仅使用Astropy软件包的解决方案,对我来说会更有用。目前,我找到的最接近的是 astropy.coordinates 包中的(get_sun)函数。这个日落/日出功能是否已经内置于Astropy中?

2 个答案:

答案 0 :(得分:13)

Astroplan包中有一个Observer类,其中包含Observer.sun_rise_timeObserver.sun_set_time方法。

Astroplan是Astropy affiliated package

此功能是否将在未来放入核心Astropy软件包或保留在Astroplan中是不是很清楚。但是使用pip install astroplanconda install -c astropy astroplan,您可以轻松安装Astroplan并使用它。

答案 1 :(得分:1)

使用get_sun可以很容易地计算出太阳的当前位置,这可以扩展到确定下一个日出或日落时间。

我使用以下方法检查是否接近日出以自动关闭望远镜。

def almostSunrise():                                                                                
    now = Time(datetime.utcnow(), format='datetime', scale='utc')                                  
    altazframe = AltAz(obstime=now, location=lapalma)                                               
    sunaltaz = get_sun(now).transform_to(altazframe)                                                
    if sunaltaz.alt.value >= -5 and sunaltaz.alt.value <= 5:                                         
        return True                                                                                 
    else:                                                                                           
        return False 

其中lapalma是我设置的EarthLocation

相关问题