Companions and Orbits

FunctionDescription
companion_search(model_dict, data; companion, free, ...)Grid search for a companion around any primary model (including an image): the companion fitted at every node, a χ² map, the best node and its significance
companion_grid(model_dict, data; companion, step, rmin, rmax, mask)The grid companion_search uses, and its number of nodes
companion_flux_map(search)The companion's fitted flux at every node
detection_sigma(chi2r_null, chi2r_best, ndof)CANDID's significance convention: the null model's χ² against a χ² distribution, as Gaussian σ

With only the companion's flux free (CANDID's chi2Map), the model is linear in it and each node is a 1-D fit (BraDi, or Halley with a BraDi fallback). With other parameters free (the primary's diameter, a companion diameter), each node runs VMLMB with bounds. The default grid step is λ/(2Bmax), out to the smearing radius Rλ/(2Bmax); an image primary's bright pixels are masked. Bandwidth smearing follows the model's "smear".

OITOOLS.companion_search — Function
companion_search(model_dict, data; companion = "comp", free = [companion * ",f"],
                 lb = Dict(), ub = Dict(), fmax = 0.5,
                 step = nothing, rmin = nothing, rmax = nothing, mask = 0.01,
                 weights = [1, 1, 1], solver = :bradi, path = :auto, refine = 0,
                 threads = true, on_grid = nothing) -> CompanionSearch

Search for a companion around the model's primary: the companion is fitted at each node of a grid of positions, with its position fixed there. Returns the χ² map, the best node and its significance against the model without a companion.

The model is the primary plus a component companion with keys companion,f, companion,x and companion,y (x and y are set by the grid). The primary's flux is written as 1 - $companion,f. A point companion is a component with no shape key; give it ud (and free it) for a resolved one. Bandwidth smearing follows the model's "smear" setting.

Free at each node: free, which must include companion,f, bounded to [0, fmax].

  • Only companion,f free, and no spectral lines on the companion: the fast path, the other parameters fixed at the dict's values (fit the primary alone first).
  • Otherwise: the general path, VMLMB with lb/ub (defaults from default_bounds).

The grid (defaults from the data):

  • step λ/(2 Bmax), half of PMOIRED's λ/Bmax;
  • rmax R λ/(2 B_max), the bandwidth-smearing radius, when the data have channel widths;
  • rmin the extent of the primary's analytic components (offset plus radius), at least step;
  • mask: nodes where the primary's image components, convolved with a beam of FWHM λ/B_max, exceed mask times their peak, are not searched. 0 turns it off.

solver (fast path): :bradi, a global 1-D minimisation on [0, fmax] (OptimPackNextGen's BraDi), or :halley, Halley's method from the best of a coarse sampling, falling back to BraDi at any node where it does not converge in the bounds.

weights are those of model_to_chi2; the fast path takes V², T3amp, T3φ, VISAMP and VISPHI.

path = :general uses VMLMB even when only the flux is free.

refine: after the grid, the refine best local minima of the map (nodes no worse than any searched neighbour) are each fitted again with fit_model_lsqfit, the companion's position free as well as free: x and y within [-rmax, rmax], the flux within [0, fmax], the rest within lb/ub or default_bounds. Minima that converge within half a step of a better one are merged. When lower than the best node, the best refined minimum gives best, fit and nsigma, with LM's σ; the map is unchanged. 0 (default): no refinement.

on_grid is called before any node is fitted, with (; x, y, chi2r, params, nnodes): the axes and the arrays the search fills node by node (NaN until done), written by the search's threads while the caller reads them.

source
OITOOLS.companion_grid — Function
companion_grid(model_dict, data; companion = "comp", step = nothing, rmin = nothing,
               rmax = nothing, mask = 0.01) -> NamedTuple

The grid companion_search searches, with the same defaults, without searching it: (; x, y, nodes, step, rmin, rmax), where nodes are the (i, j) indices into x and y of the nodes that will be fitted (inside the radius range, outside the mask).

source
OITOOLS.CompanionSearch — Type
CompanionSearch

What companion_search returns.

fieldmeaning
x, ythe grid axes, mas (x East, y North)
chi2r(length(x), length(y)), reduced χ² at each node; NaN where not searched
params(length(free), length(x), length(y)), the free parameters fitted at each node
freetheir names, companion,f among them
companionthe companion component's name
bestthe best node: (x, y, sep, pa, f, dmag, chi2r, params); pa in degrees East of North, dmag = −2.5 log₁₀(f/(1−f)); the best refined minimum when the search refined
chi2r_nullreduced χ² of the model without the companion (f = 0)
nsigmathe best node's significance against it (CANDID's convention)
ndofthe degrees of freedom the significance uses: data points − 1
fita FitResult for the best node, the companion's position fixed; with refinement, the best refined minimum's LsqFitResult, the position among its free parameters
path:fast or :general
solverthe 1-D solver of the fast path (:bradi or :halley), :vmlmb for the general path
fallbacksnodes where Halley did not converge and BraDi was used instead
nnodes, secondshow many nodes were fitted, and how long it took
refinedthe refined minima, best first: (x, y, sep, pa, f, dmag, chi2r, params, stderror, start), where params are the free parameters, stderror LM's σ for them then x and y, and start the node it started from; empty without refinement
source
OITOOLS.detection_sigma — Function
detection_sigma(chi2r_null, chi2r_best, ndof) -> Float64

How many σ the better model is preferred by, as CANDID (Gallenne et al. 2015) computes it: the best model is taken to describe the data (its χ²ᵣ rescaled to 1), the χ² of the null model is then ndof · χ²ᵣ,null / χ²ᵣ,best, and its probability under a χ² distribution with ndof degrees of freedom is converted to the equivalent number of Gaussian σ. It assumes the error bars are correct up to a common factor.

source

Orbits and radial velocities

A component on an orbit takes PMOIRED's keys and PMOIRED's definition (_orbit): "c,x" = "c,y" = "orbit", with the elements c,orb P (days), MJD0 (periastron, MJD), e, omega, OMEGA, incl (degrees) and a (mas), or M (M☉) and plx (mas) in place of a. The position is computed in Float64 at each data point's MJD, once per epoch. ω is the secondary's, relative to the primary (orbitize!'s convention, 180° from Gallenne et al. 2023's). Each element can be fixed, free or an expression.

Radial velocities (read_rv, a CSV MJD,RV,sigma,star with star a or b) are fitted with the interferometry by fit_model_lsqfit(…; rv), fit_model(…; rv) and bootstrap_fit(…; rv), with the velocity elements c,orb Ka, Kb, gamma, or M and q (= Mb/Ma) with incl. chi2 and ndof count them; chi2_rv is their part.

m = Dict{String,Any}("1,ud" => 0.2, "2,f" => 0.37, "2,x" => "orbit", "2,y" => "orbit",
                     "2,orb P" => 42.38, "2,orb MJD0" => 59785.45, "2,orb e" => 0.623,
                     "2,orb omega" => 114.1, "2,orb OMEGA" => 77.4, "2,orb incl" => 71.0,
                     "2,orb a" => 3.75, "2,orb Ka" => 50.3, "2,orb Kb" => 58.8, "2,orb gamma" => 14.9)
rv = read_rv("demos/data/HD210763/rv_gallenne2023.csv")
r  = fit_model_lsqfit(m, ["2,orb e", "2,orb a", "2,orb Ka", "2,orb Kb", "2,orb gamma"], data; rv)
FunctionDescription
orbit_x(t, P, MJD0, e, omega, OMEGA, incl, a), orbit_y(…)The secondary's offset East and North (mas) at MJD t
orbit_rv(t, star, P, MJD0, e, omega, K, gamma)A star's radial velocity (km/s)
orbit_a(P, M, plx), orbit_semiamplitudes(P, e, incl, M, q)Kepler's third law: the semi-major axis, and Ka, Kb
kepler_E(M, e)The eccentric anomaly, with derivatives for dual numbers
read_rv(path), RVDataRadial velocities from a CSV table
OITOOLS.orbit_x — Function
orbit_x(t, P, MJD0, e, omega, OMEGA, incl, a)
orbit_y(t, P, MJD0, e, omega, OMEGA, incl, a)

The secondary's offset from the primary (mas, x East, y North) at time t (MJD), for a period P (days), periastron MJD0, eccentricity e, omega, OMEGA, incl (degrees) and semi-major axis a (mas), as PMOIRED's _orbit. A component with c,x = c,y = "orbit" is placed there.

source
OITOOLS.orbit_rv — Function
orbit_rv(t, star, P, MJD0, e, omega, K, gamma; gamma_d = 0) -> km/s

The radial velocity of the primary (star = :a, semi-amplitude K = Ka) or the secondary (:b, Kb) at time t (MJD), PMOIRED's: VA = γ − Ka[cos(ω + ν) + e cos ω], VB = γ + Kb[cos(ω + ν) + e cos ω], plus gamma_d·(t − MJD0).

source
OITOOLS.orbit_a — Function
orbit_a(P, M, plx) -> mas

The apparent semi-major axis from the total mass M (M☉), the parallax plx (mas) and the period P (days), by Kepler's third law: a = plx · (M (P/365.25)²)^(1/3).

source
OITOOLS.orbit_semiamplitudes — Function
orbit_semiamplitudes(P, e, incl, M, q) -> (Ka, Kb)

The velocity semi-amplitudes (km/s) from the total mass M (M☉) and the mass ratio q = Mb/Ma, by Kepler's third law (PMOIRED's): K = 2π a sin i / (P √(1 − e²)) with a in km, Ka = K/(1 + 1/q), Kb = K/(1 + q).

source
OITOOLS.kepler_E — Function
kepler_E(M, e) -> E

The eccentric anomaly solving E − e sin E = M (radians, 0 ≤ e < 1): Newton's method in Float64, then one Newton step in the arguments' type, which gives the derivatives of dual numbers.

source
OITOOLS.read_rv — Function
read_rv(path) -> RVData

A CSV table of radial velocities with the header MJD,RV,sigma,star: time (MJD), velocity and its error (km/s, positive receding), and the star, a (primary) or b (secondary). Lines starting with # are comments.

source
OITOOLS.RVData — Type
RVData

Radial velocities: mjd, rv and sigma (km/s), and star — :a (the primary, at the origin) or :b (the secondary, the component on an orbit) — one entry per measurement.

source