Pyephem calculate current solar time

若如初见. 提交于 2020-01-02 18:47:07

问题


I am trying to calculate the local solar time based on UTC hour and longitude. I have looked through the ephem package but was not able to identify a direct method to do so. Similar questions on this matter either evoke the calculation of fixed positions (sunrise, moon, sunset) (e.g. Calculating dawn and sunset times using PyEphem) or receive suggestions of simplified methods (e.g. Local solar time function from UTC and longitude). Is there any alternative to the aforementioned solutions?

Thanks in advance


回答1:


To compute local solar time, I think that you can just ask for the current right ascension of the point directly beneath the location (its nadir point), and subtract the right ascension of the Sun to learn exactly how far from local midnight it is:

from ephem import Sun, Observer, pi, hours

dt = '2016/08/27 19:19'

sun = Sun()
sun.compute(dt)

boston = Observer()
boston.lat = '42.37'
boston.lon = '-71.03'
boston.date = dt
ra, dec = boston.radec_of('0', '-90')

print 'Sun right ascension:', sun.ra
print 'Boston nadir right ascension:', ra
print 'Solar time:', hours((ra - sun.ra) % (2 * pi)), 'hours'

Could you try out this approach and see whether it gives the numbers you expect to reasonable precision?



来源:https://stackoverflow.com/questions/39163549/pyephem-calculate-current-solar-time

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!