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.

Eight moons from new to waning crescent, each with its name and how much of it is lit, over a 29.5-day timeline
  • 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

OperationGives
events Rise, set and transit in a windowIn: latitudeInDegrees, longitudeInDegrees, startUtc, windowInHours
Out: 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: instantUtc
Out: illuminationFraction, phaseAngleInDegrees, elongationInDegrees, phaseName
nextPhases The next of each of the four main phases after an instantIn: startUtc
Out: newMoonUtc, firstQuarterUtc, fullMoonUtc, lastQuarterUtc
position The moon's azimuth and altitude from a placeIn: latitudeInDegrees, longitudeInDegrees, instantUtc
Out: azimuthInDegrees, altitudeInDegrees
orientation Which way the moon's axis points and which part of its face turns toward the placeIn: latitudeInDegrees, longitudeInDegrees, instantUtc
Out: librationLongitudeInDegrees, librationLatitudeInDegrees, axisPositionAngleInDegrees

Fields

FieldMeaning
latitudeInDegrees−90 to 90, north positive
longitudeInDegrees−180 to 180, east positive
startUtcThe window's start, ISO 8601 with Z. For nextPhases, midnight UTC.
windowInHoursThe window's length: 24 in every case here. More than 0 and at most 48.
instantUtcAn instant, ISO 8601 with Z, read as UT1
riseUtcThe 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.
setUtcAs rise, going down
transitUtcThe first moment in the window the moon crosses the meridian. Left out when it stays down all window.
isAlwaysUptrue when the moon is up for the whole window
isAlwaysDowntrue when it's down for the whole window
illuminationFraction0 to 1, the part of the face that's lit, seen from the Earth's centre
phaseAngleInDegreesThe Sun–Moon–Earth angle: 0 at full, 180 at new
elongationInDegreesThe 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.
phaseNameFrom 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.
newMoonUtcThe first new moon from the start
firstQuarterUtcThe first first quarter from the start
fullMoonUtcThe first full moon from the start
lastQuarterUtcThe first last quarter from the start
azimuthInDegrees0 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
librationLongitudeInDegreesThe 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).
librationLatitudeInDegreesAs librationLongitudeInDegrees, the latitude: north positive, within about 7° of 0
axisPositionAngleInDegreesThe 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

CaseWhat it tests
usno-events-tonga-local-dayeventsA window from local midnight across the date line.
usno-events-alert-2026-03-21eventsThe moon stays up all day.
usno-events-alert-2026-08-21eventsThe moon stays down all day.
usno-events-vancouver-2026-09-21eventsNo moonrise in this UTC day: riseUtc is null, not the next day's.
usno-next-phases-2026-03-16nextPhasesThe four phases come in order from the start, crossing into April.
skyfield-phase-at-full-moon-2026-03-03phaseExactly at full moon.
skyfield-phase-at-new-moon-2026-03-19phaseExactly at new moon: almost nothing lit.
skyfield-phase-at-first-quarter-2026-03-25phaseExactly at first quarter: firstQuarter, not a neighbour.
skyfield-position-lowpositionJust risen: seen from the place, almost 1° lower than from the Earth's centre.
skyfield-position-below-horizonpositionBelow the horizon: a negative altitude, not an error.
skyfield-position-always-uppositionUp all day at Alert, low in the sky.
skyfield-position-south-polepositionA kilometre from the South Pole: azimuth is still clockwise from true north.
horizons-orientation-loworientationJust 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-10000phaseInstants 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.

OperationCases
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.

FieldTolerance
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

ImplementationStatus
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 transitAstronomical 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 datesAstronomical Applications API 4.0.1: Phases of the MoonUS Naval Observatory · Public domain
Illumination, phase angle, name and positionSkyfield 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 checkAstronomical 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
OrientationHorizons 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
MethodAstronomical Algorithms, 2nd edition, 1998, chapters 15, 47, 48, 49 and 53Jean Meeus. The method to follow; no value in the file comes from it