Skip to content

Add planetary phenomena - #271

Merged
rhannequin merged 1 commit into
mainfrom
planetary-phenomena
Jun 22, 2026
Merged

rhannequin merged 1 commit into
mainfrom
planetary-phenomena

Conversation

@rhannequin

@rhannequin rhannequin commented Jun 7, 2026 •

Copy link
Copy Markdown
Owner

This adds the classic planetary phenomena relative to the Sun, computed in the apparent geocentric ecliptic frame of date:

  • Conjunctions of any planet with the Sun, classified as inferior or superior.
  • Oppositions of the superior planets (Mars to Neptune).
  • Greatest elongations of the inferior planets (Mercury and Venus), classified as eastern or western.

It also exposes the elongation of a body as a first-class property, which until now only existed internally for the phase angle computation.

ephem = Astronoby::Ephem.load("inpop19a.bsp")
range = {ephem: ephem, start_time: Time.utc(2025, 1, 1), end_time: Time.utc(2026, 1, 1)}

Astronoby::Mars.opposition_events(**range)
# => [#<Astronoby::Opposition>]

Astronoby::Venus.conjunction_events(**range)
# => [#<Astronoby::Conjunction>]

Astronoby::Mercury.greatest_elongation_events(**range)
# => [#<Astronoby::GreatestElongation>, ...]

The phenomena are only defined for the planets they can occur for. Requesting an impossible one raises Astronoby::UnsupportedEventError:

  • opposition_events requires a superior planet.
  • greatest_elongation_events requires an inferior planet.
  • conjunction_events requires a planet (the Sun, the Earth and the Moon have none).

The elongation is also available directly on a body instance, together with the side of the Sun it lies on:

venus = Astronoby::Venus.new(instant: instant, ephem: ephem)
venus.elongation # => #<Astronoby::Angle>
venus.eastern?   # => false (visible in the morning)
venus.western?   # => true

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.

Pull request overview

This PR adds support for classic planet–Sun phenomena (conjunctions, oppositions, greatest elongations) computed in the apparent geocentric ecliptic frame of date, and promotes elongation (plus east/west-of-Sun predicates) to a first-class SolarSystemBody property. It also adjusts ecliptic conversion for apparent/topocentric places to use true obliquity of date and refactors extremum-finding into reusable finder classes.

Changes:

  • Add event models and calculators for conjunctions/oppositions and greatest elongations, plus supporting numerical root/extremum finders.
  • Add #elongation, #eastern?, and #western? to SolarSystemBody, and expose phenomena query class methods with UnsupportedEventError guards.
  • Update apparent/topocentric ecliptic conversion to use true obliquity of date; refresh related spec expectations and add new documentation pages/sections.

Reviewed changes

Copilot reviewed 38 out of 38 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
spec/astronoby/events/greatest_elongation_calculator_spec.rb Adds specs validating Venus and Mercury greatest elongation event finding.
spec/astronoby/events/conjunction_opposition_calculator_spec.rb Adds specs for Mars/Saturn oppositions and Mercury/Venus/Saturn conjunction classification.
spec/astronoby/bodies/venus_spec.rb Updates apparent ecliptic expectations; adds elongation + east/west predicates spec.
spec/astronoby/bodies/uranus_spec.rb Updates apparent ecliptic expectations after true-obliquity change.
spec/astronoby/bodies/sun_spec.rb Updates apparent ecliptic expectations after true-obliquity change.
spec/astronoby/bodies/solar_system_body_spec.rb Adds specs asserting unsupported phenomena raise UnsupportedEventError.
spec/astronoby/bodies/saturn_spec.rb Updates apparent ecliptic expectations after true-obliquity change.
spec/astronoby/bodies/neptune_spec.rb Updates apparent ecliptic expectations after true-obliquity change.
spec/astronoby/bodies/moon_spec.rb Updates apparent ecliptic expectations after true-obliquity change.
spec/astronoby/bodies/mercury_spec.rb Updates apparent ecliptic expectations after true-obliquity change.
spec/astronoby/bodies/mars_spec.rb Updates apparent ecliptic expectations after true-obliquity change.
spec/astronoby/bodies/jupiter_spec.rb Updates apparent ecliptic expectations after true-obliquity change.
spec/astronoby/bodies/deep_sky_object_position_spec.rb Updates deep-sky apparent ecliptic expectations after true-obliquity change.
lib/astronoby/root_finder.rb Introduces a sampling + bisection root finder for conjunction/opposition detection.
lib/astronoby/extremum_finder.rb Introduces sampling + golden-section refinement for maxima/minima detection.
lib/astronoby/events/opposition.rb Adds an Opposition event model.
lib/astronoby/events/conjunction.rb Adds a Conjunction event model with inferior/superior subtype.
lib/astronoby/events/greatest_elongation.rb Adds a GreatestElongation event model with eastern/western direction.
lib/astronoby/events/conjunction_opposition_calculator.rb Adds conjunction/opposition event computation via RootFinder.
lib/astronoby/events/greatest_elongation_calculator.rb Adds greatest elongation computation via ExtremumFinder.
lib/astronoby/events/extremum_calculator.rb Refactors existing apoapsis/periapsis logic to reuse ExtremumFinder.
lib/astronoby/reference_frames/apparent.rb Switches apparent ecliptic conversion to true obliquity of date.
lib/astronoby/reference_frames/topocentric.rb Switches topocentric ecliptic conversion to true obliquity of date.
lib/astronoby/coordinates/equatorial.rb Extends to_ecliptic to accept an explicit obliquity parameter.
lib/astronoby/bodies/solar_system_body.rb Adds planet classification helpers, phenomena query APIs, and elongation/east/west helpers.
lib/astronoby/bodies/mercury.rb Adds orbital period and marks Mercury as an inferior planet.
lib/astronoby/bodies/venus.rb Adds orbital period and marks Venus as an inferior planet.
lib/astronoby/bodies/mars.rb Adds orbital period and marks Mars as a superior planet.
lib/astronoby/bodies/jupiter.rb Adds orbital period and marks Jupiter as a superior planet.
lib/astronoby/bodies/saturn.rb Adds orbital period and marks Saturn as a superior planet.
lib/astronoby/bodies/uranus.rb Adds orbital period and marks Uranus as a superior planet.
lib/astronoby/bodies/neptune.rb Adds orbital period and marks Neptune as a superior planet.
lib/astronoby/bodies/earth.rb Adds Earth orbital period constant (used for synodic periods).
lib/astronoby/bodies/moon.rb Adds Moon orbital period constant (used for apo/periapsis finder scaling).
lib/astronoby.rb Wires new finders and planetary-phenomena classes into the library requires.
docs/solar_system_bodies.md Documents #elongation, #eastern?, and #western?.
docs/README.md Adds a “Planetary phenomena” usage section and link.
docs/planetary_phenomena.md Adds a new documentation page describing phenomena APIs and semantics.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/astronoby/root_finder.rb Resolved
@rhannequin
rhannequin merged commit cbebf61 into main Jun 22, 2026
28 checks passed
@rhannequin
rhannequin deleted the planetary-phenomena branch June 22, 2026 22:43
@rhannequin rhannequin mentioned this pull request Jun 24, 2026
rhannequin added a commit that referenced this pull request Jun 26, 2026
## 0.10.0 - 2026-06-26

_If you are upgrading: please see [UPGRADING.md]._

### Bug fixes

* Fix constant name typo ([#245])
* Fix matrix multiplication order in Apparent frame ([#250])
* Remove spurious N·P from observer ECEF-to-TOD transformation ([#251])
* Apply aberration in GCRS before precession/nutation rotation ([#253])
* Fix Moon magnitude ([#254])
* Fix astrometric position for Deep Sky Objects ([#272])

### Features

* Defer Solar System body computations lazily ([#244])
* Integrate `iers` gem for Delta T and GMST ([#249])
* Add IERS polar motion correction to observer ECEF-to-TOD transformation ([#252])
* Fall back to polynomial GMST for dates outside IERS EOP range ([#255])
* Add ICRS frame bias to precession matrix ([#257])
* Extract `EarthRotation` class from `Observer` ([#260])
* Add TEME reference frame for satellite tracking ([#261])
* Add ECEF to geodetic conversion (WGS-84) ([#262])
* Memoize per-instant conversions on `Instant` ([#268])
* Add `ReferenceFrame#separation_from` for angular separation ([#269])
* Introduce `Center`, `Body` and `Position` domain objects ([#270])
* Add planetary phenomena ([#271])
* Add lunar libration, position angle of axis and bright limb ([#273])
* Add `Astronoby::Orientation` for arcsecond lunar libration ([#279])
* Add Lunar eclipses ([#280])
* Add `Astronoby::Duration` ([#281])

### Improvements

* Optimize nutation loop by eliminating array allocations ([#246])
* Reuse single Nutation instance in observer matrix computation ([#247])
* Memoize Observer geodetic computation methods ([#248])
* Update documentation with recent values ([#256])
* Update referential frames documentation ([#258])
* YARD documentation update ([#259])
* Update zlib, JSON and ERB for security reasons
* Add references to README
* Bump actions/checkout from 5 to 7 by @dependabot ([#239], [#276])
* Bump rubyzip from 3.2.1 to 3.4.0 by @dependabot ([#237], [#267], [#275])
* Bump irb from 1.15.2 to 1.17.0 by @dependabot ([#242])
* Bump standard from 1.51.1 to 1.55.0 by @dependabot ([#243], [#274])
* Bump rake from 13.3.1 to 13.4.2 by @dependabot ([#264])
* Bump ephem from 0.4.1 to 0.5.0 by @dependabot ([#278])
* Upgrade default Ruby to 4.0.5 ([#277])

### Backward-incompatible changes

* Minimum Ruby version bumped to 3.2.0 ([#249])
* Delta T and GMST now use IERS data ([#249])
* Defer Solar System body computations lazily ([#244])
* `SolarSystemBody#ephem` is now publicly accessible ([#244])
* `ReferenceFrame#center_identifier` replaced by `#center` ([#270])
* `Sun#equation_of_time` now returns a `Duration` ([#281])

**Full Changelog**: v0.9.0...v0.10.0

[#237]: #237
[#239]: #239
[#242]: #242
[#243]: #243
[#244]: #244
[#245]: #245
[#246]: #246
[#247]: #247
[#248]: #248
[#249]: #249
[#250]: #250
[#251]: #251
[#252]: #252
[#253]: #253
[#254]: #254
[#255]: #255
[#256]: #256
[#257]: #257
[#258]: #258
[#259]: #259
[#260]: #260
[#261]: #261
[#262]: #262
[#264]: #264
[#267]: #267
[#268]: #268
[#269]: #269
[#270]: #270
[#271]: #271
[#272]: #272
[#273]: #273
[#274]: #274
[#275]: #275
[#276]: #276
[#277]: #277
[#278]: #278
[#279]: #279
[#280]: #280
[#281]: #281
[UPGRADING.md]: https://github.com/rhannequin/astronoby/blob/main/UPGRADING.md
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