View Source SpaceDust.Time.Transforms (Space Dust v0.3.0)

Nx-based time transformations between different time standards.

All conversions are performed efficiently using Nx tensors for potential GPU/TPU acceleration.

Time Scale Relationships

UTC <---> TAI <---> TT
  |         |
  |         +--> GPS
  |
  +--> JD/MJD
  |
  +--> GMST
  • TAI = UTC + leap_seconds
  • TT = TAI + 32.184s
  • GPS = TAI - 19s

Summary

Functions

Convert a batch of TAI times to UTC using Nx.

Full conversion pipeline: UT1 unix seconds -> GMST radians.

Convert a batch of UTC times to TAI using Nx. Takes a tensor of Unix seconds (UTC) and leap seconds offset.

GMST in radians from a batch of UT1 Julian Dates, normalized to [0, 2π).

Convert GPS time to TAI.

Convert GPS time directly to UTC.

Calculate GMST from a Julian Date.

Convert Julian Date to UTC.

Convert TAI to GPS time.

Convert TAI to TT.

Convert TAI to UTC.

Convert TT to TAI.

Convert TT directly to UTC.

Calculate GMST from UTC time.

Convert UTC directly to GPS time.

Convert UTC to Julian Date.

Convert UTC to TAI.

Convert UTC directly to TT.

Convert UTC to the UT1 Julian Date.

Functions

batch_tai_to_utc(tai_tensor, leap_seconds)

Convert a batch of TAI times to UTC using Nx.

batch_ut1_to_gmst(ut1_unix_seconds)

Full conversion pipeline: UT1 unix seconds -> GMST radians.

Takes UT1, not UTC: an EOP lookup cannot run inside defn, so add the UT1 - UTC offset (see utc_to_ut1_jd/1) before calling this. Passing UTC costs up to about 13 arcseconds of rotation.

batch_utc_to_tai(utc_tensor, leap_seconds)

Convert a batch of UTC times to TAI using Nx. Takes a tensor of Unix seconds (UTC) and leap seconds offset.

gmst_from_jd_tensor(jd)

GMST in radians from a batch of UT1 Julian Dates, normalized to [0, 2π).

gps_to_tai(gps)

@spec gps_to_tai(SpaceDust.Time.GPS.t()) :: SpaceDust.Time.TAI.t()

Convert GPS time to TAI.

gps_to_utc(gps)

@spec gps_to_utc(SpaceDust.Time.GPS.t()) :: SpaceDust.Time.UTC.t()

Convert GPS time directly to UTC.

jd_to_gmst(julian_date)

Calculate GMST from a Julian Date.

The Julian Date must be in UT1. Use utc_to_gmst/1 to have the UT1 offset applied for you.

jd_to_unix_seconds(jd)

jd_to_utc(julian_date)

Convert Julian Date to UTC.

tai_to_gps(tai)

@spec tai_to_gps(SpaceDust.Time.TAI.t()) :: SpaceDust.Time.GPS.t()

Convert TAI to GPS time.

GPS = TAI - 19 seconds (offset since GPS epoch)

tai_to_tt(tai)

@spec tai_to_tt(SpaceDust.Time.TAI.t()) :: SpaceDust.Time.TT.t()

Convert TAI to TT.

TT = TAI + 32.184 seconds

tai_to_tt_tensor(tai_tensor)

tai_to_utc(tai)

@spec tai_to_utc(SpaceDust.Time.TAI.t()) :: SpaceDust.Time.UTC.t()

Convert TAI to UTC.

UTC = TAI - leap_seconds

Note: This requires knowing the leap seconds at the TAI time, which technically requires iterating since leap seconds are defined in UTC. We use an approximation that works for normal use cases.

tt_to_tai(tt)

@spec tt_to_tai(SpaceDust.Time.TT.t()) :: SpaceDust.Time.TAI.t()

Convert TT to TAI.

TAI = TT - 32.184 seconds

tt_to_tai_tensor(tt_tensor)

tt_to_utc(tt)

@spec tt_to_utc(SpaceDust.Time.TT.t()) :: SpaceDust.Time.UTC.t()

Convert TT directly to UTC.

unix_seconds_to_jd(unix_seconds)

utc_to_gmst(utc)

@spec utc_to_gmst(SpaceDust.Time.UTC.t()) :: SpaceDust.Time.GMST.t()

Calculate GMST from UTC time.

Uses the IAU 1982 expression, evaluated on UT1.

utc_to_gps(utc)

@spec utc_to_gps(SpaceDust.Time.UTC.t()) :: SpaceDust.Time.GPS.t()

Convert UTC directly to GPS time.

utc_to_jd(utc)

Convert UTC to Julian Date.

utc_to_tai(utc)

@spec utc_to_tai(SpaceDust.Time.UTC.t()) :: SpaceDust.Time.TAI.t()

Convert UTC to TAI.

TAI = UTC + leap_seconds

utc_to_tt(utc)

@spec utc_to_tt(SpaceDust.Time.UTC.t()) :: SpaceDust.Time.TT.t()

Convert UTC directly to TT.

utc_to_ut1_jd(utc)

@spec utc_to_ut1_jd(SpaceDust.Time.UTC.t()) :: float()

Convert UTC to the UT1 Julian Date.

Earth's rotation angle is a function of UT1, so any sidereal time has to be formed from UT1 rather than UTC. The offset comes from the interpolated IERS table and is bounded by 0.9 s; an epoch with no EOP coverage falls back to UTC, which costs up to about 13 arcseconds of rotation.