Repository navigation
Lunar eclipse local circumstances - #302
Merged
Merged
Conversation
`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.
There was a problem hiding this comment.
🟡 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.clearmakes subsequentvisible?andcircumstancecalls 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
LunarEclipse#visibility_from(observer)returns aLunarEclipseVisibilitydescribing what one place sees of an eclipse:#circumstance,#coverageper phase,#above_horizon_at?,#horizon_crossingsand#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.
LunarEclipseGeometryis 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:
The eclipse API also got a consistency pass while it is still unreleased:
EclipsePhasebecameLunarEclipsePhase, magnitudes and gamma are derived from the geometry rather than stored twice, and#greatest_eclipsebecame#greatest_eclipse_instant.UPGRADING.mdcovers the parts that affect 0.10.0.