Repository navigation
Add Astronoby::Orientation for arcsecond lunar libration - #279
Merged
Merged
Conversation
rhannequin
force-pushed
the
accurate-lunar-libration
branch
from
June 23, 2026 15:13
9f72cb1 to
9d4bf11
Compare
Merged
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
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.
The Moon already has libration, the position angle of its axis and the position angle of its bright limb, all from Meeus's analytic series. The libration in longitude and the axis angle are good to a few arcseconds, but the libration in latitude is off by about 0.02 degrees. That residual is the well known difference between the mean lunar equator the classical method uses and the mean-Earth frame that JPL Horizons, IMCCE and Skyfield report, and it cannot be removed analytically.
This adds a more accurate path for the two quantities that suffer from it. JPL distributes the Moon's integrated orientation as a binary PCK kernel (
moon_pa_de440_200625.bpc), andephem0.5.0 can now read it. When you give one to the Moon, the libration and the axis angle are computed from that orientation rather than from the series, and they match Horizons to better than an arcsecond.The kernel is a separate read-only data source, loaded once like the ephemeris and passed next to it. Without one nothing changes and the Moon keeps using the analytic method, so this is entirely opt-in.
How it works
Astronoby::Orientationwraps the binary PCK. The kernel gives the orientation of the Moon's principal-axis frame, and which frame that is gets read from the kernel rather than assumed. The small fixed rotation from the principal axes to the mean-Earth frame is defined in NAIF's text frame kernels, not in the binary one, so its DE440 value is the single constant kept in the code. It is essentially the same across ephemeris versions (below 0.15 arcsecond), so it is applied to whatever kernel you load.Astronoby::MoonOrientationEphemerisdoes the computation. It evaluates the orientation at the light-time-retarded instant, expresses the Moon-to-Earth direction in the mean-Earth frame to get the selenographic sub-Earth point (the libration), and projects the lunar north pole to get the axis angle.Moon#librationand#position_angle_of_axisuse this calculator when an orientation kernel is present and fall back to the Meeus one otherwise. Both still return the sameAstronoby::LibrationandAstronoby::Angle, so calling code does not change.Along the way
A few smaller things came out of this change:
Astronoby::Rotationis a new home for the elementary rotation matrices about the axes, built from anAstronoby::Angle.Precessionnow uses it instead of its own private copies.Coordinates::Equatorial#position_angle_toholds the position angle formula that both the bright limb and the axis angle need. It is the directional companion toReferenceFrame#separation_from, kept on the coordinates since it is pure equatorial trigonometry.ephemmoves to~> 0.5, the first version that reads binary PCK kernels.The accuracy is checked against JPL Horizons in the specs. For a few 2025 dates the libration agrees to better than 0.01 arcsecond and the axis angle to about 0.16 arcsecond.