Moon
Meeus, Astronomical Algorithms · checked against USNO, Skyfield and JPL Horizons
What it is
The moon goes around the Earth about every 29.5 days, lit by the sun from a different angle each night. Illumination is the fraction of its face that’s lit, and the phase names where it is in the cycle. It’s close enough that where you stand shifts where you see it, so its rise and set need a correction the sun doesn’t. It always keeps the same face toward us, but not exactly: it rocks a few degrees each way, its libration, so over a month we see about 59% of it, and its axis leans up to about 25° from the sky’s north.
- It rises about 50 minutes later each day, so about once a month a day has no moonrise, and another has no moonset.
- Waxing is growing, waning is shrinking. The lit side is on the right while it waxes, seen from the northern hemisphere.
- It builds on astronomical time, like the sun.
Operations
| Operation | Gives |
|---|---|
events |
Rise, set and transit in a windowIn: latitudeInDegrees, longitudeInDegrees, startUtc, windowInHoursOut: riseUtc, setUtc, transitUtc, isAlwaysUp, isAlwaysDown |
phase |
How much is lit, how far it is from the sun, and the phase's name, at an instantIn: instantUtcOut: illuminationFraction, phaseAngleInDegrees, elongationInDegrees, phaseName |
nextPhases |
The next of each of the four main phases after an instantIn: startUtcOut: newMoonUtc, firstQuarterUtc, fullMoonUtc, lastQuarterUtc |
position |
The moon's azimuth and altitude from a placeIn: latitudeInDegrees, longitudeInDegrees, instantUtcOut: azimuthInDegrees, altitudeInDegrees |
orientation |
Which way the moon's axis points and which part of its face turns toward the placeIn: latitudeInDegrees, longitudeInDegrees, instantUtcOut: librationLongitudeInDegrees, librationLatitudeInDegrees, axisPositionAngleInDegrees |
Fields
| Field | Meaning |
|---|---|
latitudeInDegrees | −90 to 90, north positive |
longitudeInDegrees | −180 to 180, east positive |
startUtc | The window's start, ISO 8601 with Z. For nextPhases, midnight UTC. |
windowInHours | The window's length: 24 in every case here. More than 0 and at most 48. |
instantUtc | An instant, ISO 8601 with Z, read as UT1 |
riseUtc | The first moment in the window the moon's top edge reaches the horizon, seen from the place (with parallax) and with 34′ of refraction. null if it doesn't happen in the window. USNO gives the minute. |
setUtc | As rise, going down |
transitUtc | The first moment in the window the moon crosses the meridian. Left out when it stays down all window. |
isAlwaysUp | true when the moon is up for the whole window |
isAlwaysDown | true when it's down for the whole window |
illuminationFraction | 0 to 1, the part of the face that's lit, seen from the Earth's centre |
phaseAngleInDegrees | The Sun–Moon–Earth angle: 0 at full, 180 at new |
elongationInDegrees | The moon's apparent ecliptic longitude minus the sun's, seen from the Earth's centre: 0 up to 360, 0 at new, 90 at first quarter, 180 at full. Under 180 the moon is waxing. Left out within 0.5° of new moon, where it wraps. |
phaseName | From the moon's elongation, its ecliptic longitude minus the sun's, in eight 45° bands each centred on its phase: new within 22.5° of 0, then waxingCrescent, firstQuarter (centred on 90), waxingGibbous, full (180), waningGibbous, lastQuarter (270) and waningCrescent. Instants within 0.5° of a band's edge aren't cases. |
newMoonUtc | The first new moon from the start |
firstQuarterUtc | The first first quarter from the start |
fullMoonUtc | The first full moon from the start |
lastQuarterUtc | The first last quarter from the start |
azimuthInDegrees | 0 up to 360, clockwise from north, seen from the place. Left out near the zenith. |
altitudeInDegrees | −90 to 90, of the moon's centre, seen from the place (with parallax, up to about 1° lower than from the Earth's centre), geometric: no refraction |
librationLongitudeInDegrees | The selenographic longitude of the disc's centre seen from the place, in the moon's mean-Earth frame: −180 up to 180, east positive (toward Mare Crisium), within about 8° of 0. Total libration: optical, physical and the place's own (diurnal). |
librationLatitudeInDegrees | As librationLongitudeInDegrees, the latitude: north positive, within about 7° of 0 |
axisPositionAngleInDegrees | The position angle of the moon's north pole on the sky, seen from the place: from the direction of the celestial north pole (true equator of date) toward east, −180 up to 180, within about 25° of 0 |
Edge cases
| Case | What it tests |
|---|---|
usno-events-tonga-local-dayevents | A window from local midnight across the date line. |
usno-events-alert-2026-03-21events | The moon stays up all day. |
usno-events-alert-2026-08-21events | The moon stays down all day. |
usno-events-vancouver-2026-09-21events | No moonrise in this UTC day: riseUtc is null, not the next day's. |
usno-next-phases-2026-03-16nextPhases | The four phases come in order from the start, crossing into April. |
skyfield-phase-at-full-moon-2026-03-03phase | Exactly at full moon. |
skyfield-phase-at-new-moon-2026-03-19phase | Exactly at new moon: almost nothing lit. |
skyfield-phase-at-first-quarter-2026-03-25phase | Exactly at first quarter: firstQuarter, not a neighbour. |
skyfield-position-lowposition | Just risen: seen from the place, almost 1° lower than from the Earth's centre. |
skyfield-position-below-horizonposition | Below the horizon: a negative altitude, not an error. |
skyfield-position-always-upposition | Up all day at Alert, low in the sky. |
skyfield-position-south-poleposition | A kilometre from the South Pole: azimuth is still clockwise from true north. |
horizons-orientation-loworientation | Just risen: the place sees the moon from almost 1° away from where the Earth's centre does, so the libration moves by almost 1°. |
invalid-phase-year-10000phase | Instants run from year −9999 to 9999: outOfRange, not a crash. |
Their inputs and expected values are in vectors.json; search for the case's id.
For agents
Follow Meeus, Astronomical Algorithms: chapter 47 for the moon’s position, 48 for illumination and 49 for the phase dates, or search elongation for them. For rise and set, correct for the moon’s parallax and semi-diameter: its altitude at rise changes with its distance. Search the window from startUtc, never a calendar day, and return the first of each event. Return the elongation, the moon’s apparent ecliptic longitude minus the sun’s, and name the phase from it in 45° bands centred on each phase. For position, give azimuth and altitude seen from the place, not the Earth’s centre: correct for parallax, up to about 1°, and don’t add refraction. For orientation, follow chapter 53 for the optical and physical libration and the position angle of the axis, but from the moon’s place seen from the place, so the libration includes the place’s own, up to about 1°. Pass every case in vectors.json within its tolerance.
To check by hand against the book, 2nd edition (1998): example 47.a (p. 342) for position, 48.a (p. 347) for illumination, and 49.a and 49.b (p. 353) for phase dates. All four work in dynamical time, so subtract ΔT before comparing with a UTC case. The 1st edition (1991) numbers these chapters 45 to 47 and prints different values for the moon.
Test data
vectors.json holds 768 cases, published 2026-11-06. Earth model: WGS84 latitude and longitude; UT1 read from the UTC given. How to read it: Test data format.
| Operation | Cases |
|---|---|
events |
582580 published · 4 edge · 120 polar · 2 invalid |
phase |
6967 reference · 8 edge · 2 invalid |
nextPhases |
2524 published · 1 invalid |
position |
4644 reference · 4 edge · 2 invalid |
orientation |
4644 reference · 4 edge · 2 invalid |
Tags say where each value came from: what they mean.
| Field | Tolerance |
|---|---|
riseUtc | ± 120 s |
setUtc | ± 120 s |
transitUtc | ± 120 s |
newMoonUtc | ± 120 s |
firstQuarterUtc | ± 120 s |
fullMoonUtc | ± 120 s |
lastQuarterUtc | ± 120 s |
illuminationFraction | ± 0.01 |
phaseAngleInDegrees | ± 0.5 |
elongationInDegrees | ± 0.01 |
azimuthInDegrees | ± 0.01 |
altitudeInDegrees | ± 0.01 |
librationLongitudeInDegrees | ± 0.05 |
librationLatitudeInDegrees | ± 0.05 |
axisPositionAngleInDegrees | ± 0.05 |
Every other field is compared exactly.
Implementations
| Implementation | Status |
|---|---|
| gshaw/algorithms-swiftSwift | Passes |
| gshaw/algorithms-typescriptTypeScript | Passes |
Each implementation's CI grades it against this page's test data on every push, and again when the data changes. The code isn't public yet. See how implementations work.
Source
| Rise, set and transit | Astronomical Applications API 4.0.1: Complete Sun and Moon Data for One DayUS Naval Observatory. Checked against Skyfield's find_risings and find_settings. Every request and response is in /moon/sources/usno.jsonl · Public domain |
| Phase dates | Astronomical Applications API 4.0.1: Phases of the MoonUS Naval Observatory · Public domain |
| Illumination, phase angle, name and position | Skyfield 1.55 on JPL's DE421Brandon Rhodes. Illumination checked against USNO's percentage lit at 12:00 UT; position against USNO's celestial navigation data. Every call is in /moon/sources/skyfield.txt · MIT |
| Position check | Astronomical Applications API 4.0.1: Celestial Navigation Data, Hc and ZnUS Naval Observatory. Its Hc is from the Earth's centre, so Skyfield's altitude is checked against Hc minus the parallax in altitude it gives. USNO lists the moon only when it's up · Public domain |
| Orientation | Horizons On-Line Ephemeris System, observer table quantities 14 and 17, on DE441JPL Solar System Dynamics. The sub-observer longitude and latitude in the MOON_ME frame, east positive, and the north pole's position angle, seen from the place. Every request and response is in /moon/sources/horizons.jsonl · Public domain |
| Method | Astronomical Algorithms, 2nd edition, 1998, chapters 15, 47, 48, 49 and 53Jean Meeus. The method to follow; no value in the file comes from it |