如何计算日出/日落时间?

发布于 2024-07-15 13:21:15 字数 1459 浏览 7 评论 0原文

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

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

发布评论

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

评论(8

万劫不复 2024-07-22 13:21:15

您可以考虑阅读维基百科关于日出方程的文章。 主要段落给出了方程:

cos(ωo) = -tan(φ) * tan(δ)

其中:

  • ωo小时角度,以度为单位的日出(取负值时)或日落(取正值时)的角度(° )
  • φ 是地球上观测者的纬度,单位为度
  • δ 是太阳赤纬,单位为度

You may consider reading Wikipedia's article on sunrise equations. The lead paragraph gives the equation:

cos(ωo) = -tan(φ) * tan(δ)

where:

  • ωo is the hour angle in degrees at either sunrise (when negative value is taken) or sunset (when positive value is taken) in degree (°)
  • φ is the latitude of the observer on the Earth in degrees
  • δ is the sun declination in degrees
把时间冻结 2024-07-22 13:21:15

如果你想与 NOAA 匹配,你必须查阅 Jean Meeus 的天文算法(主要是第 15 章)。 而且很复杂! 马丁·贝克特是对的,你必须定义日落。 通常,这是太阳上肢的明显升起或落下,这使得您的“标准”海拔高度为 -5/6 度(不是零)。 而且你无法直接以 NOAA 的精度计算日出或日落。 您必须为相关日期的视赤经和赤纬创建一组控制方程,然后对一段时间内的视赤经和赤纬进行插值,以找到标准高度下准确的上升和落下时间。

希望这可以帮助。 当我遇到同样的事情时,我花了大约一个月的时间来消化AA并重写我们所有的太阳能代码,并且仍然花了一年多的时间来整理我的代码出现问题的一些极端情况。 所以需要一些时间来弄清楚。 我不知道该算法的任何公共代码示例,目前也没有任何可分享的,但如果可以的话,我很乐意帮助您解决一些令人头痛的问题。

If you want to match NOAA, you'll have to consult Jean Meeus' Astronomical Algorithms (mostly Chapter 15). And it's complicated! Martin Beckett is correct, you have to define the sunset. Typically this is the apparent rise or set of upper limb of the sun, which makes your "standard" altitide -5/6 degrees (not zero). And you can't calculate the sunrise or sunset directly with NOAA's accuracy. You'll have to create a governing set of equations for apparent right ascension and declination for the day in question and then interpolate the apparent right ascension and declination over time to find the exact rising and setting times at the standard altitude.

Hope this helps. I spent about a month digesting AA and re-writing all our solar code when I came across the same thing, and it still took over a year to sort out some of the corner cases where my code broke. So it will take some time to figure out. I'm not aware of any public code examples of this algorithm and don't have any to share at this moment, but I'm happy to help you through some headaches if I can.

谁把谁当真 2024-07-22 13:21:15

为了确保 5 分钟范围内的准确性,您必须考虑“哪个”日落
您想要太阳底部触及地平线的时间还是太阳顶部经过地平线以下的时间?

太阳穿过地平线需要 2 分钟。
低于 1 分钟水平时,您还需要考虑大气折射。

For accuracy in the 5min range you have to consider 'which' sunset.
Do you want the time the bottom of the sun touches the horizon or the time the top of the sun passes below the horizon?

It takes 2mins for the sun to cross the horizon.
Below the 1min level you also need to take into account atmospheric refraction.

还不是爱你 2024-07-22 13:21:15

日出/日落的定义可能有所不同。 例如,在 ephem 中,“上升和下降被定义为当身体上肢接触地平线(即当身体的 alt 加半径等于 0 时)" [PyEphem 快速参考]

#!/usr/bin/env python
import datetime
import ephem # to install, run `pip install pyephem`

o = ephem.Observer()
o.lat, o.long, o.date = '34:3', '-118:15', datetime.datetime.utcnow()
sun = ephem.Sun(o)
print "Los Angeles"
print "sunrise:", o.next_rising(sun), "UTC"
print "sunset:",o.next_setting(sun), "UTC"

输出

Los Angeles, CA
sunrise: 2010/3/30 13:42:43 UTC
sunset: 2010/3/30 02:11:50 UTC

如果它是开源库,那么您可以修复它,而不是创建一个带有新错误的新库。

Definitions of what constitutes sunrise/sunset can vary. For example, in ephem "rising and setting are defined as the moments when the upper limb of the body touches the horizon (that is, when the body’s alt plus radius equals zero)" [PyEphem Quick Reference].

#!/usr/bin/env python
import datetime
import ephem # to install, run `pip install pyephem`

o = ephem.Observer()
o.lat, o.long, o.date = '34:3', '-118:15', datetime.datetime.utcnow()
sun = ephem.Sun(o)
print "Los Angeles"
print "sunrise:", o.next_rising(sun), "UTC"
print "sunset:",o.next_setting(sun), "UTC"

Output

Los Angeles, CA
sunrise: 2010/3/30 13:42:43 UTC
sunset: 2010/3/30 02:11:50 UTC

If it is open-source library then you could fix it instead of creating a new one with new bugs.

七色彩虹 2024-07-22 13:21:15

看看这本书:
“用计算器进行实用天文学(平装本)”作者:Peter Duffett-Smith。
虽然很旧了,但仍在印刷中......
链接

Have a look at this book:
"Practical Astronomy with your Calculator (Paperback)" by Peter Duffett-Smith.
It is quite old but still in print...
link

空心空情空意 2024-07-22 13:21:15

我在 Ruby 中为时间方程写了这个。

include Math

# degrees to radians = PI/180
to_r = PI/180.0

#radians to degrees = 180/PI
to_d = 180.0/PI

puts "Day, Declination, EofT"

# test a celestial year worth of values.
for jday in 1..366

  et = -7.633 * sin(jday * (2 * PI)/365.24) + 9.65 * sin((jday - 78) * 180/92 * to_r)
  a_sin = sin(23.433 * to_r) * sin((2 * PI/366) * (jday - 81))
  declination = asin(a_sin) * to_d
  puts "#{jday}, #{declination}, #{et}"

end

然后对于上面的等式:

# center disk and refraction factor have been considered.
cos_omega = sin(-0.83 * to_r) - tan(latitude * to_r) * tan(declination * to_r)
semi_diurnal_arc = acos(cos_omega)

有一个完整的网站致力于此,位于 http://www.analemma.com/

  • 这些计算的关键是好的库,比如上面的 python 库。
  • 还使用日期和时间类。 我会在 ruby​​forge 上查找诸如 ephem 之类的东西。

In Ruby I wrote this for equation of time.

include Math

# degrees to radians = PI/180
to_r = PI/180.0

#radians to degrees = 180/PI
to_d = 180.0/PI

puts "Day, Declination, EofT"

# test a celestial year worth of values.
for jday in 1..366

  et = -7.633 * sin(jday * (2 * PI)/365.24) + 9.65 * sin((jday - 78) * 180/92 * to_r)
  a_sin = sin(23.433 * to_r) * sin((2 * PI/366) * (jday - 81))
  declination = asin(a_sin) * to_d
  puts "#{jday}, #{declination}, #{et}"

end

Then for the above equation:

# center disk and refraction factor have been considered.
cos_omega = sin(-0.83 * to_r) - tan(latitude * to_r) * tan(declination * to_r)
semi_diurnal_arc = acos(cos_omega)

There is a whole website devoted to this at http://www.analemma.com/

  • The key to these calculations are good libraries like the one for python above.
  • Also usage of Date and Time classes. I would look on rubyforge for something like ephem.
要走就滚别墨迹 2024-07-22 13:21:15

您可能想查看有关计算太阳位置的早期条目。 具体来说,我指出的 Solpos 程序支持日出/日落。

You might want to look at an earlier entry on calculating the position of the sun. Specifically, the Solpos program that I pointed to has support for sunrise/sunset.

在巴黎塔顶看东京樱花 2024-07-22 13:21:15

我确实在这个NOAA页面的技术定义下看到了一些有趣的东西和计算细节标题,但我相信您已经阅读过。

SO问题的答案“太阳给定的一天中的时间,以及纬度/经度”,上面的内容实际上可能就是您所需要的。

作为旁注(它不会直接回答您的问题),您是否有理由无法提取 NOAA 数据并将其用作查找表而不是计算它? 如今,存储往往相对便宜。

I did see some interesting things on this NOAA page under the Technical Definitions and Computational Details heading, but I'm sure you've read that already.

The answer to the SO question "Position of the sun given time of day, and lat/long" and the above may actually be all you need.

As a side note (it doesn't answer your question directly), is there a reason you can't pull the NOAA data and use it as a lookup table instead of calculating it? Storage tends to be relatively cheap these days.

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