Fit Radial Velocity and Astrometry
You can use Octofitter to jointly fit relative astrometry data and radial velocity data. Below is an example. For more information on these functions, see previous guides.
Import required packages
using Octofitter
using OctofitterRadialVelocity
using CairoMakie
using PairPlots
using Distributions
using PlanetOrbitsWe now use PlanetOrbits.jl to create sample data. We start with a template orbit and record it's positon and velocity at a few epochs.
orb_template = orbit(
a = 1.0,
e = 0.7,
i= pi/4,
Ω = 0.1,
ω = 1π/4,
M = 1.0,
plx=100.0,
m =0,
tp =58829-40
)
Makie.lines(orb_template,axis=(;autolimitaspect=1))
Sample position and store as relative astrometry measurements:
epochs = [58849,58852,58858,58890]
astrom_dat = Table(
epoch=epochs,
ra=raoff.(orb_template, epochs),
dec=decoff.(orb_template, epochs),
σ_ra=fill(1.0, size(epochs)),
σ_dec=fill(1.0, size(epochs)),
cor=fill(0.0, size(epochs))
)
astrom = PlanetRelAstromObs(
astrom_dat,
name = "simulated",
variables = @variables begin
# Fixed values for this example - could be free variables:
jitter = 0 # mas [could use: jitter ~ Uniform(0, 10)]
northangle = 0 # radians [could use: northangle ~ Normal(0, deg2rad(1))]
platescale = 1 # relative [could use: platescale ~ truncated(Normal(1, 0.01), lower=0)]
end
)PlanetRelAstromObs Table with 6 columns and 4 rows:
epoch ra dec σ_ra σ_dec cor
┌────────────────────────────────────────────
1 │ 58849 -18.3017 -108.907 1.0 1.0 0.0
2 │ 58852 -21.1181 -111.432 1.0 1.0 0.0
3 │ 58858 -26.6349 -115.889 1.0 1.0 0.0
4 │ 58890 -53.1334 -129.043 1.0 1.0 0.0And plot our simulated astrometry measurments:
fig = Makie.lines(orb_template,axis=(;autolimitaspect=1))
Makie.scatter!(astrom.table.ra, astrom.table.dec)
fig
Generate a simulated RV curve from the same orbit:
using Random
Random.seed!(1)
epochs = 58849 .+ range(0,step=1.5, length=20)
planet_sim_mass = 0.001 # solar masses here
rvlike = MarginalizedStarAbsoluteRVObs(
Table(
epoch=epochs,
rv=radvel.(orb_template, epochs, planet_sim_mass) .+ 150,
σ_rv=fill(5.0, size(epochs)),
),
name="inst1",
variables=@variables begin
jitter ~ LogUniform(0.1, 100) # m/s
end
)
epochs = 58949 .+ range(0,step=1.5, length=20)
rvlike2 = MarginalizedStarAbsoluteRVObs(
Table(
epoch=epochs,
rv=radvel.(orb_template, epochs, planet_sim_mass) .- 150,
σ_rv=fill(5.0, size(epochs)),
),
name="inst2",
variables=@variables begin
jitter ~ LogUniform(0.1, 100) # m/s
end
)
fap = Makie.scatter(rvlike.table.epoch[:], rvlike.table.rv[:])
Makie.scatter!(rvlike2.table.epoch[:], rvlike2.table.rv[:])
fap
Now specify model and fit it:
planet_b = Planet(
name="b",
basis=Visual{KepOrbit},
observations=[astrom],
variables=@variables begin
e ~ Uniform(0,0.999999)
a ~ truncated(Normal(1, 1),lower=0.1)
mass ~ truncated(Normal(1, 1), lower=0.)
i ~ Sine()
M = system.M
Ω ~ UniformCircular()
ω ~ UniformCircular()
θ ~ UniformCircular()
tp = θ_at_epoch_to_tperi(θ, 58849.0; M, e, a, i, ω, Ω) # reference epoch for θ. Choose an MJD date near your data.
end
)
sys = System(
name="test",
companions=[planet_b],
observations=[rvlike, rvlike2],
variables=@variables begin
M ~ truncated(Normal(1, 0.04),lower=0.1) # (Baines & Armstrong 2011).
plx = 100.0
end
)
model = Octofitter.LogDensityModel(sys)
using Random
rng = Xoshiro(0) # seed the random number generator for reproducible results
results = octofit(rng, model, max_depth=9, adaptation=300, iterations=400)Chains MCMC chain (400×35×1 Array{Float64, 3}):
Iterations = 1:1:400
Number of chains = 1
Samples per chain = 400
Wall duration = 9.16 seconds
Compute duration = 9.16 seconds
parameters = M, plx, inst1_jitter, inst2_jitter, b_e, b_a, b_mass, b_i, b_Ωx, b_Ωy, b_ωx, b_ωy, b_θx, b_θy, b_Ω, b_ω, b_θ, b_M, b_tp, b_simulated_jitter, b_simulated_northangle, b_simulated_platescale
internals = n_steps, is_accept, acceptance_rate, hamiltonian_energy, hamiltonian_energy_error, max_hamiltonian_energy_error, tree_depth, numerical_error, step_size, nom_step_size, is_adapt, loglike, logpost, tree_depth, numerical_error
Summary Statistics
parameters mean std mcse ess_bulk ess_ta ⋯
Symbol Float64 Float64 Float64 Float64 Float ⋯
M 0.9971 0.0404 0.0023 294.7892 242.69 ⋯
plx 100.0000 0.0000 NaN NaN N ⋯
inst1_jitter 0.4379 0.4016 0.0215 193.8180 86.06 ⋯
inst2_jitter 0.4094 0.3689 0.0196 202.2767 185.03 ⋯
b_e 0.5614 0.2181 0.0493 17.4154 37.97 ⋯
b_a 1.3539 0.4642 0.0969 31.1467 25.98 ⋯
b_mass 0.9016 0.5859 0.0404 177.4480 192.46 ⋯
b_i 0.8974 0.2597 0.0529 17.9875 20.49 ⋯
b_Ωx 0.5410 0.6762 0.4622 3.4139 13.20 ⋯
b_Ωy -0.1059 0.5246 0.4088 1.8566 24.34 ⋯
b_ωx -0.0414 0.6459 0.3023 5.1065 54.86 ⋯
b_ωy 0.7236 0.2969 0.0469 41.9382 133.54 ⋯
b_θx -0.9971 0.1051 0.0059 381.5377 246.32 ⋯
b_θy -0.1672 0.0179 0.0010 372.0520 224.23 ⋯
b_Ω -0.4662 1.0815 0.8245 1.8386 12.27 ⋯
b_ω 1.5928 0.8556 0.3227 6.1306 41.67 ⋯
b_θ -2.9754 0.0062 0.0003 580.6075 273.72 ⋯
⋮ ⋮ ⋮ ⋮ ⋮ ⋮ ⋱
3 columns and 5 rows omitted
Quantiles
parameters 2.5% 25.0% 50.0% 75.0% ⋯
Symbol Float64 Float64 Float64 Float64 ⋯
M 0.9223 0.9698 0.9973 1.0262 ⋯
plx 100.0000 100.0000 100.0000 100.0000 ⋯
inst1_jitter 0.1021 0.1583 0.3123 0.5546 ⋯
inst2_jitter 0.1036 0.1553 0.2805 0.5079 ⋯
b_e 0.0849 0.4250 0.5875 0.7486 ⋯
b_a 0.8437 0.9966 1.2762 1.5748 ⋯
b_mass 0.1002 0.4515 0.8141 1.2675 ⋯
b_i 0.3296 0.7407 0.9676 1.1179 ⋯
b_Ωx -0.8363 0.0697 0.8807 0.9824 ⋯
b_Ωy -1.0334 -0.6371 0.0922 0.3314 ⋯
b_ωx -1.0199 -0.7116 0.0088 0.5088 ⋯
b_ωy 0.0494 0.5284 0.7820 0.9505 ⋯
b_θx -1.2155 -1.0547 -0.9904 -0.9319 ⋯
b_θy -0.2030 -0.1783 -0.1660 -0.1561 ⋯
b_Ω -2.5088 -1.4985 0.0918 0.3307 ⋯
b_ω 0.1136 1.0377 1.5589 2.3518 ⋯
b_θ -2.9877 -2.9795 -2.9754 -2.9713 ⋯
⋮ ⋮ ⋮ ⋮ ⋮ ⋱
1 column and 5 rows omitted
Display results as a corner plot:
octocorner(model,results, small=true)
Plot RV curve, phase folded curve, and binned residuals:
Octofitter.rvpostplot(model, results)
Display RV, PMA, astrometry, relative separation, position angle, and 3D projected views:
octoplot(model, results)