The Astronomical Applications Department frequently receives requests for the formulas or algorithms used to compute times of sunrise, sunset, twilight, moonrise, and moonset. Unfortunately there is no single formula that can be used to accurately predict times of these phenomena over an acceptably wide range of dates and places. The good news, though, is that algorithms to compute times of solar and lunar phenomena have been published in many places and are readily available. Below are a few sources for this information. The U.S. Navy neither endorses nor recommends any product or vendor.
- The authoritative source describing the methods used to compute astronomical phenomena in The Astronomical Almanac is the Explanatory Supplement to the Astronomical Almanac. Algorithms for computing times of rise, set, and transit are given in Chapter 9. This book is written at the intermediate to advanced level.
- A general source of algorithms for performing a wide variety of celestial calculations is Astronomical Algorithms by Jean Meeus. This book can be utilized by technical people who are not necessarily specialists in astronomy, and contains many worked examples which are invaluable for checking your own calculations or computer code. The computation of times of rise, set, and transit is covered in Chapter 14. This book also contains algorithms for low-precision ephemerides of major celestial bodies.
- Over the years, a series of articles discussing the
computation of times of rise and set was published in Sky & Telescope magazine. These articles contain printed
listings of simple BASIC programs employing the algorithms discussed in the articles.
All of the articles were written by Roger W. Sinnott:
BASIC is quite readable, thus facilitating the conversion of the code to other computer languages. Better still, the BASIC source code given in the first two articles is available for download from Sky & Telescope's Web site. The programs are SUNUP.BAS and MOONUP.BAS.
Sky & Telescope, July 1989, pp. 78-80, "Ups and Downs of the Moon".
Sky & Telescope, August 1994, pp. 84-85, "Sunrise and Sunset: A Challenge"
Sky & Telescope, March 1995, pp. 84-86, "Sunrise/Sunset Challenge: The Winners"
- A simple, compact algorithm for calculating times of sunrise and sunset, valid from 1980-2050, was published in 1996 by B. D. Yallop of H.M. Nautical Almanac Office (UK). The algorithm was published as NAO Technical Note No. 70. For information on availability, send e-mail to hmnao@ukho.gov.uk
- Accurate, easy-to-implement ephemerides of the Sun, Moon,
and major planets can be found in:
Both of these documents are published by Willmann-Bell, Inc.. They contain FORTRAN source code listings with an option to get the code and data on disk.
Chapront-Touze and Chapront (1991). Lunar Tables and Programs from 4000 BC to AD 8000, and
Bretagnon and Simon (1986). Planetary Programs and Tables from -4000 to +2800.