Skip to content

Add lunar libration, position angle of axis and bright limb - #273

Merged
rhannequin merged 2 commits into
mainfrom
lunar-libration
Jun 22, 2026
Merged

rhannequin merged 2 commits into
mainfrom
lunar-libration

Conversation

@rhannequin

Copy link
Copy Markdown
Owner

Summary

This adds the lunar observation quantities that lunar observers expect: the Moon's libration in longitude and latitude, the position angle of its axis, the position angle of its bright limb, and the parallactic angle. All of them are derived from the Moon's and the Sun's apparent positions.

Everything is exposed on Astronoby::Moon instances:

ephem = Astronoby::Ephem.load("inpop19a.bsp")
instant = Astronoby::Instant.from_time(Time.utc(2025, 3, 1))
moon = Astronoby::Moon.new(instant: instant, ephem: ephem)

moon.libration                      # => Astronoby::Libration
moon.libration.longitude.str(:dms)  # => "-2° 5′ 4.4219″"   (l)
moon.libration.latitude.str(:dms)   # => "+0° 28′ 45.9616″" (b)
moon.position_angle_of_axis.str(:dms)        # => "-21° 48′ 46.657″"  (P)
moon.bright_limb_position_angle.str(:dms)    # => "+248° 1′ 57.9467″" (χ)

observer = Astronoby::Observer.new(
  latitude: Astronoby::Angle.from_degrees(48.8566),
  longitude: Astronoby::Angle.from_degrees(2.3522)
)
moon.parallactic_angle(observer: observer).str(:dms)
# => "+11° 42′ 47.1246″" (q)

Design

  • Astronoby::Libration is a small immutable value object holding the total (optical + physical) libration in longitude and latitude as Astronoby::Angle objects.
  • Astronoby::MoonPhysicalEphemeris is an internal calculator that owns the Meeus ch. 53 computation (optical + physical libration and axis angle). It follows the existing precedent of MoonPhasesPeriodicTerms, deriving its mean arguments locally.
  • Moon#libration and #position_angle_of_axis delegate to that calculator. #bright_limb_position_angle (geocentric, Meeus ch. 48) reuses the existing sun helper like #elongation and #phase_angle. #parallactic_angle(observer:) (Meeus ch. 14) uses the topocentric place via the existing observed_by, since lunar parallax is significant.

bright_limb_position_angle and parallactic_angle are kept Moon-only for now; they generalise cleanly to SolarSystemBody/Topocentric later if other bodies need them.

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 new lunar-observation quantities to Astronoby::Moon (total libration, axis position angle, bright-limb position angle, and observer-dependent parallactic angle) backed by a new internal Meeus-based calculator and documented in the guides.

Changes:

  • Introduces Astronoby::MoonPhysicalEphemeris to compute optical+physical libration and axis position angle (Meeus ch. 53).
  • Adds Astronoby::Libration value object and exposes new observation methods on Astronoby::Moon.
  • Adds/updates specs and documentation for the new Moon observation outputs.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
spec/astronoby/moon_physical_ephemeris_spec.rb Adds worked-example specs for libration and axis position angle calculations.
spec/astronoby/libration_spec.rb Adds unit specs for the Libration value object accessors.
spec/astronoby/bodies/moon_spec.rb Adds integration specs for Moon libration, axis angle, bright-limb angle, and parallactic angle.
lib/astronoby/moon_physical_ephemeris.rb Implements Meeus ch. 53 physical ephemeris computations (libration + axis angle).
lib/astronoby/libration.rb Adds the libration value object holding longitude/latitude angles.
lib/astronoby/bodies/moon.rb Exposes new lunar observation methods on Astronoby::Moon.
lib/astronoby.rb Wires new files into the library requires.
docs/README.md Documents new “Lunar observation” usage in the main docs index.
docs/moon_phases.md Adds navigation link to the new lunar observation page.
docs/lunar_observation.md Adds a dedicated documentation page for libration and angle quantities.

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

Comment thread lib/astronoby/libration.rb Resolved
Comment thread docs/lunar_observation.md Resolved
Comment thread docs/lunar_observation.md Resolved
Base automatically changed from planetary-phenomena to main June 22, 2026 22:43
@rhannequin
rhannequin merged commit df6f811 into main Jun 22, 2026
27 checks passed
@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