Low-level API

These functions are not meant to be used outside of the package. They are documented only to aid future developments of the package.

Epochs

Tempo.JulianDateType
JulianDate

A type representing the JulianDate (JD) epoch origin.

With this origin, Epoch reference is -4712-01-01T12:00.

source
Tempo.JulianDate2000Type
JulianDate2000

A type representing the JulianDate2000 (J2000) epoch origin.

With this origin, Epoch reference is 2000-01-01T12:00.

source
Tempo.ModifiedJulianDateType
ModifiedJulianDate

A type representing the ModifiedJulianDate (MJD) epoch origin.

With this origin, Epoch reference is 1858-11-17T00:00.

source
Tempo.ModifiedJulianDate2000Type
ModifiedJulianDate2000

A type representing the ModifiedJulianDate2000 (MJD2000) epoch origin.

With this origin, Epoch reference is 2000-01-01T00:00.

source
Tempo.parse_isoFunction
parse_iso(s::AbstractString)

Parse an ISO datetime string, in the format YYYY-MM-DDThh:mm:ss.ffffffff and return a Tuple containing the year, month, day , hour, minute, second and milliseconds. If the string format is not recognised as ISO, an ArgumentError is thrown.

source

Timescale Offsets

Tempo.offsetFunction
offset(::Tempo.JulianDate)

Offset in days to shift J2000 epochs (with origin at 2000-01-01T12:00) to JulianDate (with origin at -4712-01-01T12:00)

source
offset(::Tempo.ModifiedJulianDate)

Offset in days to shift J2000 epochs (with origin at 2000-01-01T12:00) to ModifiedJulianDate (with origin at 1858-11-17T00:00)

source
offset(::Tempo.JulianDate2000)

Offset in days to shift J2000 epochs (with origin at 2000-01-01T12:00) to JulianDate2000 (with origin at 2000-01-01T12:00)

source
offset(::Tempo.ModifiedJulianDate2000)

Offset in days to shift J2000 epochs (with origin at 2000-01-01T12:00) to ModifiedJulianDate2000 (with origin at 2000-01-01T00:00)

source
Tempo.offset_tdb2ttFunction
offset_tdb2tt(seconds)

Return the offset between TDB and TT in seconds. This routine is accurate to ~40 microseconds over the interval 1900-2100.

Note

An accurate transformation between TDB and TT depends on the trajectory of the observer. For two observers fixed on Earth's surface the quantity TDB-TT can differ by as much as ~4 microseconds.

References

  • https://www.cv.nrao.edu/~rfisher/Ephemerides/times.html#TDB
  • Issue #26
source
Tempo.offset_tt2tdbFunction
offset_tt2tdb(seconds)

Return the offset between TT and TDB in seconds. This routine is accurate to ~40 microseconds over the interval 1900-2100.

Note

An accurate transformation between TDB and TT depends on the trajectory of the observer. For two observers fixed on Earth's surface the quantity TDB-TT can differ by as much as ~4 microseconds.

References

  • https://www.cv.nrao.edu/~rfisher/Ephemerides/times.html#TDB
  • Issue #26
source
Tempo.offset_tt2tdbhFunction
offset_tt2tdbh(seconds)

Return the offset between TT and TDBH in seconds.

The maximum error in using the above formula is about 10 µs from 1600 to 2200. For even more precise applications, the series expansion by Harada & Fukushima (2003) is recommended.

References

  • The IAU Resolutions on Astronomical Reference Systems, Time Scales, and Earth Rotation Models, United States Naval Observatory, https://arxiv.org/pdf/astro-ph/0602086.pdf
source

Timescale Types

Tempo.TimeScaleNodeType
TimeScaleNode{T} <: AbstractGraphNode

Define a timescale.

Fields

  • name – timescale name
  • id – timescale identification number (ID)
  • parentid – ID of the parent timescale
  • ffp – offest function from the parent timescale
  • ftp – offset function to the parent timescale
source

Conversions

Base.convertFunction
convert(to::S2, e::Epoch{S1}; system::TimeSystem=TIMESCALES)

Convert Epoch with timescale S1 to S2. Allows to use the default TimeSystem or a custom constructed one.

source
Tempo.cal2jdFunction
cal2jd(year::Integer, month::Integer, day::Integer)

This function converts a given date in the Gregorian calendar (year, month, day) to the corresponding two-parts Julian Date. The first part is the DJ2000, while the second output is the number of days since J2000.

The year must be greater than 1583, and the month must be between 1 and 12. The day must also be valid, taking into account whether the year is a leap year. If the input year or month or day are invalid, a DomainError is thrown.

Examples

julia> Tempo.cal2jd(2021, 1, 1)
(2.4000005e6, 59215.0)

julia> Tempo.cal2jd(2022, 2, 28)
(2.4000005e6, 59638.0)

julia> Tempo.cal2jd(2019, 2, 29)
ERROR: DomainError with 29:
the day shall be between 1 and 28.

References

  • Seidelmann P. K., (1992), Explanatory Supplement to the Astronomical Almanac, University Science Books, Section 12.92 (p604).
  • Klein, A., (2006), A Generalized Kahan-Babuska-Summation-Algorithm. Computing, 76, 279-293, Section 3.
  • ERFA software library
source
cal2jd(d::Date)

Convert Gregorian calendar Date to a Julian Date, in days.

Outputs

  • j2000 – J2000 zero point: always 2451545
  • d – J2000 Date for 12 hrs
source
Tempo.calhms2jdFunction
calhms2jd(year, month, day, hour, minute, seconds)

Convert Gregorian Calendar date and time to a two-parts Julian Date. The first part is the DJ2000, while the second output is the number of days since J2000.

Examples

julia> Tempo.calhms2jd(2000, 1, 1, 12, 0, 0)
(2.451545e6, 0.0)

julia> Tempo.calhms2jd(2022, 1, 1, 0, 0, 0)
(2.451545e6, 8035.5)
source
Tempo.fd2hmsFunction
fd2hms(fd::Number)

Convert the day fraction fd to hour, minute and seconds.

source
Tempo.fd2hmsfFunction
fd2hmsf(fd::Number)

Convert the day fraction fd to hour, minute, second and fraction of seconds.

Examples

julia> Tempo.fd2hms(0.5)
(12, 0, 0.0)
source
Tempo.hms2fdFunction
hms2fd(hour::Integer, minute::Integer, second::Number)

Convert hours, minutes and seconds to day fraction.

Examples

julia> Tempo.hms2fd(12, 0, 0.0)
0.5
source
Tempo.jd2calFunction
jd2cal(dj1::Number, dj2::Number)

This function converts a given Julian Date (JD) to a Gregorian calendar date (year, month, day, and fraction of a day).

Examples

julia> Tempo.jd2cal(DJ2000, 0.0)
(2000, 1, 1, 0.5)

julia> Tempo.jd2cal(DJ2000, 365.5)
(2001, 1, 1, 0.0)

julia> Tempo.jd2cal(DJ2000 + 365, 0.5)
(2001, 1, 1, 0.0)
Note

The Julian Date is apportioned in any convenient way between the arguments dj1 and dj2. For example, JD = 2450123.7 could be expressed in any of these ways, among others:

dj1dj2
2450123.70.0(JD method)
2451545.0-1421.3(J2000 method)
2400000.550123.2(MJD method)
2450123.50.2(date & time method)
Warning

The earliest valid date is -68569.5 (-4713 Jan 1). The largest value accepted is 1e9.

References

  • Seidelmann P. K., (1992), Explanatory Supplement to the Astronomical Almanac, University Science Books, Section 12.92 (p604).

  • Klein, A., (2006), A Generalized Kahan-Babuska-Summation-Algorithm. Computing, 76, 279-293, Section 3.

  • ERFA software library

source
Tempo.jd2calhmsFunction
jd2calhms(dj1::Number, dj2::Number)

Convert a two-parts Julian Date to Gregorian year, month, day, hour, minute, seconds. See jd2cal for more information on the Julian Date composition.

julia> Tempo.jd2calhms(DJ2000, 0.0)
(2000, 1, 1, 12, 0, 0.0)

julia> Tempo.jd2calhms(DJ2000 + 1, 0.25)
(2000, 1, 2, 18, 0, 0.0)

julia> Tempo.jd2calhms(DJ2000, 1.25)
(2000, 1, 2, 18, 0, 0.0)
source
Tempo.tai2utcFunction
tai2utc(tai1, tai2)

Transform a 2-part (quasi) Julian Date, in days, in International Atomic Time, TAI to a 2-part Julian Date in the Coordinated Universal Time, UTC, scale.

Note

tai1 + tai2 is Julian Date, apportioned in any convenient way between the two arguments, for example such that tai1 is the Julian Day Number and tai2 is the fraction of a day. The returned utc1 and utc2 form an analogous pair.

Note

JD cannot unambiguously represent UTC during a leap second unless special measures are taken. The convention in the present function is that the JD day represents UTC days whether the length is 86399, 86400 or 86401 SI seconds.

References

  • Seidelmann P. K., (1992), Explanatory Supplement to the Astronomical Almanac, University Science Books, Section 12.92 (p604).

  • McCarthy, D. D., Petit, G. (eds.), IERS Conventions (2003), IERS Technical Note No. 32, BKG (2004)

  • ERFA software library

source
Tempo.utc2taiFunction
utc2tai(utc1, utc2)

Transform a 2-part (quasi) Julian Date, in days, in Coordinate Universal Time, UTC to a 2-part Julian Date in the International Atomic Time, TAI scale.

Note

utc1 + utc2 is quasi Julian Date (see Note 2), apportioned in any convenient way between the two arguments, for example such that utc1 is the Julian Day Number and utc2 is the fraction of a day.

Note

JD cannot unambiguously represent UTC during a leap second unless special measures are taken. The convention in the present function is that the JD day represents UTC days whether the length is 86399, 86400 or 86401 SI seconds.

References

  • Seidelmann P. K., (1992), Explanatory Supplement to the Astronomical Almanac, University Science Books, Section 12.92 (p604).

  • McCarthy, D. D., Petit, G. (eds.), IERS Conventions (2003), IERS Technical Note No. 32, BKG (2004)

  • ERFA software library

source

Leapseconds

Tempo.LeapsecondsType
Leapseconds{T}

Stores information about the leap seconds that have been added to Coordinated Universal Time (UTC).

Fields

  • jd2000: a vector storing the Julian Date, in days since J2000, of each leap second.
  • leap: a vector storing the number of leap seconds at each corresponding entry of the jd2000 field.
source
Tempo.leapsecondsFunction
leapseconds(jd2000::Number)

For a given UTC date, in Julian days since J2000, calculate Delta(AT) = TAI - UTC.

source

Miscellaneous

Tempo.find_yearFunction
find_year(d::Integer)

Return the Gregorian year associated to the given Julian Date day d since J2000.

source
Tempo.find_monthFunction
find_month(dayinyear::Integer, isleap::Bool)

Find the month from the day of the year, depending on whether the year is leap or not.

source
Tempo.find_dayFunction
find_day(dayinyear::Integer, month::Integer, isleap::Bool)

Find the day of the month from the day in the year and the month, depending on whether the year is leap or not.

source
Tempo.fraction_of_dayFunction
fraction_of_day(t::Time)
hms2fd(t::Time)

Find the fraction of the day.

Example

julia> t = Time(12, 30, 40.3424)
12:30:40.3423

julia> Tempo.fraction_of_day(t)
0.5213002592592593
source
Tempo.fraction_of_secondFunction
fraction_of_second(t::Time)

Find the fraction of seconds.

Example

julia> t = Time(12, 30, 40.3424)
12:30:40.3423

julia> Tempo.fraction_of_second(t)
0.3423999999999978
source
fraction_of_second(d::DateTime)

Get the fraction of seconds associated to a DateTime object.

source
Tempo.isleapyearFunction
isleapyear(year::Integer)

Return true if the given Gregorian year is leap.

source
isleapyear(d::Date)

True if Date is within a leap year.

source
Tempo.second_in_dayFunction
second_in_day(t::Time)

Find the second in the day.

Example

julia> t = Time(12, 30, 40.3424)
12:30:40.3423

julia> Tempo.second_in_day(t)
45040.3424
source