Skip to content

Commit

Permalink
Ported ttut1 (#21)
Browse files Browse the repository at this point in the history
* ttut1

* ttut1 done

* ttut1

* ttut1

* ttut1

* ttut1 fixed
  • Loading branch information
prakharcode authored and helgee committed May 14, 2018
1 parent 8982cef commit 27cbb88
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/conversions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -383,15 +383,39 @@ julia> AstroTime.Epochs.tttdb(tt.jd1, tt.jd2, AstroTime.Epochs.deltatr(tdb))
date, date1
end

"""
ttut1(jd1, jd2, dt)
Transform a two-part Julian date from `TT` to `UT1`.
# Example
```jldoctest
julia> tt = Epoch{tt}(2.4578265e6, 0.30440190993249416)
2017-03-14T07:18:20.325 TT
julia> AstroTime.Epochs.ttut1(tt.jd1, tt.jd2, AstroTime.Epochs.deltat(tt))
(2.4578265e6, 0.30440190993249416)
```
"""
@inline function ttut1(jd1, jd2, dt)
dtd = dt / SECONDS_PER_DAY
if jd1 > jd2
date = jd1
date1 = jd2 - dtd
else
date = jd1 - dtd
date1 = jd2
end
date, date1
end

"""
ut1tt(jd1, jd2, dt)
Transform a two-part Julian date from `UT1` to `TT`.
# Example
```jldoctest
julia> ut1 = Epoch{UT1}(2.4578265e6, 0.30440190993249416)
2017-03-14T07:18:20.325 UT1
julia> AstroTime.Epochs.ut1tt(ut1.jd1, ut1.jd2, AstroTime.Epochs.deltat(ut1))
Expand Down
3 changes: 3 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,11 @@ AstroTime.update()
@test Epochs.tttdb(julian2(tt), julian1(tt), Δtr(tdb)) == ERFA.tttdb(julian2(tt), julian1(tt), Δtr(tdb))

dt(ep) = Epochs.deltat(ep)
@test Epochs.ttut1(julian1(tt), julian2(tt), dt(tt)) == ERFA.ttut1(julian1(tt), julian2(tt), dt(tt))
@test Epochs.ttut1(julian2(tt), julian1(tt), dt(tt)) == ERFA.ttut1(julian2(tt), julian1(tt), dt(tt))
@test Epochs.ut1tt(julian1(ut1), julian2(ut1), dt(ut1)) == ERFA.tttdb(julian1(ut1), julian2(ut1), dt(ut1))
@test Epochs.ut1tt(julian2(ut1), julian1(ut1), dt(ut1)) == ERFA.tttdb(julian2(ut1), julian1(ut1), dt(ut1))

end
@testset "Leap Seconds" begin
@test leapseconds(TTEpoch(1959,1,1)) == 0
Expand Down

0 comments on commit 27cbb88

Please sign in to comment.