Pyephem计算当前的太阳时

时间:2016-08-26 09:57:46

标签: python pyephem

我正在尝试根据UTC时间和经度计算当地的太阳时间。我查看了ephem包,但无法确定直接方法。关于这个问题的类似问题要么引起固定位置(日出,月亮,日落)的计算(例如Calculating dawn and sunset times using PyEphem),要么接受简化方法的建议(例如Local solar time function from UTC and longitude)。有没有上述解决方案的替代方案?

提前致谢

1 个答案:

答案 0 :(得分:2)

为了计算当地的太阳时间,我想你可以直接询问当前正好在该位置(它的最低点)下方的点的正确提升,并减去太阳的正确提升以准确地了解当地午夜的距离它是:

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'

你能尝试一下这种方法,看看它是否能给出合理精确度的数字吗?