Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ported Tttdb #20

Merged
merged 4 commits into from
May 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion src/conversions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,32 @@ end
32.184 + leapsec - ΔUT1
end

"""
tttdb(jd1, jd2, dtr)

Transform a two-part Julian date from `TT` to `TDB`.

# Example

```jldoctest
julia> tt = Epoch{TT}(2.4578265e6, 0.30440190993249416)
2017-03-14T07:18:20.325 TT
julia> AstroTime.Epochs.tttdb(tt.jd1, tt.jd2, AstroTime.Epochs.deltatr(tdb))
(2.4578265e6, 0.30440190993249416)
```
"""
@inline function tttdb(jd1, jd2, dtr)
dtrd = dtr / SECONDS_PER_DAY
if jd1 > jd2
date = jd1
date1 = jd2 + dtrd
else
date = jd1 + dtrd
date1 = jd2
end
date, date1
end

# TAI <-> UTC
@transform UTC TAI ep begin
jd1, jd2 = julian1(ep), julian2(ep)
Expand Down Expand Up @@ -491,4 +517,3 @@ Epoch{T}(ep::Epoch{T}) where {T} = ep
end
ex
end

2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ AstroTime.update()
@test Epochs.dtdb(julian1(tdb), julian2(tdb), 0.0, 0.0, 0.0, 0.0) == ERFA.dtdb(julian1(tdb), julian2(tdb), 0.0, 0.0, 0.0, 0.0)
@test Epochs.tdbtt(julian1(tdb), julian2(tdb), Δtr(tdb)) == ERFA.tdbtt(julian1(tdb), julian2(tdb), Δtr(tdb))
@test Epochs.tdbtt(julian2(tdb), julian1(tdb), Δtr(tdb)) == ERFA.tdbtt(julian2(tdb), julian1(tdb), Δtr(tdb))
@test Epochs.tttdb(julian1(tt), julian2(tt), Δtr(tdb)) == ERFA.tttdb(julian1(tt), julian2(tt), Δtr(tdb))
@test Epochs.tttdb(julian2(tt), julian1(tt), Δtr(tdb)) == ERFA.tttdb(julian2(tt), julian1(tt), Δtr(tdb))
end
@testset "Leap Seconds" begin
@test leapseconds(TTEpoch(1959,1,1)) == 0
Expand Down