Skip to content

Lunar eclipse local circumstances - #302

Merged
rhannequin merged 2 commits into
improve-rts-accuracyfrom
lunar-eclipse-visibility
Aug 30, 2026
Merged

rhannequin merged 2 commits into
improve-rts-accuracyfrom
lunar-eclipse-visibility

Conversation

@rhannequin

Copy link
Copy Markdown
Owner

LunarEclipse#visibility_from(observer) returns a LunarEclipseVisibility describing what one place sees of an eclipse: #circumstance, #coverage per phase, #above_horizon_at?, #horizon_crossings and #observable_windows.

It takes no ephemeris, the Moon's apparent place is now carried on the eclipse itself, at greatest eclipse and at every contact, so an eclipse can be computed once, cached, and then observed from as many places as wanted.

LunarEclipseGeometry is exposed at every contact rather than only at greatest eclipse, giving the cone radii, axis distance, position angle, magnitudes and which side of the axis the Moon passes. Each contact geometry carries the Moon's apparent geocentric place as #moon_coordinates.

Three fixes came out of building it:

  • Equatorial coordinates now report the epoch of the frame they came from instead of always claiming J2000, so precessing an apparent or topocentric place works
  • Events are bisected to a millisecond instead of a second
  • Rise, transit and set times no longer come out late

The eclipse API also got a consistency pass while it is still unreleased: EclipsePhase became LunarEclipsePhase, magnitudes and gamma are derived from the geometry rather than stored twice, and #greatest_eclipse became #greatest_eclipse_instant. UPGRADING.md covers the parts that affect 0.10.0.

`LunarEclipse#visibility_from(observer)` returns a `LunarEclipseVisibility`
describing what one place sees of an eclipse: `#circumstance`, `#coverage` per
phase, `#above_horizon_at?`, `#horizon_crossings` and `#observable_windows`.

It takes no ephemeris, the Moon's apparent place is now carried on the
eclipse itself, at greatest eclipse and at every contact, so an eclipse can
be computed once, cached, and then observed from as many places as wanted.

`LunarEclipseGeometry` is exposed at every contact rather than only at
greatest eclipse, giving the cone radii, axis distance, position angle,
magnitudes and which side of the axis the Moon passes. Each contact
geometry carries the Moon's apparent geocentric place as `#moon_coordinates`.

Three fixes came out of building it:
* Equatorial coordinates now report the epoch of the frame they came from
  instead of always claiming J2000, so precessing an apparent or topocentric
  place works
* Events are bisected to a millisecond instead of a second
* Rise, transit and set times no longer come out late

The eclipse API also got a consistency pass while it is still unreleased:
`EclipsePhase` became `LunarEclipsePhase`, magnitudes and gamma are derived
from the geometry rather than stored twice, and `#greatest_eclipse` became
`#greatest_eclipse_instant`. `UPGRADING.md` covers the parts that affect
0.10.0.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Grazing visibility can be missed, while zero-vector epochs and mutable cached results create inconsistent API behavior.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds ephemeris-free local lunar-eclipse visibility while improving eclipse geometry, coordinate epochs, event precision, and API consistency.

Changes:

  • Adds local visibility, phase coverage, horizon crossings, and observable windows.
  • Carries apparent lunar coordinates through eclipse geometry and corrects frame epochs.
  • Renames eclipse APIs, improves root precision, and centralizes horizon calculations.
File summaries
File Description
UPGRADING.md Documents breaking API and precision changes.
spec/astronoby/root_finder_spec.rb Tests root accuracy and termination.
spec/astronoby/reference_frames/teme_spec.rb Tests TEME epochs.
spec/astronoby/reference_frames/mean_of_date_spec.rb Tests mean-of-date epochs.
spec/astronoby/reference_frames/astrometric_spec.rb Tests J2000 astrometric epochs.
spec/astronoby/reference_frame_spec.rb Tests frame epoch propagation.
spec/astronoby/horizon_spec.rb Tests shared horizon conventions.
spec/astronoby/events/lunar_eclipse_visibility_spec.rb Covers local eclipse visibility.
spec/astronoby/events/lunar_eclipse_spec.rb Updates eclipse API tests.
spec/astronoby/events/lunar_eclipse_phase_spec.rb Tests renamed phases and durations.
spec/astronoby/events/lunar_eclipse_geometry_spec.rb Tests expanded geometry.
spec/astronoby/events/lunar_eclipse_calculator_spec.rb Tests contact coordinates.
spec/astronoby/events/conjunction_opposition_calculator_spec.rb Accommodates precise event times.
lib/astronoby/root_finder.rb Improves bisection precision and exact roots.
lib/astronoby/reference_frames/topocentric.rb Adds topocentric epoch.
lib/astronoby/reference_frames/teme.rb Adds TEME epoch.
lib/astronoby/reference_frames/mean_of_date.rb Adds mean-of-date epoch.
lib/astronoby/reference_frames/apparent.rb Adds apparent-frame epoch.
lib/astronoby/reference_frame.rb Propagates frame epochs to coordinates.
lib/astronoby/horizon.rb Centralizes rise/set horizon calculations.
lib/astronoby/events/rise_transit_set_calculator.rb Uses shared horizon logic.
lib/astronoby/events/lunar_eclipse.rb Adds visibility and derives geometry values.
lib/astronoby/events/lunar_eclipse_visibility.rb Implements local circumstances.
lib/astronoby/events/lunar_eclipse_phase.rb Renames phases and preserves fractional duration.
lib/astronoby/events/lunar_eclipse_geometry.rb Stores coordinates and axis side.
lib/astronoby/events/lunar_eclipse_calculator.rb Produces expanded contact geometry.
lib/astronoby/coordinates/equatorial.rb Accepts coordinate epochs.
lib/astronoby.rb Loads the new and renamed components.
docs/lunar_eclipses.md Documents local visibility APIs.
CHANGELOG.md Records features and fixes.
benchmarks/performance.rb Benchmarks eclipse calculation and visibility.
Review details

Suppressed comments (1)

lib/astronoby/events/lunar_eclipse_visibility.rb:146

  • The memoized windows array is mutable despite the object's immutability contract. For example, visibility.observable_windows.clear makes subsequent visible? and circumstance calls return different answers. Freeze the computed array before returning it.
    def observable_windows
      @memo[:observable_windows] ||= begin
  • Files reviewed: 31/31 changed files
  • Comments generated: 5
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread lib/astronoby/root_finder.rb Resolved
Comment thread lib/astronoby/coordinates/equatorial.rb Resolved
Comment thread docs/lunar_eclipses.md Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The broad astronomical coordinate, timing, interpolation, and public API changes warrant final domain-expert validation.

Review details
  • Files reviewed: 31/31 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@rhannequin
rhannequin merged commit 53d7015 into main Aug 30, 2026
45 checks passed
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.

2 participants