Flexible and fast astronomical orbits (originally a submodule of Transits.jl).
The goals of this package are, in this order:
To install use Pkg. From the REPL, press ]
to enter Pkg-mode
pkg> add Orbits
If you want to use the most up-to-date version of the code, check it out from main
pkg> add Orbits#main
using Orbits
using Plots
using Unitful, UnitfulAstro
using UnitfulRecipes
# orbital params for SAO 136799
distance = inv(6.92e-3)u"pc"
orbit = KeplerianOrbit(;
period = 40.57u"yr",
ecc = 0.42,
Omega = 318.6u"°",
tp = 1972.12u"yr",
incl = 54.7u"°",
a = 0.154u"arcsecond" * distance |> u"AU",
omega = 72.6u"°",
)
# get position at specific time
t = 2022.134u"yr"
pos = relative_position(orbit, t)
ra_off, dec_off = @. pos[1:2] / distance |> u"arcsecond"
2-element Vector{Quantity{Float64, NoDims, Unitful.FreeUnits{(″,), NoDims, nothing}}}:
0.14482641030730156 ″
-0.07816487001285195 ″
# plot using Unitful recipes
plot(orbit; distance, lab="", leg=:topleft)
scatter!([0u"arcsecond" ra_off], [0u"arcsecond" dec_off],
c=[:black 1], m=[:+ :o], lab=["SAO 136799A" "B ($t)"])
pa = round(Orbits.position_angle(orbit, t), sigdigits=5)
sep = round(u"AU", Orbits.separation(orbit, t), sigdigits=5)
pa, sep
(118.36, 23.782 AU)
If you would like to contribute, feel free to open a pull request. If you want to discuss something before contributing, head over to discussions and join or open a new topic.