Integrate horologium for TAI, TT and TDB - #298
Open
rhannequin wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
🟢 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:standardprecision) and update precession evaluation to use TT. - Standardize
Instant#tt/#tai/#tdb/#diffoutputs toRationalto avoid Float precision loss at large Julian Dates. - Update dependencies (
horologium,iers ~> 0.2), add regression specs forInstant#hashconsistency, 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 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 |
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.
So far, Astronoby has been dealing with its time scale conversions: TAI was TT minus a Rational literal, and TDB simply returned TT.
horologiumnow does this job, so this hands TAI, TT and TDB over to it.Astronoby::Instantkeeps its public API and becomes a thin layer overHorologium::Instant. UT1 stays inAstronoby::DeltaThorologium 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,taiandtdbrender asRational, notFloat. A Julian Date is around 2.46 million, which leaves a singleFloatabout 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 inTeme#to_ecefbefore being fixed.Precession now uses
ttinstead oftdb. The IAU 2006 model is conventionally evaluated in TT, as SOFA and ERFA do. Sincetdbused to bett, this preserves the previous behaviour exactly, and it avoids paying for the 787-term TDB model on every instant.