Skip to content

Integrate horologium for TAI, TT and TDB - #298

Open
rhannequin wants to merge 2 commits into
document-delta-t-extractionfrom
integrate-horologium-gem
Open

Integrate horologium for TAI, TT and TDB#298
rhannequin wants to merge 2 commits into
document-delta-t-extractionfrom
integrate-horologium-gem

Conversation

@rhannequin

@rhannequin rhannequin commented Aug 22, 2026

Copy link
Copy Markdown
Owner

So far, Astronoby has been dealing with its time scale conversions: TAI was TT minus a Rational literal, and TDB simply returned TT. horologium now does this job, so this hands TAI, TT and TDB over to it.

Astronoby::Instant keeps its public API and becomes a thin layer over Horologium::Instant. UT1 stays in Astronoby::DeltaT horologium leaves it out on purpose, since it rests on observations of the rotation of the Earth rather than on definitions.
The precision is pinned to :standard.

tt, tai and tdb render as Rational, not Float. A Julian Date is around 2.46 million, which leaves a single Float about 47 microseconds for the fraction of a day. That is 2 cm of Earth rotation, and it showed up as a 2.3 cm shift in Teme#to_ecef before being fixed.

Precession now uses tt instead of tdb. The IAU 2006 model is conventionally evaluated in TT, as SOFA and ERFA do. Since tdb used to be tt, this preserves the previous behaviour exactly, and it avoids paying for the 787-term TDB model on every instant.

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.

🟢 Approval recommended

The changes are cohesive and well-tested, with only minor documentation-type mismatches noted.

Pull request overview

This PR migrates Astronoby’s TT/TAI/TDB time scale handling to the horologium gem while keeping Astronoby::Instant’s public API intact, improving both correctness (real TDB) and numeric precision (Rational JD outputs).

Changes:

  • Delegate TT/TAI/TDB computations to horologium (pinned to :standard precision) and update precession evaluation to use TT.
  • Standardize Instant#tt/#tai/#tdb/#diff outputs to Rational to avoid Float precision loss at large Julian Dates.
  • Update dependencies (horologium, iers ~> 0.2), add regression specs for Instant#hash consistency, and document upgrade notes.
File summaries
File Description
UPGRADING.md Documents the new horologium dependency, iers minimum version bump, and the Rational-returning API changes.
spec/astronoby/instant_spec.rb Adds coverage ensuring hash/deduplication behavior is consistent across numeric input types.
lib/astronoby/precession.rb Switches precession evaluation input from tdb to conventional tt.
lib/astronoby/instant.rb Wraps Horologium::Instant and routes TT/TAI/TDB through it while preserving Astronoby’s API surface.
Gemfile.lock Locks horologium and raises iers to the required ~> 0.2 range.
astronoby.gemspec Adds horologium dependency and raises iers dependency constraint.
Review details
  • Files reviewed: 5/6 changed files
  • Comments generated: 1
  • Review effort level: Lite

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

Comment thread lib/astronoby/instant.rb
Comment on lines +95 to +99
# @return [Numeric] the Terrestrial Time as a Julian Date
def terrestrial_time
@memo[:terrestrial_time] ||=
@instant.as(:julian_date, scale: :tt, as: :rational)
end
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