Introduce the TDB scale#13
Merged
Merged
Conversation
This adds Barycentric Dynamical Time, the scale the planetary ephemerides are written in. It is the third Astronoby-critical scale, after TAI and TT, and the first one that comes from a model rather than a constant offset. ```rb instant = Horologium::Instant.from_julian_date(2_460_796.5, scale: :tt) instant.to(:tdb).as(:julian_date) # => 2460796.5000000168 ``` TDB keeps almost the rate of TT, apart from periodic relativistic terms worth at most about two milliseconds, from the Earth's motion through the Sun's gravity. `Scales::TDB` reads TAI in TT first, a fixed 32.184 seconds, then adds the TDB - TT difference `Data::BarycentricModel` gives. `Data::BarycentricModel` is the full Fairhead & Bretagnon (1990) series that ERFA and astropy use, ported from ERFA's `dtdb.c`. The value is geocentric: the part of the model that depends on where on the Earth the observer stands is a few microseconds, and is left out. It agrees with pyerfa to about a nanosecond. The difference is a floating-point model, so unlike TAI and TT this edge is not exact, even at `:exact`. The model reads the date as a `Float`; at `:exact` its result is stored faithfully as a `Rational`, but the model itself stays a float computation. `:exact` keeps the arithmetic that follows it, not the model. UTC and the civil representations come next.
There was a problem hiding this comment.
Pull request overview
This pull request adds support for the TDB (Barycentric Dynamical Time) time scale to Horologium, including a port of the Fairhead & Bretagnon (1990) TDB−TT series (as used by ERFA/astropy) and wiring it into the scale registry so instants can be converted to/from :tdb.
Changes:
- Add
Horologium::Data::BarycentricModelimplementing the Fairhead & Bretagnon series forTDB - TT. - Add
Horologium::Scales::TDBand register it as a built-in scale, including top-level requires. - Add test coverage and RBS signatures for the new model and scale.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/test_configuration.rb | Updates expectations for registered scale lists to include :tdb. |
| test/scales/test_tdb.rb | Adds scale-level tests for registration, conversion behavior, and precision handling. |
| test/data/test_barycentric_model.rb | Adds model-level tests comparing tdb_minus_tt against reference values and bounds. |
| sig/horologium/scales/tdb.rbs | Adds RBS for the new Scales::TDB API surface. |
| sig/horologium/data/barycentric_model.rbs | Adds RBS for the new barycentric model module and helpers/constants. |
| lib/horologium/scales/tdb.rb | Implements the TDB scale conversion via TT plus model correction. |
| lib/horologium/data/barycentric_model.rb | Implements the full Fairhead & Bretagnon (1990) series ported from ERFA. |
| lib/horologium/configuration.rb | Registers :tdb as a built-in scale. |
| lib/horologium.rb | Requires the new model and scale files for library initialization. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
This adds Barycentric Dynamical Time, the scale the planetary ephemerides are written in. It is the third Astronoby-critical scale, after TAI and TT, and the first one that comes from a model rather than a constant offset.
TDB keeps almost the rate of TT, apart from periodic relativistic terms worth at most about two milliseconds, from the Earth's motion through the Sun's gravity.
Scales::TDBreads TAI in TT first, a fixed 32.184 seconds, then adds the TDB - TT differenceData::BarycentricModelgives.Data::BarycentricModelis the full Fairhead & Bretagnon (1990) series that ERFA and astropy use, ported from ERFA'sdtdb.c. The value is geocentric: the part of the model that depends on where on the Earth the observer stands is a few microseconds, and is left out. It agrees with pyerfa to about a nanosecond.The difference is a floating-point model, so unlike TAI and TT this edge is not exact, even at
:exact. The model reads the date as aFloat; at:exactits result is stored faithfully as aRational, but the model itself stays a float computation.:exactkeeps the arithmetic that follows it, not the model.UTC and the civil representations come next.