skywatch algorithms

This document describes every computation skywatch performs, the worked examples it is validated against, and the accuracy you can expect. Chapter numbers refer to Jean Meeus, Astronomical Algorithms, 2nd edition (Willmann-Bell, 1998).

1. Time

Julian Day (ch. 7, eq. 7.1). For Gregorian dates with Y, M (Jan/Feb treated as months 13/14 of the previous year), A = ⌊Y/100⌋, B = 2 − A + ⌊A/4⌋:

JD = ⌊365.25 (Y + 4716)⌋ + ⌊30.6001 (M + 1)⌋ + D + B − 1524.5

Example 7.a: 1957 Oct 4.81 → JD 2436116.31 ✔.

ΔT = TT − UT uses the Espenak & Meeus (2006) piecewise polynomials, e.g. for 2005–2050 ΔT = 62.92 + 0.32217 t + 0.005589 t², t = y − 2000. All ephemerides take TT; observer-facing times are UT converted to the location's IANA zone with zoneinfo.

Sidereal time (ch. 12, eq. 12.4):

θ₀ = 280.46061837° + 360.98564736629° (JD − 2451545) + 0.000387933 T² − T³/38 710 000

Apparent sidereal time adds the equation of the equinoxes Δψ cos ε. Example 12.a: 1987 Apr 10 0h UT → 13h10m46.3668s ✔; 12.b: 19h21m UT → 128.7378734° ✔.

2. Coordinates

3. The Sun (ch. 25, low precision)

L₀ = 280.46646 + 36000.76983 T + 0.0003032 T²
M  = 357.52911 + 35999.05029 T − 0.0001537 T²
C  = (1.914602 − 0.004817 T − 0.000014 T²) sin M + (0.019993 − 0.000101 T) sin 2M + 0.000289 sin 3M
λ  = L₀ + C − 0.00569 − 0.00478 sin Ω,  ε = ε₀ + 0.00256 cos Ω

Example 25.a (1992 Oct 13.0 TD): λ = 199.90895°, α = 198.38083°, δ = −7.78507°, R = 0.99766 au — all reproduced to 1e-5° ✔. Equation of time uses Smart's series (eq. 28.3): Example 28.b gives 13m42.7s ✔.

4. The Moon

Position (ch. 47). The fundamental arguments L′, D, M, M′, F are the full polynomials. skywatch sums the 60 terms of Table 47.A (Σl, Σr) and the 30 largest terms of Table 47.B (Σb), multiplying terms in M by E = 1 − 0.002516 T (and E² for 2M), plus the additive A₁, A₂, A₃ corrections. Then λ = L′ + Σl·10⁻⁶, β = Σb·10⁻⁶, Δ = 385000.56 + Σr/1000 km, nutation is added to λ.

Example 47.a (1992 Apr 12.0 TD):

Quantity Meeus skywatch
Σl −1 127 527 −1 127 527
Σr −16 590 875 −16 590 875
Σb −3 229 126 −3 228 572 (truncated series, 2″)
apparent λ 133.167265° 133.167233°
α 134.688470° 134.688598°
δ 13.768368° 13.768908°
Δ 368 409.7 km 368 409.7 km

Illumination (ch. 48): phase angle tan i = R sin ψ / (Δ − R cos ψ) with ψ the Sun–Moon elongation, k = (1 + cos i)/2. Example 48.a: k = 0.6786 ✔. Phase names use k and waxing/waning (new < 3 %, quarter 45–55 %, full > 97 %).

Phases (ch. 49): mean phase from lunation number k, then the 25-term periodic corrections for new/full or quarter phases, the W correction for quarters, and the 14 planetary corrections A₁…A₁₄. Example 49.a: new moon of 1977 Feb → JDE 2443192.65118 ✔ (< 1 s). Converting JDE (TT) to UT subtracts ΔT.

5. Planets

Heliocentric positions use JPL's Approximate Positions of the Planets, Table 1 (Standish), valid 1800–2050: six elements a, e, I, L, ϖ, Ω plus linear rates per Julian century. For each planet:

  1. ω = ϖ − Ω, M = L − ϖ; solve Kepler's equation E − e sin E = M by Newton iteration (1e-12 rad).
  2. Orbital-plane coordinates x′ = a(cos E − e), y′ = a√(1−e²) sin E, rotate by ω, I, Ω to J2000 ecliptic.
  3. Geocentric vector = planet(t − τ) − Earth-Moon barycentre(t), iterating the light-time τ = Δ · 0.0057755 d/au.
  4. Rotate to J2000 equatorial (ε = 23.4392911°), precess to date and apply nutation.

Example 33.a (Venus 1992 Dec 20.0 TD; Meeus uses full VSOP87): α = 21h04m41.454s, δ = −18°53′16.84″, Δ = 0.910845 au. skywatch gives 21h04m42.5s, −18°53′11″, 0.91100 au — 15″ and 6″ off, comfortably within the JPL table's stated error.

Magnitudes: simplified Mallama & Hilton (2018) phase curves, V = 5 log₁₀(rΔ) + f(i), e.g. Mars −1.601 + 0.02267 i − 0.0001302 i²; Saturn includes the ring term −1.825 sin B where B is the sub-Earth latitude on the ring plane computed from Saturn's pole (α 40.589°, δ 83.537°). Apparent diameter = 2·s₀/Δ with Meeus's semidiameters at 1 au.

6. Rise, transit, set and twilight

Instead of Meeus's three-point interpolation (ch. 15), skywatch evaluates the exact geometric altitude minus the standard altitude h₀ on a 10-minute grid and refines every sign change by bisection to 1 s. This works for any object (including the fast-moving Moon) and naturally reports multiple or zero events.

Body h₀
stars, planets −0.5667°
Sun −0.8333°
Moon 0.7275 π − 0.5667° (π = horizontal parallax)
twilight −6°, −12°, −18° (Sun centre)

Transit is the zero crossing of the hour angle from negative to positive. If no crossing exists in the window the object is classified as circumpolar or never-rising from the altitude at the window's midpoint.

Example 15.a (Venus at Boston, 1988 Mar 20, using Meeus's tabulated positions with quadratic interpolation): rise 12h25m26s, transit 19h40m18s, set 2h54m40s UT — reproduced within 1 minute ✔.

Sunrise/sunset reference checks (tests, ±2 min): London 2024-06-21 and 2024-12-21 against timeanddate.com, Pune 2024-01-15 and 2024-06-21 against api.sunrise-sunset.org. Measured differences are 0–1.3 min.

7. Constellation identification

The IAU boundaries were drawn along B1875.0 meridians and parallels. Roman (1987, PASP 99, 695; CDS VI/42) tabulated them as 357 rows (RA_low, RA_high, Dec_low, constellation) sorted by descending Dec_low. A position is precessed to B1875.0 (JD 2405889.2586); the answer is the first row with Dec ≥ Dec_low and RA_low ≤ RA < RA_high. All eight test points from Roman's paper pass.

8. Planning: the dark window and target score

Night = local noon to next local noon. Dark window = astronomical night (Sun < −18°) intersected with "Moon below its rise/set altitude", sampled every 5 minutes. If it is empty, skywatch falls back to astronomical night with the Moon up, then nautical twilight, civil twilight and finally sunset→sunrise.

Every candidate (160 deep-sky objects, the 1st-magnitude named stars and the planets) is evaluated every 15 minutes across the window; its best sample gives the score

score = 100 · sin(alt) · (0.55·B + 0.45·S) · (1 − 0.8·P)     (0 if alt < 15°)

sin(alt) approximates the reduction in airmass (extinction and seeing) toward the horizon.

Worked example — M31 from Pune at 23:41 IST on 2026-10-16 (Moon set): alt 67° → sin = 0.921; m = 3.4 → B = 0.844; size 177.8′ → S = 1.0; P = 0. Score = 100 · 0.921 · (0.464 + 0.45) = 84 ✔ (row 2 of the tonight example in the README).

9. Monthly events

10. Accuracy summary

Quantity Typical error Validation
Sun α, δ 0.01° Meeus 25.a (≤ 1e-5° vs. book's low-precision result)
Equation of time 0.1 s Meeus 28.b
Moon λ, β ~10″ Meeus 47.a
Moon illuminated fraction 0.001 Meeus 48.a
Lunar phase instants < 1 min Meeus 49.a, USNO Dec 2020 (±2 min)
Planets α, δ 15″ (Venus) – few ′ (outer) Meeus 33.a
Rise/set times < 1 min (geometry), ±2 min vs. almanacs Meeus 15.a, London/Pune references
Conjunction separation ~0.01° Jupiter–Saturn 2020
Constellation exact (boundary table) Roman 1987 test points, bright stars

Sources