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.AbstractEpochOrigin
— TypeAbstractEpochOrigin
Abstract type for all epoch origins.
Tempo.JulianDate
— TypeJulianDate
A type representing the JulianDate (JD) epoch origin.
With this origin, Epoch reference is -4712-01-01T12:00
.
Tempo.JulianDate2000
— TypeJulianDate2000
A type representing the JulianDate2000 (J2000) epoch origin.
With this origin, Epoch reference is 2000-01-01T12:00
.
Tempo.ModifiedJulianDate
— TypeModifiedJulianDate
A type representing the ModifiedJulianDate (MJD) epoch origin.
With this origin, Epoch reference is 1858-11-17T00:00
.
Tempo.ModifiedJulianDate2000
— TypeModifiedJulianDate2000
A type representing the ModifiedJulianDate2000 (MJD2000) epoch origin.
With this origin, Epoch reference is 2000-01-01T00:00
.
Tempo.EpochConversionError
— TypeEpochConversionError
A type representing epoch conversion errors.
Tempo.parse_iso
— Functionparse_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.
Timescale Offsets
Tempo.offset
— Functionoffset(::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
)
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
)
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
)
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
)
Tempo.offset_gps2tai
— FunctionTempo.offset_tai2gps
— FunctionTempo.offset_tai2tt
— FunctionTempo.offset_tai2utc
— FunctionTempo.offset_tcb2tdb
— FunctionTempo.offset_tcg2tt
— FunctionTempo.offset_tdb2tt
— Functionoffset_tdb2tt(seconds)
Return the offset between TDB
and TT
in seconds. This routine is accurate to ~40 microseconds over the interval 1900-2100.
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
Tempo.offset_tdb2tcb
— FunctionTempo.offset_tt2tai
— FunctionTempo.offset_tt2tcg
— FunctionTempo.offset_tt2tdb
— Functionoffset_tt2tdb(seconds)
Return the offset between TT
and TDB
in seconds. This routine is accurate to ~40 microseconds over the interval 1900-2100.
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
Tempo.offset_tt2tdbh
— Functionoffset_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
Tempo.offset_utc2tai
— FunctionTimescale Types
Tempo.TimeScaleNode
— TypeTimeScaleNode{T} <: AbstractGraphNode
Define a timescale.
Fields
name
– timescale nameid
– timescale identification number (ID)parentid
– ID of the parent timescaleffp
– offest function from the parent timescaleftp
– offset function to the parent timescale
Tempo.AbstractTimeScale
— TypeAbstractTimeScale
All timescales are subtypes of the abstract type AbstractTimeScale
.
Tempo.GlobalPositioningSystemTime
— TypeGlobalPositioningSystemTime <: AbstractTimeScale
A type representing the Global Positioning System Time (GPS) time scale.
Tempo.BarycentricDynamicalTime
— TypeBarycentricDynamicalTime <: AbstractTimeScale
A type representing the Barycentric Dynamical Time (TDB) time scale.
Tempo.HighPrecisionBarycentricDynamicalTime
— TypeHighPrecisionBarycentricDynamicalTime <: AbstractTimeScale
A type representing the High Precision Barycentric Dynamical Time (TDBH) time scale.
Tempo.BarycentricCoordinateTime
— TypeBarycentricCoordinateTime <: AbstractTimeScale
A type representing the Barycentric Coordinate Time (TCB) time scale.
Tempo.TerrestrialTime
— TypeTerrestrialTime <: AbstractTimeScale
A type representing the Terrestrial Time (TT) time scale.
Tempo.InternationalAtomicTime
— TypeInternationalAtomicTime <: AbstractTimeScale
A type representing the International Atomic Time (TAI) time scale.
Tempo.UniversalTime
— TypeUniversalTime <: AbstractTimeScale
A type representing the Universal Time (UT1) time scale.
Tempo.CoordinatedUniversalTime
— TypeCoordinatedUniversalTime <: AbstractTimeScale
A type representing the Coordinated Universal Time (UTC) time scale.
Tempo.GeocentricCoordinateTime
— TypeGeocentricCoordinateTime <: AbstractTimeScale
A type representing the Geocentric Coordinate Time (TCG) time scale.
Conversions
Base.convert
— Functionconvert(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.
Tempo.cal2jd
— Functioncal2jd(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
cal2jd(d::Date)
Convert Gregorian calendar Date
to a Julian Date, in days.
Outputs
j2000
– J2000 zero point: always 2451545d
– J2000 Date for 12 hrs
Tempo.calhms2jd
— Functioncalhms2jd(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)
Tempo.fd2hms
— Functionfd2hms(fd::Number)
Convert the day fraction fd
to hour, minute and seconds.
Tempo.fd2hmsf
— Functionfd2hmsf(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)
Tempo.hms2fd
— Functionhms2fd(hour::Integer, minute::Integer, second::Number)
Convert hours, minutes and seconds to day fraction.
Examples
julia> Tempo.hms2fd(12, 0, 0.0)
0.5
Tempo.jd2cal
— Functionjd2cal(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)
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:
dj1 | dj2 | |
---|---|---|
2450123.7 | 0.0 | (JD method) |
2451545.0 | -1421.3 | (J2000 method) |
2400000.5 | 50123.2 | (MJD method) |
2450123.5 | 0.2 | (date & time method) |
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.
Tempo.jd2calhms
— Functionjd2calhms(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)
Tempo.tai2utc
— Functiontai2utc(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.
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.
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)
Tempo.utc2tai
— Functionutc2tai(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.
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.
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)
Leapseconds
Tempo.Leapseconds
— TypeLeapseconds{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 thejd2000
field.
Tempo.LEAPSECONDS
— ConstantLEAPSECONDS
Leapseconds data.
Tempo.leapseconds
— Functionleapseconds(jd2000::Number)
For a given UTC date, in Julian days since J2000
, calculate Delta(AT) = TAI - UTC.
Miscellaneous
Tempo.find_year
— Functionfind_year(d::Integer)
Return the Gregorian year associated to the given Julian Date day d
since J2000
.
Tempo.find_month
— Functionfind_month(dayinyear::Integer, isleap::Bool)
Find the month from the day of the year, depending on whether the year is leap or not.
Tempo.find_day
— Functionfind_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.
Tempo.fraction_of_day
— Functionfraction_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
Tempo.fraction_of_second
— Functionfraction_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
fraction_of_second(d::DateTime)
Get the fraction of seconds associated to a DateTime
object.
Tempo.isleapyear
— Functionisleapyear(year::Integer)
Return true
if the given Gregorian year is leap.
isleapyear(d::Date)
True if Date
is within a leap year.
Tempo.lastj2000dayofyear
— Functionlastj2000dayofyear(year::Integer)
Tempo.second_in_day
— Functionsecond_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