月亮/农历阶段算法 [英] Moon / Lunar Phase Algorithm

查看:184
本文介绍了月亮/农历阶段算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道一个算法要么计算在给定日期的月相或年龄或找到日期新/满月在某一年?

Does anyone know an algorithm to either calculate the moon phase or age on a given date or find the dates for new/full moons in a given year?

谷歌搜索会告诉我的回答是在一些天文学的书,但我真的不想买一整本书的时候我只需要一个单一的页面。

Googling tells me the answer is in some Astronomy book, but I don't really want to buy a whole book when I only need a single page.

更新:

我应该有资格对谷歌搜索好一点我的发言。我没有找到解决办法,只能在工作时间某个子集(如1900年);而触发的解决方案,这将是更加昂贵的计算比我想。

I should have qualified my statement about googling a little better. I did find solutions that only worked over some subset of time (like the 1900's); and the trig based solutions that would be more computationally expensive than I'd like.

取值洛特在他的Python书籍有几种算法在某一年计算复活节,大部分都低于10行code和一些工作,在公历的所有日子。寻找满月在三月份是查找复活节的一个关键部分,所以我想应该有一个算法,不需要触发,并适用于公历起讫日期。

S Lott in his Python book has several algorithms for calculating Easter on a given year, most are less than ten lines of code and some work for all days in the Gregorian calendar. Finding the full moon in March is a key piece of finding Easter so I figured there should be an algorithm that doesn't require trig and works for all dates in the Gregorian calendar.

推荐答案

我移植了一些code到Python为此而回。我正想只是链接到它,但事实证明,它掉下来的网页在此期间,所以我不得不去灰尘其关闭,重新上传。请参见 moon.py 这从约翰·沃克的moontool 得到的。

I ported some code to Python for this a while back. I was going to just link to it, but it turns out that it fell off the web in the meantime, so I had to go dust it off and upload it again. See moon.py which is derived from John Walker's moontool.

我找不到这是一个参考什么时间跨度是准确下去,但似乎是作者为pretty的严谨。这意味着,是的,​​它不使用触发,但你会用什么赫克本作将使它计算望而却步我无法想象。 Python的函数调用开销可能比触发操作的成本更高。计算机是pretty的快速的计算。

I can't find a reference for this for what time spans it's accurate for either, but seems like the authors were pretty rigorous. Which means yes, it does use trig, but I can't imagine what the heck you would be using this for that would make it computationally prohibitive. Python function call overhead is probably more than the cost of the trig operations. Computers are pretty fast at computing.

在code使用的算法是从下列来源获得:

The algorithms used in the code are drawn from the following sources:

Meeus,吉恩。天文算法。里士满:Willmann - 贝尔,1991年国际标准书号0-943396-35-2

一个必须具备的;如果你只买一书,确保它是这一个。算法是presented数学,而不是计算机程序,但源$ C ​​$ C实现多种算法书中可以分别从出版商在任的QuickBasic,Turbo Pascal的,或C. Meeus提供了许多工作的例子有序计算这是必不可少的调试code,并经常presents几种算法,精度,速度,复杂性和长期之间不同的权衡(世纪和千年)的有效性。

A must-have; if you only buy one book, make sure it's this one. Algorithms are presented mathematically, not as computer programs, but source code implementing many of the algorithms in the book can be ordered separately from the publisher in either QuickBasic, Turbo Pascal, or C. Meeus provides many worked examples of calculations which are essential to debugging your code, and frequently presents several algorithms with different tradeoffs among accuracy, speed, complexity, and long-term (century and millennia) validity.

Duffett史密斯,彼得。实用天文学计算器。第3版。剑桥:剑桥大学preSS,1981年ISBN 0-521-28411-2

尽管在标题中注明计算器;这就是如果你有兴趣在开发软件,计算出行星的位置,轨道,日食有参考价值,等等。更多的背景信息,给出比Meeus,帮助那些尚未精通天文学学会经常混淆的术语。给定的算法是简单的,并比那些由Meeus提供不准确的,但适用于大多数的实际工作。

Despite the word Calculator in the title; this is a valuable reference if you're interested in developing software which calculates planetary positions, orbits, eclipses, and the like. More background information is given than in Meeus, which helps those not already versed in astronomy learn the often-confusing terminology. The algorithms given are simpler and less accurate than those provided by Meeus, but are suitable for most practical work.

这篇关于月亮/农历阶段算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆