Class: Horologium::Scales::TT

Inherits:
Base
  • Object
show all
Defined in:
lib/horologium/scales/tt.rb,
sig/horologium/scales/tt.rbs

Overview

Terrestrial Time, the scale the theories of the solar system motion are written in, and the one an ephemeris expects. It is exactly 32.184 SI seconds ahead of TAI. The offset is fixed by definition, so this conversion needs no external data.

The 32.184 seconds come from Ephemeris Time, the scale used before atomic clocks. TT continues it, and the offset is the gap between the two when TAI took over.

Examples:

At the origin epoch, TT is 32.184 s ahead of TAI

instant = Horologium::Instant.from_julian_date(
  2_443_144.5,
  scale: :tai
)
instant.to(:tt).as(:julian_date) # => 2443144.5003725

Constant Summary collapse

SECONDS_AHEAD_OF_TAI =

The SI seconds TT is ahead of TAI.

Returns:

  • (Rational)
Rational(32_184, 1_000)
DAYS_AHEAD_OF_TAI =

The same offset in days, because a Julian Date counts days.

Returns:

  • (Rational)
SECONDS_AHEAD_OF_TAI / Duration::SECONDS_PER_DAY
OFFSETS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

The offset at each precision, built once, so a conversion does not build it again every time.

Returns:

Numeric::Precision::NAMES.map do |precision|
  [precision, Numeric::Precision.build(DAYS_AHEAD_OF_TAI, precision)]
end.to_h.freeze

Class Method Summary collapse

Methods inherited from Base

provenance, seconds_in_day, si_seconds_in_day, zone_designator

Class Method Details

.from_reference(value, precision) ⇒ Horologium::Numeric::TwoPartFloat, Horologium::Numeric::Exact

A TAI Julian Date, read in TT. It adds the 32.184 seconds.

Parameters:

Returns:



44
45
46
# File 'lib/horologium/scales/tt.rb', line 44

def from_reference(value, precision)
  Numeric::Precision.add(value, offset(precision))
end

.to_reference(value, precision) ⇒ Horologium::Numeric::TwoPartFloat, Horologium::Numeric::Exact

A TT Julian Date, read back in TAI. It removes the 32.184 seconds.

Parameters:

Returns:



55
56
57
# File 'lib/horologium/scales/tt.rb', line 55

def to_reference(value, precision)
  Numeric::Precision.subtract(value, offset(precision))
end