Lunar4: A Lunar Distance Navigation Program


The method of lunar distances is a way to determine Greenwich time from a sextant measurement of the distance (angular separation) between the Moon and another celestial body. It was an important part of marine navigation in the late 18th and early 19th centuries. Due to the tedious mathematics, limited accuracy, falling chronometer prices, and increasing availability of time signals in ports, the "lunar" became almost extinct by the late 19th century. However, a few enthusiasts continue to practice lunars today.

Lunar4 is a free Windows program for the analysis of historic or modern lunar distance observations. It solves the classic lunar, in which the lunar distance and the altitudes of both bodies are observed (practically simultaneously) at an unknown time and position. If position is already known, Lunar4 solves for time only, given either a lunar distance or the altitude of one body. It also performs the functions of:

Positions and velocities of the solar system bodies are obtained from a Jet Propulsion Laboratory planetary ephemeris. None is supplied with the installer. The user must download an ephemeris in ASCII format from JPL, then convert it to binary with tools included in Lunar4. An internal star catalog (a subset of the Hipparcos catalog, second reduction) contains all stars down to third magnitude. There's also a manual entry screen for stars not in the catalog, or the user can modify the catalog since it's a pair of text files.

Bodies are reduced to apparent place with the vector method described in The Astronomical Almanac, including the displacement and velocity of the topocenter with respect to the geocenter. Polar motion and deflection of the vertical are included if the user supplies the parameters. Precession and nutation are applied with the IAU 2006/00A model.

The bug that made it impossible to run the previous version under Windows 8 has been eliminated in this release. Although it has not yet received all the tests on the "test results" page, I'm confident there will be no problems.

Lunar4 is copyright © 2018 by Paul S. Hirose. Nonprofit redistribution of the program is permissible if you give me credit.

Bugs and Updates


Lunar4 was created mainly for my use on a Windows 8.1 machine. I do not guarantee successful installation in other Windows versions.

The current version is 4.3. To install, download the .zip file and extract its files. By default, when you do "Extract all" a new directory "Lunar4_3" is created in the directory that contains the .zip. To uninstall the program delete its directory.

A leap second table is included in the installation. Since the program requires that you navigate to this file and open it manually, it may be moved to any place in your system. If you have more than one program which uses my leap second table, it's best if they share the same one so there's only one file to update when a leap second occurs. This update is easy with any text editor.

Shortcuts to your desktop and start menu, if you want them, must added by hand. In exchange for that inconvenience you enjoy better security since system administrator privileges are not necessary to install the software.

You need a JPL solar system ephemeris to run the program. (Even if you're interested only in star positions, the corrections for parallax and aberration require Earth position and velocity.) Go to the JPL Planetary and Lunar Ephemerides site and download an ASCII ephemeris and the header file (which is in the same directory as the ephemeris). Descriptions of the ephemerides are on the Web page. The files may be saved in any convenient place. Since this updated release relies on my SofaJpl 2.0 astronomy DLL, its binary JPL ephemerides are not compatible with my previous software.

Launch Lunar4. Click the Body #1 button. (It's the only button not disabled.) Click JPL Tools and convert the ASCII ephemeris to binary. The procedure is explained in detail in the Lunar4 operating instructions (see link below), but you can probably figure it out by looking at the screen. (The OK button is disabled until you select the ephemeris and header files, and enter a name for the output file.) When you click OK and the JPL Tools dialog box disappears, the conversion to binary is complete.

First Run of Program

  1. Assuming you just completed the last step above, you are in the Body #1 dialog box. Click Open Ephemeris, open the new binary ephemeris.
  2. Choose a body above the horizon. More precisely, choose a body which will be above the horizon at the time and place you enter below, then OK out of the dialog box. (It's not absolutely necessary that the body be above the horizon, but the refraction model will throw an exception if it's far below the horizon.)
  3. Click the Body #2 button, choose a different body above the horizon, and OK out of the dialog box.
  4. Click the Topocenter button and enter a location.
  5. Click the Time button, enter a time, OK out of the dialog. The default time is the current time.
  6. Click OK in the main window. (It is not necessary to enter any data.) A results window will appear with positions of the bodies. The limbs will be the ones selected in the main window.

Further Information

Operating Instructions
A description of the main window, and the body select, JPL tools, topocenter, time, and manual star entry dialogs.
Test Results
Synthetic lunar distance observations created with the JPL HORIZONS and USNO MICA programs are solved, as well as examples from writings of 19th century authority William Chauvenet. Results are satisfactory when compared with the expected values.


The core algorithm was invented independently by me, though I don't claim to be first. It iteratively determines time and position by solving a set of linear equations. There are three observables in the problem: one separation angle and two altitudes. There are three unknowns: time, latitude, and longitude. You supply the observables and estimates of the unknowns. From the estimates Lunar4 predicts the angles that ought be observed at that time and place. In addition, it evaluates how they respond to small changes in each unknown, i.e., computes partial derivatives. This yields nine coefficients in a set of three linear equations in three unknowns. Solving the equations yields adjustments to the unknowns. After applying them, the predicted angles equal to the observed angles. In reality, the assumption that each angle responds linearly to an adjustment in time, latitude, and longitude is not strictly true. Therefore, the process must be repeated until there's no significant change in the solution, to the accuracy requested by the user

In other words, Lunar4 iteratively seeks the time and place that cause its predicted altitudes and lunar distance to equal the observed angles. When that occurs, the parallax, refraction, and all other factors that affect the observations have automatically been applied, as rigorously as they can be computed. The disadvantage of this method is the quantity of computation, which is impractical without electronic assistance.

JPL Planetary and Lunar Ephemerides
All data on the positions of the Sun, Moon, and planets come from the JPL ephemeris that you have opened. Even if both bodies are stars, Earth position and velocity are needed to compute parallax and aberration.
SOFA library
The International Astronomical Union's SOFA service maintains a publicly accessible and authoritative set of algorithms and procedures that implement standard models used in fundamental astronomy. Software routines from the IAU SOFA Collection (copyright © International Astronomical Union Standards of Fundamental Astronomy) are used in Lunar4.
Strasbourg Astronomical Data Center (CDS)
CDS is the source of star designations and astrometric data in Lunar4.
Hipparcos, the New Reduction (van Leeuwen, 2007)
This is the source of the Lunar4 star catalog data. It's a re-reduction of the astrometric data collected by the Hipparcos space-based astrometry mission in the 1990s.
VOTable Version 1.2
Lunar4's star name table and star catalog use the VOTable XML format.
SofaJpl 2.0 astronomy DLL for Windows .NET Framework
The JPL and SOFA routines are not actually in the Lunar4 executable. It relies on the SofaJpl 2.0, an "astronomy toolbox" DLL.
NIST Index of Refraction of Air formulas
Jack A. Stone and Jay H. Zimmerman, Index of Refraction of Air, National Institute of Standards and Technology Web site. To compute refractive index, Lunar4 completely implements the IAPWS and Ciddor formulas described on the NIST page.
Cassini's refraction model
Web page by astronomer Andrew T. Young describing the Cassini refraction model. Young has a high opinion of this very old model: "it is worth emphasizing that Cassini's simple model is more accurate than is needed for all astronomical purposes to at least 74° Z.D., and remains good to better than a second of arc to 81° — provided that the refractivity of air and the height of the homogeneous atmosphere are accurately evaluated for actual conditions." (They are, in Lunar4.)

Between 15° and 10° altitude I use a weighted average of Cassini and the low altitude formula in section B of The Astronomical Almanac. The latter "fades in" linearly, and takes over completely below 10°.

"A Community Devoted to the Preservation and Practice of Celestial Navigation and Other Methods of Traditional Position-Finding." It's as good a place as any to discuss lunar distances. I'm available there.

[return to my home page]

(page last modified 2018-08-26)