Getting started with harv¶
harv is a Python package for inferring the orbital parameters of a star with an unseen companion (e.g., another star, a brown dwarf, a planet, or a compact object) from radial velocities (RVs), Gaia epoch astrometry, or both. It is a successor to and a full reimplementation of The Joker, built on JAX, NumPyro, and unxt.
harv is designed for population studies of stellar companions. Instead of only using
the systems with a confident detection, a population inference can include every source
in a survey, as long as we have posterior samples of the orbital parameters for each
source. Many of these sources will have only a few RV measurements or low
signal-to-noise astrometry, and in these cases the posterior pdf over the orbital
parameters is often highly multimodal in period. MCMC and most other sampling methods
struggle in this regime. harv provides a custom rejection sampler that returns
independent posterior samples even for highly multimodal or structured posterior pdfs.
A typical analysis with harv has the same steps for any data format: we store the data
in a data container, choose a model, set up a prior, run the rejection sampler, and, if
needed, continue with MCMC or another sampler. This tutorial introduces each of these
pieces, but we do not go into much detail about modeling data here — this is meant as a
high-level overview of the package. The radial velocity and Gaia astrometry tutorials run the sampler on real data, and the harv
paper (arXiv:2611.35085) describes the methods in
more detail.
Let’s start with the imports we’ll need. We first turn on double precision in JAX, for reasons we explain below:
import jax
jax.config.update("jax_enable_x64", True)
import numpyro.distributions as dist
import quaxed.numpy as jnp
from unxt import Q
import harv
import harv.models as hm
from harv.models.parameterizations import ThieleInnesGaiaAstrometry
/home/runner/work/harv/harv/.venv/lib/python3.14/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
from .autonotebook import tqdm as notebook_tqdm
1. Data, units, and JAX¶
harv is built on JAX, so the model code can be compiled with jax.jit, vectorized
with jax.vmap, and run on CPUs or GPUs. Unlike most packages in the JAX ecosystem,
harv requires double precision (float64) because the likelihoods are not accurate in
single precision. That is why we enabled jax_enable_x64 above before importing harv.
If you do not, harv enables it on import and will output a warning.
harv is also units-aware through the unxt package.
Data, parameters, priors, and samples are unxt.Quantity objects, which are like the
more familiar astropy.units.Quantity but work with JAX transformations. It is standard
to use the short alias Q for unxt.Quantity, which we do below. Since jax.numpy
doesn’t know how to handle quantities, we use quaxed.numpy (imported as jnp) for any
math with these objects. The sharp bits page covers the
conventions and pitfalls of working with JAX, NumPyro, and unxt in more detail.
Each data format has its own container. For RV data, RVData stores the
observation times, the measured velocities, and their uncertainties. We assume that the
times are barycentric and that the noise is Gaussian with known variances (though we can
relax the second assumption, see Section 7). Here we make an RV data set with five
observations:
rv_data = harv.RVData(
time=Q([56000.0, 56100.0, 56250.0, 56400.0, 56600.0], "day"),
rv=Q([12.3, -8.7, 5.1, -14.2, 10.8], "km/s"),
rv_err=Q([1.2, 0.9, 1.1, 0.8, 1.0], "km/s"),
)
rv_data
RVData(
time=Quantity(f64[5], unit='d'),
time_ref=Quantity(weak_f64[], unit='d'),
rv=Quantity(f64[5], unit='km / s'),
rv_err=Quantity(f64[5], unit='km / s')
)
The container also sets a reference time time_ref, which by default is the mean of the
observation times. The orbital phase is measured relative to this time.
For Gaia epoch astrometry, GaiaAstrometryData stores the times, the
one-dimensional along-scan positions and their uncertainties, and, for each transit, the
scan angle and the along-scan parallax factor:
astro_data = harv.GaiaAstrometryData(
time=Q([958.111, 994.911, 995.087, 1010.091, 1076.919], "day"),
al_position=Q([147.066, 379.996, 378.656, 74.666, -293.923], "mas"),
al_position_err=Q([0.370, 0.446, 0.428, 0.270, 0.247], "mas"),
scan_angle=Q([-59.047, -5.114, -5.783, -68.579, -134.155], "deg"),
parallax_factor=jnp.array([0.70828, -0.46657, -0.45946, 0.19659, -0.21379]),
)
astro_data
GaiaAstrometryData(
time=Quantity(f64[5], unit='d'),
time_ref=Quantity(weak_f64[], unit='d'),
al_position=Quantity(f64[5], unit='mas'),
al_position_err=Quantity(f64[5], unit='mas'),
scan_angle=Quantity(f64[5], unit='deg'),
parallax_factor=f64[5]
)
When we have more than one data set for a system, we can combine them in a shared
container. A SourceData holds several data sets for one star (e.g.,
RVs from two instruments, or RVs and astrometry), and a
SystemData holds data for different bodies in the same system
(e.g., the RVs of both stars in a double-lined binary). We come back to these in Section
8.
2. Models and parameterizations¶
Much of the design of harv follows from one property of Keplerian models: the
prediction for the data is a nonlinear function of some of the parameters and a linear
function of the others. For a source with \(N\) measurements \(\boldsymbol{y}\), we can
write
where \(\boldsymbol{\theta}\) are the nonlinear parameters, \(\boldsymbol{\beta}\) are the \(Q\) linear parameters, and the \(N \times Q\) design matrix \(\mathsf{X}\) depends on the nonlinear parameters. For example, the standard parameterization of the RV model is
where \(v_0\) is the systemic velocity, \(K\) is the velocity semi-amplitude, \(\omega\) is
the argument of pericenter, and the true anomaly \(f\) depends on time through the period
\(P\), the eccentricity \(e\), and the orbital phase \(\tau\) (the time of pericenter passage
relative to time_ref, in units of the period). The prediction is nonlinear in \((P, e,
\tau, \omega)\) and linear in \(K\) and \(v_0\). For Gaia astrometry, the along-scan
position is the sum of the standard five-parameter astrometric model (two position
offsets, two proper motion components, and the parallax) and the orbit of the
photocenter. This prediction is linear in the five astrometric parameters, and also in
the angular semi-major axis of the photocenter orbit \(a_0\) if the orientation of the
orbit is fixed.
In harv, a parameterization specifies the names and units of the parameters of a
model, which of them are linear, how to compute the design matrix from the nonlinear
parameters, and a default prior. There are several parameterizations for each type of
data. For example, the Thiele-Innes parameterization of the astrometric orbit combines
\(a_0\) and the three orientation angles into four constants that enter the model
linearly, and the Fourier parameterizations replace the Keplerian orbit with a truncated
Fourier series so that the period is the only nonlinear parameter. Let’s print the
nonlinear and linear parameters of each parameterization:
parameterizations = [
hm.StandardRV(),
hm.SqrtEccRV(),
hm.FourierRV(),
hm.StandardGaiaAstrometry(),
ThieleInnesGaiaAstrometry(),
hm.FourierGaiaAstrometry(),
]
for p in parameterizations:
print(type(p).__name__)
print(" nonlinear:", [par.name for par in p.nonlinear_params()])
print(" linear: ", [par.name for par in p.linear_params()])
StandardRV
nonlinear: ['period', 'eccentricity', 'phase_peri', 'arg_peri']
linear: ['rv_semiamp', 'v_sys']
SqrtEccRV
nonlinear: ['period', 'sqrte_cosw', 'sqrte_sinw', 'mean_longitude']
linear: ['rv_semiamp', 'v_sys']
FourierRV
nonlinear: ['period']
linear: ['cos_amp_1', 'sin_amp_1', 'cos_amp_2', 'sin_amp_2', 'v_sys']
StandardGaiaAstrometry
nonlinear: ['period', 'eccentricity', 'phase_peri', 'arg_peri', 'lon_asc_node', 'cos_i']
linear: ['ra0', 'dec0', 'pmra', 'pmdec', 'parallax', 'semi_major_axis']
ThieleInnesGaiaAstrometry
nonlinear: ['period', 'eccentricity', 'phase_peri']
linear: ['ra0', 'dec0', 'pmra', 'pmdec', 'parallax', 'ti_A', 'ti_B', 'ti_F', 'ti_G']
FourierGaiaAstrometry
nonlinear: ['period']
linear: ['ra0', 'dec0', 'pmra', 'pmdec', 'parallax', 'ti_A_1', 'ti_B_1', 'ti_F_1', 'ti_G_1', 'ti_A_2', 'ti_B_2', 'ti_F_2', 'ti_G_2']
A model combines a parameterization with any extensions to the model (see Section 7).
The models for the two data types are RVModel and
GaiaAstrometryModel, which use the standard parameterizations by
default. For example, harv.RVModel(parameterization=hm.SqrtEccRV()) is an RV model that
samples in \(\sqrt{e}\cos\omega\) and \(\sqrt{e}\sin\omega\) instead of \(e\) and \(\omega\). The
choice of parameterization can make a big difference to how efficiently the rejection
sampler works, which the astrometry parameterizations tutorial explores in detail.
3. Priors¶
The rejection sampler generates samples from the prior, so the prior pdf is an essential
part of the model specification in harv. Priors are NumPyro
distributions, and for parameters
with units, harv.QD attaches a unit to a distribution (e.g.,
harv.QD(dist.Normal(0.0, 10.0), "km/s")). A HarvPrior holds one
dictionary of priors for the nonlinear parameters and one for the linear parameters.
The easiest way to set up a prior is with the default_prior() method of a
parameterization. For the standard RV parameterization, the default prior is
log-uniform in period between period_min and period_max, uses a half-normal prior
for eccentricity (a normal distribution with mean 0 and standard deviation 0.5,
truncated at \(e = 1\)), is uniform in the orbital phase and the argument of pericenter,
and puts Gaussian priors on the linear parameters:
prior = hm.StandardRV().default_prior(
period_min=Q(1.0, "day"),
period_max=Q(1000.0, "day"),
sigma_K0=Q(30.0, "km/s"),
sigma_v0=Q(50.0, "km/s"),
)
print(prior.nonlinear_priors.keys())
print(prior.linear_priors.keys())
dict_keys(['period', 'eccentricity', 'phase_peri', 'arg_peri'])
dict_keys(['rv_semiamp', 'v_sys'])
Any of these can be replaced by passing a distribution as a keyword argument with the
parameter name (e.g., eccentricity=dist.Uniform(0.0, 1.0)), or by building a
HarvPrior directly, as we show in the prior customization tutorial.
The default priors on the linear parameters depend on the nonlinear parameters. A Gaussian prior on \(K\) with the same width at all periods would imply a prior on the companion mass that changes with period, which is probably not what we believe. Instead, the default prior on \(K\) has a variance
which, at fixed primary mass, is fixed in companion mass. Here sigma_K0 sets
\(\sigma_{K,0}\) and period_ref sets the reference period \(P_0\) (1 year by default). We
use the same idea for astrometry. The default priors on \(a_0\) and on the proper motion
components have widths
so that they are fixed in the physical size of the orbit and in tangential velocity. These widths depend on the parallax \(\varpi\), which has consequences that we describe in the next section.
4. Marginalizing over the linear parameters¶
The main trick that makes rejection sampling practical for orbit fitting is that we do not have to sample the linear parameters. If the noise is Gaussian with covariance matrix \(\mathsf{C}\), and the prior on the linear parameters is also Gaussian, \(p(\boldsymbol{\beta} \mid \boldsymbol{\theta}) = \mathcal{N}(\boldsymbol{\beta} \mid \boldsymbol{\mu}, \mathsf{\Lambda})\) (where the mean and covariance can depend on \(\boldsymbol{\theta}\)), then the integral over \(\boldsymbol{\beta}\) can be done analytically. The result is the marginal likelihood
which only depends on the nonlinear parameters. The conditional posterior pdf of the linear parameters, \(p(\boldsymbol{\beta} \mid \boldsymbol{y}, \boldsymbol{\theta})\), is also Gaussian, so once we have samples of \(\boldsymbol{\theta}\), we can draw the linear parameters directly. For the standard RV model, this reduces the number of sampled parameters from six to four, and for the standard astrometric model from twelve to six.
The priors that harv can marginalize over are the Gaussian family read broadly: a
normal distribution, a truncated normal distribution (including HalfNormal, so any
positivity or sign constraint, for up to two truncated parameters), or a mixture of these
that share the same support. A linear parameter with any other prior (e.g., a Uniform
or a Gamma) is allowed, but it is then sampled along with the nonlinear parameters. The
summary() method of the sampler shows how it will treat
each parameter before we run anything. With the default RV prior, both linear parameters
are marginalized:
sampler = harv.RejectionSampler(prior, harv.RVModel())
print(sampler.summary())
============================================================
RejectionSampler
============================================================
model RVModel
parameterization StandardRV
extensions (none)
parameters 4 sampled, 2 marginalized
Nonlinear parameters (sampled)
name prior unit
period LogUniform d
eccentricity TwoSidedTruncatedDistribution -
phase_peri Uniform -
arg_peri Uniform rad
Linear parameters
name status prior unit
rv_semiamp marginalized PeriodDependentKPrior -
v_sys marginalized Normal km / s
status legend: marginalized = integrated out analytically;
sampled = drawn explicitly (prior cannot be marginalized);
sampled (read by prior) = marginalizable, but another prior's callable reads its value
sampled (could marg.) = marginalizable but excluded via marginalized_names
If we instead use a uniform prior on the systemic velocity, v_sys moves to the sampled
parameters:
uniform_vsys_prior = hm.StandardRV().default_prior(
period_min=Q(1.0, "day"),
period_max=Q(1000.0, "day"),
sigma_K0=Q(30.0, "km/s"),
v_sys=harv.QD(dist.Uniform(-100.0, 100.0), "km/s"),
)
print(harv.RejectionSampler(uniform_vsys_prior, harv.RVModel()).summary())
============================================================
RejectionSampler
============================================================
model RVModel
parameterization StandardRV
extensions (none)
parameters 5 sampled, 1 marginalized
Nonlinear parameters (sampled)
name prior unit
period LogUniform d
eccentricity TwoSidedTruncatedDistribution -
phase_peri Uniform -
arg_peri Uniform rad
Linear parameters
name status prior unit
rv_semiamp marginalized PeriodDependentKPrior -
v_sys sampled Uniform km/s
status legend: marginalized = integrated out analytically;
sampled = drawn explicitly (prior cannot be marginalized);
sampled (read by prior) = marginalizable, but another prior's callable reads its value
sampled (could marg.) = marginalizable but excluded via marginalized_names
Being marginalizable is not quite the same as being marginalized. A linear parameter whose
value is read by another parameter’s prior has to be sampled explicitly, because a
marginalized parameter has no sampled value to read. This is the case for the parallax
in the default Gaia prior: the priors on \(a_0\) and on the proper motion both depend on
it, so the parallax is sampled even though its HalfNormal prior could be
marginalized:
astro_prior_kwargs = {
"period_min": Q(10.0, "day"),
"period_max": Q(3000.0, "day"),
"sigma_a0": Q(1.0, "au"),
"sigma_parallax": Q(1.0, "mas"),
"sigma_pos": Q(1.0, "mas"),
"sigma_vtan": Q(30.0, "km/s"),
}
astro_prior = hm.StandardGaiaAstrometry().default_prior(**astro_prior_kwargs)
print(harv.RejectionSampler(astro_prior, harv.GaiaAstrometryModel()).summary())
============================================================
RejectionSampler
============================================================
model GaiaAstrometryModel
parameterization StandardGaiaAstrometry
extensions (none)
parameters 7 sampled, 5 marginalized
Nonlinear parameters (sampled)
name prior unit
period LogUniform d
eccentricity TwoSidedTruncatedDistribution -
phase_peri Uniform -
cos_i Uniform -
arg_peri Uniform rad
lon_asc_node Uniform rad
Linear parameters
name status prior unit
ra0 marginalized Normal mas
dec0 marginalized Normal mas
pmra marginalized ParallaxDependentProperMotionPrior -
pmdec marginalized ParallaxDependentProperMotionPrior -
parallax sampled (read by prior) HalfNormal mas
semi_major_axis marginalized PeriodDependentSemiMajorAxisPrior -
status legend: marginalized = integrated out analytically;
sampled = drawn explicitly (prior cannot be marginalized);
sampled (read by prior) = marginalizable, but another prior's callable reads its value
sampled (could marg.) = marginalizable but excluded via marginalized_names
Sampling the parallax lowers the efficiency of the rejection sampler for every source,
because the parallax is usually measured much more precisely than the width of its
prior. For a star with a well-measured parallax (say, better than 10%), we can instead
pass scale_parallax (e.g., the catalog parallax) to compute the prior widths from that
fixed value. The parallax is then marginalized like the other linear parameters, and the
sampler has one less dimension to explore:
astro_prior_fixed = hm.StandardGaiaAstrometry().default_prior(
**astro_prior_kwargs, scale_parallax=Q(1.0, "mas")
)
print(harv.RejectionSampler(astro_prior_fixed, harv.GaiaAstrometryModel()).summary())
============================================================
RejectionSampler
============================================================
model GaiaAstrometryModel
parameterization StandardGaiaAstrometry
extensions (none)
parameters 6 sampled, 6 marginalized
Nonlinear parameters (sampled)
name prior unit
period LogUniform d
eccentricity TwoSidedTruncatedDistribution -
phase_peri Uniform -
cos_i Uniform -
arg_peri Uniform rad
lon_asc_node Uniform rad
Linear parameters
name status prior unit
ra0 marginalized Normal mas
dec0 marginalized Normal mas
pmra marginalized ParallaxDependentProperMotionPrior -
pmdec marginalized ParallaxDependentProperMotionPrior -
parallax marginalized HalfNormal mas
semi_major_axis marginalized PeriodDependentSemiMajorAxisPrior -
status legend: marginalized = integrated out analytically;
sampled = drawn explicitly (prior cannot be marginalized);
sampled (read by prior) = marginalizable, but another prior's callable reads its value
sampled (could marg.) = marginalizable but excluded via marginalized_names
The posterior parallax should still be compared with the value passed in, and if the two
differ by more than a few percent, the fit can be rerun with the posterior value. We can
also choose to sample a marginalizable parameter explicitly by passing
marginalized_names to the sampler (see the prior customization tutorial). The harv paper derives how the truncated and mixture cases are
computed.
5. The rejection sampler¶
With the linear parameters marginalized, the rejection sampler follows the same algorithm as The Joker:
Generate \(J\) samples from the prior over the nonlinear parameters (and over any linear parameters that are sampled explicitly).
Evaluate the marginal likelihood for each sample.
Find the maximum marginal likelihood across all of the samples.
For each sample, draw a random number uniformly between zero and that maximum, and reject the sample if its marginal likelihood is smaller.
For each sample that survives, draw the linear parameters from their conditional posterior pdf.
The surviving samples are, by construction, independent samples from the posterior,
however many modes it has. There is no burn-in, no tuning, and no need to assess the
convergence of chains as with MCMC. Most of the computation is spent evaluating the
marginal likelihood for samples that are then rejected, but these evaluations are
independent of each other, so harv vectorizes them with JAX and they parallelize easily
across CPU cores or GPUs.
In code, we create a RejectionSampler from a prior and a model (as we
did above), and then run it on data with a number of prior samples \(J\) and a random
number key:
samples = sampler.run(
rv_data,
n_prior_samples=10_000_000,
max_posterior_samples=1024,
key=jax.random.key(42),
return_evidence_stats=True,
)
The RV getting started tutorial runs the sampler this way for a real star.
The cost of the rejection sampler depends on how informative the data are. The posterior
roughly occupies a fraction \(e^{-\mathcal{H}}\) of the prior volume, where \(\mathcal{H}\)
is the information gain (the Kullback-Leibler divergence of the posterior from the
prior), so the number of prior samples needed to resolve the posterior grows
exponentially with \(\mathcal{H}\). Rejection sampling is therefore efficient for sparse,
noisy, or low signal-to-noise data, where other samplers struggle, but it becomes
expensive for very informative data. With return_evidence_stats=True, the returned
samples include an estimate of the evidence and the effective sample size of the
importance weights over all of the prior samples, which is roughly the number of
independent posterior samples that the prior samples represent.
acceptance_diagnostics() uses these to report whether a
run resolved the posterior.
In practice, there are three typical outcomes:
Many samples survive and the effective sample size is large. The samples represent the posterior well, and we are done. This is typical for sparse or noisy data.
Few samples survive (often just one), and they are all near the same period. The posterior is probably unimodal but much narrower than the spacing between prior samples, so we can use the returned samples to initialize MCMC (see Section 8). This is typical for data with a high signal-to-noise ratio.
Few samples survive and they span a range of periods. The posterior has narrow, well-separated modes, and we need many more prior samples or a different method (e.g., nested sampling).
When only a few samples survive, the maximum marginal likelihood that the sampler found can be much lower than the true peak, so the returned samples may not be in the dominant mode. Two useful checks are to rerun with many more prior samples (e.g., ten times as many) to see whether the maximum likelihood or the returned period changes, and to check the goodness of fit of the maximum a posteriori sample after continuing with MCMC.
6. Working with the returned samples¶
The returned Samples object behaves like a dictionary of
Quantity arrays keyed by parameter name (e.g., samples["period"]), and it has
methods for plotting and summarizing the samples. Because the default Gaussian prior on
\(K\) (or \(a_0\)) is symmetric about zero, the samples include negative amplitudes, which are
equivalent to positive amplitudes with the argument of pericenter shifted by 180 degrees.
wrap_angles() maps the samples to positive amplitudes and
wraps the angles into a standard range.
For population studies, it is often more convenient to return the same number of samples
for every source. Passing top_k to run() instead of max_posterior_samples skips
the rejection step and returns the top_k prior samples with the largest marginal
likelihoods, along with their importance weights. These are weighted (not equal-weight)
posterior samples, and the sum of their weights is the fraction of the posterior mass
that they contain. Samples for many sources can then be combined in a hierarchical model
by reweighting them from the prior used for sampling (the “interim” prior) to a
population model, as we do in the population case study.
7. Model extensions¶
The base models assume that each source has one companion on a Keplerian orbit and that
the noise is Gaussian with known variances. Real data often violate these assumptions:
there may be offsets between instruments, the uncertainties may be underestimated, the
star or instrument may add correlated noise, or a second companion on a long-period orbit
may add a trend to the data. harv supports these cases with extensions that are added
to a model, and they come in two kinds. Extensions that add columns to the design matrix
add linear parameters, which can be marginalized like the others:
MultiSurveyOffset adds a velocity offset for each instrument, and
MonomialTrend adds a polynomial trend in time. Extensions that change
the noise model add nonlinear parameters, which must be sampled: Jitter
adds an extra variance to each measurement, and GP adds a Gaussian
process model for correlated noise.
An extension needs both a model extension and a prior for its parameters. For example, adding a jitter term to the RV model adds one sampled parameter:
jitter_prior = hm.StandardRV().default_prior(
period_min=Q(1.0, "day"),
period_max=Q(1000.0, "day"),
sigma_K0=Q(30.0, "km/s"),
sigma_v0=Q(50.0, "km/s"),
jitter=harv.QD(dist.HalfNormal(1.0), "km/s"),
)
jitter_model = harv.RVModel(extensions=(harv.Jitter(obs_unit="km/s"),))
print(harv.RejectionSampler(jitter_prior, jitter_model).summary())
============================================================
RejectionSampler
============================================================
model RVModel
parameterization StandardRV
extensions Jitter(km/s)
parameters 5 sampled, 2 marginalized
Nonlinear parameters (sampled)
name prior unit
period LogUniform d
eccentricity TwoSidedTruncatedDistribution -
phase_peri Uniform -
arg_peri Uniform rad
jitter (ext) HalfNormal km/s
Linear parameters
name status prior unit
rv_semiamp marginalized PeriodDependentKPrior -
v_sys marginalized Normal km / s
status legend: marginalized = integrated out analytically;
sampled = drawn explicitly (prior cannot be marginalized);
sampled (read by prior) = marginalizable, but another prior's callable reads its value
sampled (could marg.) = marginalizable but excluded via marginalized_names
The model extensions tutorial and the Gaussian process tutorial demonstrate these extensions on real data.
8. MCMC, other inference methods, and joint models¶
harv models are built on NumPyro, so the rejection sampler is not the only way to
generate posterior samples. NumpyroSampler builds a NumPyro model from
the same prior, model, and extensions, with the marginal likelihood entering as a factor
in the model, and runs MCMC with the No-U-Turn Sampler by default. This is the natural
next step when the rejection sampler returns only a few samples in a single mode, and we
can initialize the chains from those samples:
mcmc_sampler = harv.NumpyroSampler(prior, harv.RVModel())
mcmc_samples = mcmc_sampler.run(
rv_data, key=jax.random.key(0), init_samples=samples.wrap_angles()
)
Here wrap_angles() starts every chain on the same side of the \(K \to -K\) degeneracy
(see the sharp bits page). The MCMC tutorial walks through this in detail. Because the log density of a harv
model is a JAX function, it can also be passed to inference libraries outside of NumPyro.
The nested sampling case study runs a nested
sampler from blackjax on a harv model, which is a better choice than rejection
sampling for very informative data.
Finally, harv can model several data sets for the same system together.
JointModel combines component models that share the nonlinear orbital
parameters, with constructors for the most common cases. JointModel.for_sb2() is for
double-lined spectroscopic binaries, where each star has its own RVs, and
JointModel.for_rv_and_gaia() is for RVs and Gaia astrometry of the same star, where
by default the RV semi-amplitude is tied to the astrometric orbit. See the SB2 tutorial and the Gaia-4 case study for
examples.
Next steps¶
From here, we recommend working through the tutorials for your type of data. The
radial velocity tutorials start with an analysis of sparse APOGEE RVs, and see the Gaia astrometry tutorials for info on modeling Gaia data. The case studies apply harv to more complex problems, Running harv at scale has
guidance for running harv on large samples of sources, and the API documentation documents every class and function.