Swiss Ephemeris calculates the Moon's position using different methods depending on the ephemeris selected (Swiss, Moshier, or JPL). When using the compressed Swiss Ephemeris files (the default and recommended method for most users due to its balance of accuracy and speed), the following process is employed:
-
Initialization: swe_set_ephe_path() is called to specify the directory containing the ephemeris files (*.se1). If no path is set, a default path is used. This is crucial, as it initializes the library.
-
Time Conversion: The input time is given as a Julian Day number, typically in Universal Time (UT). Internally, Swiss Ephemeris often uses Ephemeris Time (ET, or TT - Terrestrial Time), which is a more uniform time scale. If the input is UT, it's converted to ET using swe_deltat(): tjd_et = tjd_ut + swe_deltat(tjd_ut).
-
File Selection: Based on the ET, the appropriate Moon file (semom*.se1) is selected. Each file covers a 600-year range. The naming scheme helps determine the correct file. (e.g., semo_00.se1 for 1 BCE to 599 CE).
-
Data Loading and Decompression: The necessary data from the chosen semom*.se1 file is loaded into memory. This data has been compressed using a proprietary algorithm. Swiss Ephemeris then decompresses this data.
-
[Redacted Person] Polynomial Evaluation: The Moon's position within the loaded 600-year segment is determined using [Redacted Person] polynomials. Coefficients for these polynomials are stored in the ephemeris file. The function swe_echeb() evaluates the [Redacted Person] polynomials at the specific time within the 600-year range. This process is highly efficient for representing complex periodic functions like planetary orbits.
-
Coordinate Transformations and Corrections: The initial position obtained is usually barycentric (relative to the solar system's center of mass) and in the ICRS reference frame (close to the J2000 equatorial system). Swiss [Redacted Person] then applies a series of transformations and corrections to convert this into a more usable geocentric (Earth-centered) ecliptic longitude, latitude, and distance:
- Barycentric to Geocentric: The Earth's position (also read from the appropriate
seplm*.se1 file using [Redacted Person] polynomials) is subtracted from the Moon's barycentric position to get a geocentric position.
- Precession: The coordinates are precessed from J2000 to the date of interest.
- Nutation: The effects of nutation (short-term oscillations in the Earth's axis) are applied.
- Aberration: Corrections for the aberration of light are included. If requested via the
iflag parameter, further corrections such as apparent geocentric position, topocentric position, and light-time are applied.
-
Speed Calculation (optional): If the iflag parameter requests it, Swiss Ephemeris calculates the Moon's speed. This is typically done by calculating the position at a slightly earlier and later time and using finite differences.
-
Return of Results: The Moon's position (longitude, latitude, distance, and optionally speed) is returned in the xx array.
Accuracy:
The Swiss Ephemeris, when used with the compressed DE431 files, provides an accuracy of better than 1 milliarcsecond compared to the original JPL DE431 ephemeris. This is well below the inherent uncertainties of the DE431 itself for most of its time range. The most significant discrepancies between DE431 and the older DE406 occur with the outer planets, particularly Pluto, for earlier dates. The Moon's position has maximum differences of <7" in TT and <2" in UT between DE431 and DE406 over the -3000 to +3000 year range.
Moshier and JPL Ephemerides: If the Moshier or full JPL ephemerides are selected (via flags in swe_set_ephe_path), the Moon's position is calculated using different algorithms specific to those ephemerides. The [Redacted Person] ephemeris uses a simplified analytical model, while the full JPL DE431 data involves direct interpolation from the extensive JPL data files.