有哪些算法或公式可用于计算昼夜平分点和至终点?几年前我找到了其中一个并实现了它,但精度并不高:一天中的时间似乎假设在00:00,06:00,12:00和18:00 UTC,具体取决于哪个昼夜平分点或至日计算.维基百科给出了这些计算出的分钟,因此必须有更精确的东西.我最喜欢的编程语言的库也出现在那些硬编码时代,因此我假设他们使用的算法与我实现的相同或类似.
我曾经尝试过使用一个图书馆,它给了我太阳经度,并实现了一个搜索程序,在0度,90度,180度和270度的确切时刻归零; 这可以归结为第二个,但不同意维基百科的时代,所以我认为这种方法有问题.然而,我惊喜地发现迈蒙尼德(中世纪犹太学者)在千禧年之前使用完全相同的想法提出了一种算法.
Jean Meeus 的《天文算法》是(复杂!)基础公式和算法的重要来源。
使用这些算法的PyMeeus实现以及下面的代码,您可以获得 2018 年冬至的以下值(其中“冬天”指的是北半球)。
winter solstice for 2018 in Terrestrial Time is at:
(2018, 12, 21, 22, 23, 52.493725419044495)
winter solstice for 2018 in UTC, if last leap second was (2016, 12):
(2018, 12, 21, 22, 22, 43.30972542127711)
winter solstice for 2018 in local time, if last leap second was (2016, 12)
and local time offset is -7.00 hours:
(2018, 12, 21, 15, 22, 43.30973883232218)
i.e. 2018-12-21T15:22:43.309725-07:00
Run Code Online (Sandbox Code Playgroud)
当然,答案并不精确到微秒,但我也想展示如何使用arrow.
代码:
winter solstice for 2018 in Terrestrial Time is at:
(2018, 12, 21, 22, 23, 52.493725419044495)
winter solstice for 2018 in UTC, if last leap second was (2016, 12):
(2018, 12, 21, 22, 22, 43.30972542127711)
winter solstice for 2018 in local time, if last leap second was (2016, 12)
and local time offset is -7.00 hours:
(2018, 12, 21, 15, 22, 43.30973883232218)
i.e. 2018-12-21T15:22:43.309725-07:00
Run Code Online (Sandbox Code Playgroud)
使用非常酷的 ISO 和 TZ 感知模块Arrow:Python 的更好的日期和时间,可以更好地打印:
from pymeeus.Sun import Sun
from pymeeus.Epoch import Epoch
year = 2018 # datetime.datetime.now().year
target="winter"
# Get terrestrial time of given solstice for given year
solstice_epoch = Sun.get_equinox_solstice(year, target=target)
print("%s solstice for %d in Terrestrial Time is at:\n %s" %
(target, year, solstice_epoch.get_full_date()))
print("%s solstice for %d in UTC, if last leap second was %s:\n %s" %
(target, year, Epoch.get_last_leap_second()[:2], solstice_epoch.get_full_date(utc=True)))
solstice_local = (solstice_epoch + Epoch.utc2local()/(24*60*60))
print("%s solstice for %d in local time, if last leap second was %s\n"
" and local time offset is %.2f hours:\n %s" %
(target, year, Epoch.get_last_leap_second()[:2],
Epoch.utc2local() / 3600., solstice_local.get_full_date(utc=True)))
Run Code Online (Sandbox Code Playgroud)
我不确定这对您来说是否是一个足够准确的解决方案,但我发现了一个NASA 网站,其中有一些用于计算春分的代码片段以及一些其他天文类型的信息。我还找到了一些名为《天文算法》的书的参考资料,如果无法在线获取该信息,该书可能会提供您需要的答案。