Skip to content

True-moon phase timing (0.1.0) - #32

Open
kingdonb wants to merge 1 commit into
mainfrom
feat/true-moon
Open

kingdonb wants to merge 1 commit into
mainfrom
feat/true-moon

Conversation

@kingdonb

Copy link
Copy Markdown
Owner

For #10. This makes the next release 0.1.0: what the brain reports at a given moment changes.

What

cycle_position now uses the Moon's true elongation from the Sun instead of counting mean synodic months from the 2000-01-06 new moon. That is Meeus, Astronomical Algorithms (2nd ed.), eq. 48.4: the mean elongation D plus the six largest periodic terms in D, M (Sun's mean anomaly) and M′ (Moon's mean anomaly).

  • Still no_std with no dependencies. Adds sin for any angle (by range reduction onto the existing cosine series), floor, and degree normalisation.
  • Phase windows, torment multipliers, illumination formula and the JSON contract are all unchanged. Only when each phase begins and ends moves, by up to ~14 hours.
  • A side effect: pre-2000 timestamps now work, since there's no reference new moon to count from. Not a goal, just free.

Accuracy

Measured against 2026's published instants (cargo test true_moon -- --nocapture):

Event (UTC) Error
New moon Jan 18 19:52 −6 min
New moon Feb 17 12:01, annular solar eclipse +4 min
New moon Aug 12 17:37, total solar eclipse −18 min
Full moon Jan 3 10:03 −7 min
Full moon Mar 3 11:38, total lunar eclipse +3 min
Full moon Aug 28 04:18, partial lunar eclipse +16 min
Full moon Nov 24 14:53 −32 min

The mean-month model could be off by up to ~14 hours.

Tests

The brain has 17 tests:

  • the published instants above, within 0.5° (~1 hour);
  • eclipses at illumination < 0.0001 and > 0.9999;
  • 2026 has exactly 12 new and 13 full moons;
  • elongation only increases, minute by minute, at a plausible rate;
  • sin against std for angles up to ±195,000°, plus floor and normalisation;
  • the existing illumination, formatting, JSON and buffer tests.

The Android unit tests (4) now use the same real instants instead of inverting the old formula. They run the rebuilt WASM through Chicory.

Not done

— Claude-Opus-5.5

🤖 Generated with Claude Code

Replace the mean synodic month (counted from the 2000-01-06 new moon)
with the Moon's true elongation from the Sun: the mean elongation D plus
the six largest periodic terms in D, M and M' (Meeus, Astronomical
Algorithms, ch. 48, eq. 48.4). Adds no_std sin for arbitrary angles,
floor and degree normalisation; still no dependencies.

Against 2026's published new and full moons, including the four
eclipses, the error is -32 to +16 minutes, where the mean model could
be off by up to ~14 hours. Phase windows, multipliers and the JSON
contract are unchanged.

Tests now check real instants (eclipses, a year's count of 12 new and
13 full moons, smooth minute-by-minute motion); the Android tests use
the same instants instead of inverting the old formula.

Refs #10

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant