Computing lunar / lunisolar holidays in python

Are there any calendar nuts here? I was looking for information on how to calculate the holidays of the current year, which occur irregularly in the Gregorian calendar. This usually happens because the holiday is based on an earlier lunar calendar.

I was looking for googled ad nauseum and made some progress, but could not finish. If anyone has a sample code in a modern language that describes their calculation, I would be very grateful. I would prefer python or one of the C * languages.

My progress:

Complete:

  • Easter: can be found with python-dateutil .
  • Hanukkah and other Hebrew calendar holidays can be found using holiday.py with python date_util * s *.

Close

  • Ramadan: date_utils has the Islamic calendar function in the module, which I tried and get mostly correct, but not quite accurate results. (He wants to convert everything to dates and from Julian dates, I'm not sure why).

import calendar_util as cu # from date utils; no jokes from .br # # year = int(sys.argv 1 ) or datetime.now().year tj = cu.gregorian_to_jd(year, 1, 1) # this year in julian ti = cu.jd_to_islamic(tj) # this year in islamic cal rj = cu.islamic_to_jd(ti[0], 9, 1) # first day of ramadan in julian # print cu.jd_to_gregorian(rj) # first day of ramadan in greg # output: (2011, 8, 1) # correct 

I get disposable results in 2014, 2016, as confirmed by this site , although it mentions “North American observations” a little vague for my taste. Pointers would be needed to increase accuracy, for example, if Jan 1 falls on the annual cut-off date. Islamic years are shorter and therefore arrive earlier every year.

Nada:

  • Chinese New Year: I did not find anything other than this discussion , where the answer is not revealed.

As a loan, I found a link to this book for $ 30, but I probably wouldn’t have paid and earned so much for a few lines of code. In the Amazon discussion, it mentions that all procedures are on the Emacs calendar. However, I have not even installed Emacs, so if this is the only code available, we hope someone can help me dig it out and simplify it to give me Ramadan / Chinese NY this year.

Not sure if this is useful here, but the events of the sun and moon are available through pyephem , which I already use. Perhaps it can also be useful.

+7
source share
1 answer

Although I do not have the code for you, I can provide information that may give you some progress.

Firstly, Julian Dana makes sense as a basis for calculating lunar and lunisolar dates, because it extinguishes in seconds the SI measured on the geoid. Thus, formulas for predicting the number of SI seconds between these events can be easily correlated. http://en.wikipedia.org/wiki/Julian_day

Lunisolar holidays and the planning of the Jewish calendar as a whole depend on the ratio of the phase of the moon to the sunny weekday. In the Jewish and Islamic calendar, the day begins at sunset. Therefore, if the moon reaches 100% phase near sunset, this can affect when the holidays take place and how the calendar is planned in the future. But what time is sunset? This depends not only on longitude, but also on the breadth of observation. Therefore, you should plan lunisolar calendars and holidays from a specific location on the geoid. http://en.wikipedia.org/wiki/Jewish_calendar#Principles

These factors led to the use of simplified church systems, of which there are several in widespread use in the world, for "calculating" the date of Easter, used instead of direct astronomical observation. http://en.wikipedia.org/wiki/Computus

Thus, the requirements of the traditional Islamic calendar, defined in terms of astronomical observations, including sunset, should be tied to a specific place on geoids if you intend to predict vacation dates and time intervals in SI seconds for an indefinite period of the past or future. This may be the reason for the comments about "North American observations" and the errors of future vacation dates that you spoke of; if the observation of the moon phase and sunny day occurs in North America, and not in Mecca, the calendar will be planned differently.

One of the inevitable and unpredictable factors in predicting any astronomical ephemera and, consequently, lunar or lunar salt events of the calendar, is the change in the Earth's rotation in time. There is a simple formula for evaluating this change, but the actual one is measured using signals from extremely distant celestial objects. http://en.wikipedia.org/wiki/Leap_second Because of this uncertainty and the sensitivity of some calendars to the correlation between the moon phase and the solar ephemeris, there is always a horizon (distant?) for these calendars past which the sequence of dates is unrecognizable.

PyEphem looks very cool, and I'll check it out myself. If its built-in logic does not meet your needs, you have been developing for quite some time how to infinitely predict celestial events in the future. Here's a taste: http://en.wikipedia.org/wiki/Precession_of_the_equinoxes#Values

Again, I do not have a special code for you, but I hope that this information does not repeat what you already know and is useful to you.

+4
source

All Articles