如何计算春分/夏至时刻?

发布于 2024-07-16 14:59:52 字数 348 浏览 13 评论 0原文

有哪些算法或公式可用于计算春分和至日? 几年前我发现了其中一个并实现了它,但精度不是很好:一天中的时间似乎假定为 00:00、06:00、12:00 和 18:00 UTC,具体取决于哪个春分点或计算至日。 维基百科给出了这些计算结果,所以更精确的东西一定是可能的。 我最喜欢的编程语言的库也出现在那些硬编码时代,所以我假设它们使用与我实现的算法相同或相似的算法。

我也曾经尝试使用一个为我提供太阳经度的库,并在 0、90、180 和 270 度的精确时刻执行搜索程序以将其归零; 这有效到了第二个,但与维基百科中的时代不一致,所以我认为这种方法有问题。 然而,我惊喜地发现迈蒙尼德(中世纪犹太学者)在千年前提出了一种使用完全相同想法的算法。

What algorithms or formulas are available for computing the equinoxes and solstices? I found one of these a few years ago and implemented it, but the precision was not great: the time of day seemed to be assumed at 00:00, 06:00, 12:00, and 18:00 UTC depending on which equinox or solstice was computed. Wikipedia gives these computed out to the minute, so something more exact must be possible. Libraries for my favorite programming language also come out to those hardcoded times, so I assume they are using the same or a similar algorithm as the one I implemented.

I also once tried using a library that gave me the solar longitude and implementing a search routine to zero in on the exact moments of 0, 90, 180, and 270 degrees; this worked down to the second but did not agree with the times in Wikipedia, so I assume there was something wrong with this approach. I am, however, pleasantly surprised to discover that Maimonides (medieval Jewish scholar) proposed an algorithm using the exact same idea a millenium ago.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

分分钟 2024-07-23 14:59:52

(复杂!)底层公式和算法的一个重要来源是天文算法让·梅厄斯着。

使用这些算法的 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

当然,答案并不精确到微秒,但我也想展示如何使用 arrow 进行高精度转换。

代码:

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)))

使用非常酷的ISO和TZ感知模块箭头:更好的日期以及 Python 的时间,可以打印得更好:

import arrow
import math

slutc = solstice_epoch.get_full_date(utc=True)
frac, whole = math.modf(slutc[5])

print("i.e. %s" % arrow.get(*slutc[:5], int(whole), round(frac * 1e6)).to('local'))

A great source for the (complex!) underlying formulas and algorithms is Astronomical Algorithms by Jean Meeus.

Using the PyMeeus implementation of those algorithms, and the code below, you can get the following values for the 2018 winter solstice (where "winter" refers to the northern hemisphere).

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

Of course, the answer is not accurate down to microseconds, but I also wanted to show how to do high-precision conversions with arrow.

Code:

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)))

Using the very cool more ISO and TZ aware module Arrow: better dates and times for Python, that can be printed more nicely:

import arrow
import math

slutc = solstice_epoch.get_full_date(utc=True)
frac, whole = math.modf(slutc[5])

print("i.e. %s" % arrow.get(*slutc[:5], int(whole), round(frac * 1e6)).to('local'))
£噩梦荏苒 2024-07-23 14:59:52

我不确定这对您来说是否是一个足够准确的解决方案,但我找到了一个 NASA 网站< /a> 其中有一些用于计算春分的代码片段以及一些其他天文类型的信息。 我还发现了一些对一本名为 天文算法 的书的引用,其中可能有如果无法在线获取信息,您需要的答案。

I'm not sure if this is an accurate enough solution for you, but I found a NASA website that has some code snippets for calculating the vernal equinox as well as some other astronomical-type information. I've also found some references to a book called Astronomical Algorithms which may have the answers you need if the info somehow isn't available online.

南冥有猫 2024-07-23 14:59:52

我知道您正在寻找可以粘贴到此处答案的内容,但我必须提及 SPICE ,由 NAIF 在 JPL 制作、由 NASA 资助的工具包。 对于农夫年鉴的东西来说,这可能有点过分了,但你提到了对精度的兴趣,而且这个工具包通常用于行星科学。

I know you're looking for something that'll paste into an answer here, but I have to mention SPICE, a toolkit produced by NAIF at JPL, funded by NASA. It might be overkill for Farmer's Almanac stuff, but you mentioned interest in precision and this toolkit is routinely used in planetary science.

从﹋此江山别 2024-07-23 14:59:52

如果您有兴趣,我已经用 C 和 Java 实现了 Jean Meeus(上面提到的天文算法的作者)的春分和至日算法。

I have implemented Jean Meeus' (the author of the Astronomical Algorithms referenced above) equinox and solstice algorithm in C and Java, if you're interested.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文