Skip to content

Commit

Permalink
Add Project.toml, fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
helgee committed May 16, 2019
1 parent c510fe3 commit 4f5317d
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -3,3 +3,4 @@
*.2*
*.4*
*.bsp
Manifest.toml
18 changes: 18 additions & 0 deletions Project.toml
@@ -0,0 +1,18 @@
name = "JPLEphemeris"
uuid = "30a7bc16-7fba-505b-b600-cae92896a3fe"

[deps]
AstroBase = "e1773a3a-3ab2-51da-b25a-65b4161c689f"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Mmap = "a63ad114-7e13-5084-954f-fe012c677804"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"

[compat]
Reexport = "≥ 0.2.0"
julia = "≥ 0.7.0"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
3 changes: 0 additions & 3 deletions REQUIRE

This file was deleted.

4 changes: 2 additions & 2 deletions benchmark/benchmark.jl
Expand Up @@ -8,10 +8,10 @@ Random.seed!(430)
function runner_ep(times)
pos = zeros(3)
vel = zeros(3)
position_velocity!(pos, vel, spk, times[1], luna, mercury)
state!(pos, vel, spk, times[1], luna, mercury)
total = 0.0
for t in times
time = @elapsed position_velocity!(pos, vel, spk, t, luna, mercury)
time = @elapsed state!(pos, vel, spk, t, luna, mercury)
total += time
end
print_time(total / n)
Expand Down
17 changes: 8 additions & 9 deletions src/spk.jl
@@ -1,14 +1,14 @@
using LinearAlgebra: transpose!
using AstroBase: NAIFId, TDBEpoch, from_naifid, julian_twopart, value, SECONDS_PER_DAY

import AstroBase.Interfaces:
import AstroBase.Ephemerides:
AbstractEphemeris,
position,
position!,
velocity,
velocity!,
position_velocity,
position_velocity!
state,
state!

export SPK,
segments,
Expand All @@ -17,8 +17,8 @@ export SPK,
position!,
velocity,
velocity!,
position_velocity,
position_velocity!
state,
state!

const SIZE_FLOAT64 = sizeof(Float64)

Expand Down Expand Up @@ -236,7 +236,7 @@ end
end


@inline function position_velocity!(pos,
@inline function state!(pos,
vel,
spk::SPK,
seg::Segment,
Expand Down Expand Up @@ -265,7 +265,6 @@ end
segments[origin][target], sign
end


function position!(pos, spk::SPK, ep::TDBEpoch, from::NAIFId, to::NAIFId)
seg, sign = findsegment(spk.segments, from, to)
jd1, jd2 = value.(julian_twopart(ep))
Expand All @@ -278,9 +277,9 @@ function velocity!(vel, spk::SPK, ep::TDBEpoch, from::NAIFId, to::NAIFId)
velocity!(vel, spk, seg, sign, jd1, jd2)
end

function position_velocity!(pos, vel, spk::SPK, ep::TDBEpoch, from::NAIFId, to::NAIFId)
function state!(pos, vel, spk::SPK, ep::TDBEpoch, from::NAIFId, to::NAIFId)
seg, sign = findsegment(spk.segments, from, to)
jd1, jd2 = value.(julian_twopart(ep))
position_velocity!(pos, vel, spk, seg, sign, jd1, jd2)
state!(pos, vel, spk, seg, sign, jd1, jd2)
end

2 changes: 1 addition & 1 deletion test/basic.jl
Expand Up @@ -33,7 +33,7 @@ spk = SPK("$path/de430.bsp")
@testset for (a, b) in zip(JPLEphemeris.list_segments(spk), de430segments)
@test a == b
end
@testset for (func, ref) in zip((position, velocity, position_velocity), (r_ref, v_ref, rv_ref))
@testset for (func, ref) in zip((position, velocity, state), (r_ref, v_ref, rv_ref))
res = func(spk, ep, ssb, mercury_barycenter)
@test all(res .≈ ref)
res = func(spk, ep, mercury_barycenter, ssb)
Expand Down
2 changes: 1 addition & 1 deletion test/kernels.jl
Expand Up @@ -61,7 +61,7 @@ end
function teststate(kernel, tdb, origin, target)
origin = id_to_body(origin)
target = id_to_body(target)
rv = vcat(position_velocity(kernel, tdb, origin, target)...)
rv = vcat(state(kernel, tdb, origin, target)...)
# From km/s to km/day
rv[4:6] .*= 86400.0
# From km to AU
Expand Down

0 comments on commit 4f5317d

Please sign in to comment.