Detection Limits

Warning

This tutorial is a work in progress.

This guide shows how to calculate detection limits, in mass, or in photometry, as a function of orbital parameters for different combinations of data.

There are a few use cases for this:

• Mass limit vs semi-major axis given one or more images and/or contrast curves
• Mass limit vs semi-major axis given an RV non-detection
• Mass limit vs semi-major axis given proper motion anomaly from the GAIA-Hipparcos Catalog of Accelerations
• Any combination of the above

We will once more use some sample data from the system HD 91312 A & B discovered by SCExAO.

using Octofitter
using OctofitterImages
using Distributions
using Pigeons
using CairoMakie
using PairPlots

Photometry Model

We will need to decide on an atmosphere model to map image intensities into mass. Here we use the Sonora Bobcat cooling and atmosphere models which will be auto-downloaded by Octofitter:

const cooling_tracks = Octofitter.sonora_cooling_interpolator()
const sonora_temp_mass_L = Octofitter.sonora_photometry_interpolator(:Keck_L′)
(::Octofitter.var"#model_interpolator#215"{Interpolations.FilledExtrapolation{Float64, 2, Interpolations.ScaledInterpolation{Float64, 2, Interpolations.BSplineInterpolation{Float64, 2, Matrix{Float64}, Interpolations.BSpline{Interpolations.Linear{Interpolations.Throw{Interpolations.OnGrid}}}, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}}, Interpolations.BSpline{Interpolations.Linear{Interpolations.Throw{Interpolations.OnGrid}}}, Tuple{StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}}}, Interpolations.BSpline{Interpolations.Linear{Interpolations.Throw{Interpolations.OnGrid}}}, Float64}, Float64, Float64, Float64, Float64}) (generic function with 1 method)

Proper Motion Anomaly Data

We start by defining and sampling from a model that only includes proper motion anomaly data from the HGCA:

@planet B Visual{KepOrbit} begin
a ~ LogUniform(1, 65)
e ~ Uniform(0,0.9)
ω ~ Uniform(0,2pi)
i ~ Sine() # The Sine() distribution is defined by Octofitter
Ω ~ Uniform(0,pi)# ~ UniformCircular()
mass = system.M_sec
θ ~ Uniform(0,2pi)
tp = θ_at_epoch_to_tperi(system,B,57423.0) # epoch of GAIA measurement
end
@system HD91312_pma begin
M_pri ~ truncated(Normal(0.95, 0.05), lower=0) # Msol
M_sec ~ LogUniform(0.2, 65) # MJup
M = system.M_pri + system.M_sec*Octofitter.mjup2msol # Msol

plx ~ gaia_plx(gaia_id=6166183842771027328)

# Priors on the center of mass proper motion
pmra ~ Normal(0, 1000)
pmdec ~ Normal(0,  1000)
end HGCALikelihood(gaia_id=6166183842771027328) B
model_pma = Octofitter.LogDensityModel(HD91312_pma)
LogDensityModel for System HD91312_pma of dimension 11 with fields .ℓπcallback and .∇ℓπcallback


Sample:

using Pigeons
chain_pma, pt = octofit_pigeons(model_pma, n_chains=16, n_chains_variational=16, n_rounds=12);
[ Info: Determining initial positions and metric using pathfinder
┌ Info: Found a sample of initial positions
└   initial_logpost_range = (-733051.75321396, -733047.1366429877)
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
scans     restarts      Λ        Λ_var      time(s)    allc(B)  log(Z₁/Z₀)   min(α)     mean(α)    min(αₑ)   mean(αₑ)
────────── ────────── ────────── ────────── ────────── ────────── ────────── ────────── ────────── ────────── ──────────
2          0       3.03       4.67       5.28   3.28e+08  -3.59e+06          0      0.752       0.88       0.91
4          0       3.99       4.32      0.428   9.28e+06  -3.78e+06          0      0.732      0.867       0.92
8          0       6.84       5.11      0.505   9.01e+05  -3.52e+03          0      0.614      0.869      0.916
16          0       6.14       6.46       1.08   1.68e+06  -6.69e+04          0      0.593      0.893      0.915
32          0       7.75       6.03       2.21   3.24e+06       -282  6.81e-240      0.556      0.896      0.917
64          1        7.7       3.89        5.5    2.3e+08        -17   6.43e-57      0.626        0.9      0.913
128          8       8.07       3.29       9.36   4.06e+08      -16.9   1.53e-12      0.634      0.901      0.912
256         25       8.66       3.14       18.4   8.01e+08      -17.1   7.75e-09      0.619      0.902      0.911
512         45       9.21       3.35         37    1.6e+09      -17.3    0.00305      0.595      0.902      0.912
1.02e+03        107       9.35       3.01       73.6   3.17e+09      -17.3     0.0288      0.601      0.902      0.909
2.05e+03        182       9.62       3.52        149    6.4e+09      -17.2     0.0693      0.576      0.902      0.912
4.1e+03        441        9.9       3.22        295   1.26e+10      -17.1      0.132      0.577      0.902       0.91
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Plot the marginal mass vs. semi-major axis posterior with contours using PairPlots.jl:

pairplot(
PairPlots.Series(
(;
sma=log.(chain_pma[:B_a][:],),
mass=log.(chain_pma[:B_mass][:]),
),
label="PMA",
color=Makie.wong_colors()[1],
)=>(
PairPlots.Scatter(markersize=3,alpha=0.35),
PairPlots.Contour(sigmas=[1,3]),
PairPlots.MarginStepHist(),
),
labels=Dict(
:sma=>"log Semi-major axis [au]",
:mass=>"log Mass [Mⱼᵤₚ]"
)
)

Image Data

using AstroImages
"https://github.com/sefffal/Octofitter.jl/raw/main/docs/image-examples-1.fits",
"image-examples-1.fits"
)

# Or multi-extension FITS (this example)
image = AstroImages.load("image-examples-1.fits").*2e-7 # units of contrast

image_data = ImageLikelihood(
(band=:L, image=AstroImages.recenter(image), platescale=4.0, epoch=57423.6),
)
OctofitterImages.ImageLikelihood Table with 6 columns and 1 row:
band  image                 platescale  epoch    contrast              ⋯
┌─────────────────────────────────────────────────────────────────────────
1 │ L     [-6.80461e-8 -6.247…  4.0         57423.6  65-element extrapol…  ⋯
@planet B Visual{KepOrbit} begin
a ~ LogUniform(1, 65)
e ~ Uniform(0,0.9)
ω ~ Uniform(0,2pi)
i ~ Sine() # The Sine() distribution is defined by Octofitter
Ω ~ Uniform(0,pi)
mass = system.M_sec

# Calculate planet temperature from cooling track and planet mass variable
tempK = cooling_tracks(system.age, B.mass)
# Calculate absolute magnitude
abs_mag_L = sonora_temp_mass_L(B.tempK, B.mass)
# Deal with out-of-grid values by clamping to grid max and min
abs_mal_L′ = if isfinite(B.abs_mag_L)
B.abs_mag_L
elseif B.mass > 10
else
end
# Calculate relative magnitude
rel_mag_L = B.abs_mal_L′ - system.rel_mag + 5log10(1000/system.plx)
# Convert to contrast (same units as image)
L = 10.0^(B.rel_mag_L/-2.5)

θ ~ Uniform(0,2pi)
tp = θ_at_epoch_to_tperi(system,B,57423.6)
end image_data

@system HD91312_img begin
# age ~ truncated(Normal(40, 15),lower=0, upper=200)
age = 10
M_pri ~ truncated(Normal(0.95, 0.05), lower=0) # Msol
# Mass of secondary
# Make sure to pick only a mass range that is covered by your models
M_sec ~ LogUniform(0.55, 65) # MJup
M = system.M_pri + system.M_sec*Octofitter.mjup2msol # Msol
plx ~ gaia_plx(gaia_id=6166183842771027328)
# Priors on the center of mass proper motion
# pmra ~ Normal(0, 1000)
# pmdec ~ Normal(0,  1000)
rel_mag = 5.65
end  B
model_img = Octofitter.LogDensityModel(HD91312_img)
LogDensityModel for System HD91312_img of dimension 9 with fields .ℓπcallback and .∇ℓπcallback

using Pigeons
chain_img, pt = octofit_pigeons(model_img, n_chains=5, n_chains_variational=5, n_rounds=7)
(chain = MCMC chain (128×23×1 Array{Float64, 3}), pt = PT(checkpoint = false, ...))

Plot mass vs. semi-major axis posterior:

vis_layers = (
PairPlots.Contour(sigmas=[1,3]),
PairPlots.MarginStepHist(),
)
pairplot(
PairPlots.Series(
(;
sma=log.(chain_pma[:B_a][:],),
mass=log.(chain_pma[:B_mass][:]),
),
label="PMA",
color=Makie.wong_colors()[1],
)=>vis_layers,
PairPlots.Series(
(;
sma=log.(chain_img[:B_a][:],),
mass=log.(chain_img[:B_mass][:]),
),
label="IMG",
color=Makie.wong_colors()[2],
)=>vis_layers,
labels=Dict(
:sma=>"log Semi-major axis [au]",
:mass=>"log Mass [Mⱼᵤₚ]"
)
)

Image and PMA data

@planet B Visual{KepOrbit} begin
a ~ LogUniform(1, 65)
e ~ Uniform(0,0.9)
ω ~ Uniform(0,2pi)
i ~ Sine() # The Sine() distribution is defined by Octofitter
Ω ~ Uniform(0,pi)
mass = system.M_sec

# Calculate planet temperature from cooling track and planet mass variable
tempK = cooling_tracks(system.age, B.mass)
# Calculate absolute magnitude
abs_mag_L = sonora_temp_mass_L(B.tempK, B.mass)
# Deal with out-of-grid values by clamping to grid max and min
abs_mal_L′ = if isfinite(B.abs_mag_L)
B.abs_mag_L
elseif B.mass > 10
else
end
# Calculate relative magnitude
rel_mag_L = B.abs_mal_L′ - system.rel_mag + 5log10(1000/system.plx)
# Convert to contrast (same units as image)
L = 10.0^(B.rel_mag_L/-2.5)

# L ~ Uniform(0,1)

θ ~ Uniform(0,2pi)
tp = θ_at_epoch_to_tperi(system,B,57423.6)
end image_data

@system HD91312_both begin
# age ~ truncated(Normal(40, 15),lower=0, upper=200)
age = 10
M_pri ~ truncated(Normal(0.95, 0.05), lower=0) # Msol
# Mass of secondary
# Make sure to pick only a mass range that is covered by your models
M_sec ~ LogUniform(0.55, 65) # MJup
M = system.M_pri + system.M_sec*Octofitter.mjup2msol # Msol
plx ~ gaia_plx(gaia_id=6166183842771027328)
# Priors on the center of mass proper motion
pmra ~ Normal(0, 1000)
pmdec ~ Normal(0,  1000)
rel_mag = 5.65
end HGCALikelihood(gaia_id=6166183842771027328) B
model_both = Octofitter.LogDensityModel(HD91312_both)

using Pigeons
chain_both, pt = octofit_pigeons(model_both,n_chains=5,n_chains_variational=5,n_rounds=10)
(chain = MCMC chain (1024×25×1 Array{Float64, 3}), pt = PT(checkpoint = false, ...))

Compare all three posteriors to see limits:

vis_layers = (
PairPlots.Contour(sigmas=[1,3]),
PairPlots.MarginStepHist(),
)
pairplot(
PairPlots.Series(
(;
sma=log.(chain_pma[:B_a][:],),
mass=log.(chain_pma[:B_mass][:]),
),
label="PMA",
color=Makie.wong_colors()[1],
)=>vis_layers,
PairPlots.Series(
(;
sma=log.(chain_img[:B_a][:],),
mass=log.(chain_img[:B_mass][:]),
),
label="IMG",
color=Makie.wong_colors()[2],
)=>vis_layers,
PairPlots.Series(
(;
sma=log.(chain_both[:B_a][:],),
mass=log.(chain_both[:B_mass][:]),
),
label="IMG + PMA",
color=Makie.wong_colors()[3],
)=>vis_layers,
labels=Dict(
:sma=>"log₂ Semi-major axis [au]",
:mass=>"log₂ Mass [Mⱼᵤₚ]"
)
)