给定纬度和经度,我如何判断现在是否是白天?
我正在编写一个 Python 程序,需要在仅给出当前 UTC 时间和目标纬度和经度的情况下确定是否是日出后。我经常看到应用程序做这种事情,但我不知道它是如何完成的。有什么想法吗?
I'm writing a Python program that needs to determine whether it's post-sunrise or not, given only the current UTC time and the target latitude and longitude. I see apps do this sort of thing all the time, but I have no idea how it's done. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
下面是某人用 Python 实现的日出/日落计算: http://michelanders.blogspot.com/2010/12/calating-sunrise-and-sunset-in-python.html
Here's someone's implementation of sunrise/sunset calculation in Python: http://michelanders.blogspot.com/2010/12/calulating-sunrise-and-sunset-in-python.html
该算法的完整布局位于此处,
实际上不需要添加太多内容。引用的文档中的 10 点将其分解为简单的、可重现的步骤,这些步骤实际上可以用任何语言实现。
A complete layout of the algorithm is here
Not a lot to add really. The 10 points in the document quoted break it down into simple to reproduce steps that can be implemented in any language really.
只是做了一个快速的谷歌搜索,我发现了这个。 NOAA 中的计算日出/日落和太阳位置计算器基于 Jean Meeus 的《天文算法》中的方程。经验证,对于纬度 +/- 72° 之间的位置,日出和日落结果的精确度为一分钟之内,而在这些纬度之外的位置则为 10 分钟之内。
可以从该页面以及此处找到计算详情的详细说明。
Just doing a quick google search I found this. The calculations in the NOAA Sunrise/Sunset and Solar Position Calculators are based on equations from Astronomical Algorithms, by Jean Meeus. The sunrise and sunset results have been verified to be accurate to within a minute for locations between +/- 72° latitude, and within 10 minutes outside of those latitudes.
A detailed explanation of the calculation details can be found from that page and also here.
您需要一些有效™的东西吗?使用高级语言。而且你知道它永远有效。你怎么能相信122行先进的天体物理学呢?你不能。但您始终可以信任 PHP。
You need something that just works™? Use the superior language. And you know it'll always work. How can you trust 122 lines of advanced astrophysics? You can't. But you can always trust PHP.