Skip to content

Commit

Permalink
Merge pull request #42 from JuliaAstro/fix-helio
Browse files Browse the repository at this point in the history
Fix computation of heliocentric radius in helio.jl
  • Loading branch information
giordano authored Sep 26, 2017
2 parents 4dc98bb + 76cdc32 commit 6858a01
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 97 deletions.
27 changes: 14 additions & 13 deletions src/helio.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ function _helio(jd::T, num::Integer, radians::Bool) where {T<:AbstractFloat}
plong = deg2rad(planets[body].per_long + dpdt[num, 5])
mlong = deg2rad(planets[body].mean_long + dpdt[num, 6])
m = mlong - plong
nu = trueanom(kepler_solver(m, eccen), eccen)
hrad = a * (1 - eccen * cos(e))
E = kepler_solver(m, eccen)
nu = trueanom(E, eccen)
hrad = a * (1 - eccen * cos(E))
hlong = mod2pi(nu + plong)
hlat = asin(sin(hlong - along) * sin(inc))
if !radians
Expand Down Expand Up @@ -79,25 +80,25 @@ for Saturn.
julia> using AstroLib
julia> helio(jdcnv(2000,08,23,0), 2)
(0.7278046880206843, 198.39093251916148, 2.887355631705488)
(0.7213758288364316, 198.39093251916148, 2.887355631705488)
```
(2) Find the current heliocentric positions of all the planets
```jldoctest
julia> using AstroLib
julia> helio.([jdcnv(1900)], [1,2,3,4,5,6,7,8,9])
julia> helio.([jdcnv(1900)], 1:9)
9-element Array{Tuple{Float64,Float64,Float64},1}:
(0.459668, 202.61, 3.0503)
(0.727828, 344.538, -3.39243)
(1.01527, 101.55, 0.0126694)
(1.65333, 287.853, -1.57546)
(5.43316, 235.913, 0.913169)
(10.0107, 268.041, 1.08517)
(20.0188, 250.056, 0.0529709)
(30.3038, 87.0724, -1.24506)
(48.4377, 75.9469, -9.57668)
(0.4207394142180803, 202.60972662618906, 3.0503005607270532)
(0.7274605731764012, 344.5381482401048, -3.3924346961624785)
(0.9832446886519147, 101.54969268801035, 0.012669354526696368)
(1.4212659241051142, 287.8531100442217, -1.5754626002228043)
(5.386813769590955, 235.91306092135062, 0.9131692817310215)
(10.054339927304339, 268.04069870870387, 1.0851704598594278)
(18.984683376211326, 250.0555468087738, 0.05297087029604253)
(29.87722677219009, 87.07244903504716, -1.245060583142733)
(46.9647515992327, 75.94692594417324, -9.576681044165511)
```
### Notes ###
Expand Down
8 changes: 2 additions & 6 deletions src/planet_coords.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

#TODO: Use full JPL ephemeris for high precision
function _planet_coords(date::T, num::Integer) where {T<:AbstractFloat}

if num<1 || num>9
error("Input should be an integer in the range 1:9 denoting planet number")
end
rad, long, lat = helio(date, num, true)
rade, longe, late = helio(date, 3, true)
x = rad * cos(lat) * cos(long) - rade * cos(late) * cos(longe)
Expand All @@ -18,7 +14,7 @@ function _planet_coords(date::T, num::Integer) where {T<:AbstractFloat}
end

"""
planet_coords()
planet_coords(date, num)
### Purpose ###
Expand Down Expand Up @@ -56,7 +52,7 @@ Find the RA, Dec of Venus on 1992 Dec 20
julia> using AstroLib
julia> adstring(planet_coords(DateTime(1992,12,20),2))
" 21 00 15.3 -19 09 09"
" 21 05 02.8 -18 51 41"
```
### Notes ###
Expand Down
Loading

0 comments on commit 6858a01

Please sign in to comment.