Priors Module (brutus.priors)¶
brutus.priors implements the astrophysical prior probability distributions used by BruteForce to break degeneracies between stellar luminosity, distance, and dust reddening.
Role in Inference:
Because broadband photometry alone often permits both a nearby cool dwarf and a distant reddened giant, brutus incorporates prior distributions over:
Stellar Mass and Luminosity: Kroupa initial mass function (
logp_imf) and Pan-STARRS \(r\)-band luminosity function (logp_ps1_luminosity_function).Galactic Structure: Thin-disk, thick-disk, halo, and bar number density, metallicity, and age distributions (
logp_galactic_structure,galactic_prior_summary,logn_disk,logn_halo).Kinematics: Velocity moments of the Galactic components, projected to proper motions and radial velocity (
thin_disk_velocity_moments,velocity_to_observables).Interstellar Extinction: Truncated Gaussian \(A_V\) prior from 3D dust maps (
logp_extinction).
It also provides the Gaussian likelihood of a measured parallax (logp_parallax).
Typical Usage:
Priors are evaluated automatically inside BruteForce.fit, and can also be called directly:
from brutus.priors.stellar import logp_imf
from brutus.priors.galactic import logp_galactic_structure
from brutus.priors.extinction import logp_extinction
from brutus.dust import Bayestar
import numpy as np
# Evaluate IMF prior for a range of initial masses (in Msun)
masses = np.array([0.5, 1.0, 2.0, 5.0])
log_prior_imf = logp_imf(masses)
# Evaluate Galactic structure prior along a sightline
distances = np.array([0.1, 0.5, 1.0, 5.0]) # kpc
gal_l, gal_b = 45.0, 10.0 # Galactic coordinates (deg)
log_prior_gal = logp_galactic_structure(distances, (gal_l, gal_b))
# Evaluate extinction prior from a 3D dust map
dustmap = Bayestar()
av_values = np.array([0.1, 0.5, 1.0, 2.0]) # mag
log_prior_dust = logp_extinction(
av_values, dustmap, (gal_l, gal_b), distance=distances
)
Customization:
Pass custom callables to BruteForce.fit to replace or disable specific priors. The Galactic structure prior is supplied via lngalprior(dist, coord, labels=...), where coord is a (l, b) tuple in degrees:
from brutus.analysis import BruteForce
fitter = BruteForce(grid)
# Replace the Galactic structure prior with a flat log-prior in distance
fitter.fit(
data=flux, data_err=flux_err, data_mask=mask,
data_labels=obj_ids, save_file="results.h5",
data_coords=coords,
lngalprior=lambda dist, coord, labels=None: np.zeros_like(dist, dtype=float),
)
See Also:
Priors - Detailed conceptual guide to all prior distributions
How brutus works - How priors fit into the Bayesian framework
Stellar Priors¶
- brutus.priors.logp_imf(mgrid, alpha_low=1.3, alpha_high=2.3, mass_break=0.5, mgrid2=None, mass_min=0.08, mass_max=100.0)[source]¶
Compute the log-prior for a Kroupa-like broken power-law initial mass function.
Evaluates a two-part power-law IMF following Kroupa (2001), with optional independent draws for a binary companion.
- Parameters:
mgrid (array_like) – Initial stellar masses in solar masses (\(M_\odot\)).
alpha_low (float, optional) – Power-law slope for
mgrid <= mass_break. Default is 1.3.alpha_high (float, optional) – Power-law slope for
mgrid > mass_break. Default is 2.3.mass_break (float, optional) – Transition mass between the low- and high-mass regimes in \(M_\odot\). Default is 0.5.
mgrid2 (array_like, optional) – Secondary stellar masses for binary systems in \(M_\odot\), broadcastable with
mgrid.mass_min (float, optional) – Minimum mass for normalization in \(M_\odot\). Default is 0.08.
mass_max (float, optional) – Maximum mass for normalization in \(M_\odot\). May be
np.infwhenalpha_high > 1. Default is 100.0.
- Returns:
logp – Normalized log-prior density (per \(M_\odot\), or per \(M_\odot^2\) when
mgrid2is given) with the shape ofmgrid. Masses outside[mass_min, mass_max]receiveLOG_ZERO(-1e300).- Return type:
- Raises:
ValueError – If
mass_minormass_breakis not finite and positive, ifmass_maxdoes not exceedmass_min, or if a slope is not finite.
See also
logp_ps1_luminosity_functionAlternative luminosity-based prior
brutus.analysis.individual.BruteForceUses IMF priors for fitting
Notes
The IMF follows the form:
\[\xi(M) \propto M^{-\alpha}\]where α = α_low for M ≤ M_break and α = α_high for M > M_break.
For binary systems, assumes independent sampling from the same IMF for both components.
References
Kroupa, P. (2001), MNRAS, 322, 231
- brutus.priors.logp_ps1_luminosity_function(Mr)[source]¶
Evaluate the Pan-STARRS 1 r-band luminosity function log-prior.
Interpolates the empirical stellar luminosity function tabulated for Pan-STARRS 1 \(M_r\) in
[-1, 20]mag (Green et al. 2015, 2018) and extrapolates linearly outside that interval.- Parameters:
Mr (array_like) – Absolute \(r\)-band magnitudes in the Pan-STARRS 1 system (mag).
- Returns:
logp – Unnormalized log-prior values with the shape of
Mr(exp(logp)integrates to approximately 0.086 over the tabulated range).- Return type:
See also
logp_imfMass-based IMF prior
brutus.analysis.individual.BruteForceUses luminosity priors for fitting
References
Green, G. M., et al. (2015), ApJ, 810, 25 Green, G. M., et al. (2018), MNRAS, 478, 651
Parallax Likelihood¶
- brutus.priors.logp_parallax(parallaxes, p_meas, p_err)[source]¶
Compute the Gaussian log-likelihood of a measured parallax.
- Parameters:
- Returns:
logp – Log-likelihood density (per mas) with the shape of
parallaxes. Returns zeros whenp_measorp_erris non-finite orp_err <= 0.- Return type:
Notes
For valid measurements, the log-likelihood is
\[\log p(\pi \mid \pi_{\text{obs}}, \sigma_\pi) = -\frac{1}{2} \left[ \frac{(\pi - \pi_{\text{obs}})^2}{\sigma_\pi^2} + \log(2\pi\sigma_\pi^2) \right]\]
Galactic Structure Priors¶
- brutus.priors.logp_galactic_structure(dists, coord, labels=None, feh=None, loga=None, R_solar=8.275, Z_solar=0.0208, R_thin=2.74, Rs_thin=2.0, R_thick=1.9, f_thick_surface=0.18, Rs_thick=2.0, Rs_halo=2.0, eta_halo_inner=2.85, eta_halo_outer=4.55, r_break_halo=19.1, q_halo=0.77, halo_mass=750000000.0, bar_mass=18133000000.0, bar_angle=25.0, rho_thin_solar=0.03, thick_feh=(-0.45, 0.22, -0.5), thick_age=(13.0, -4.0, 0.8), halo_feh=(-1.18, 0.28, -0.67, -1.95, 1.0), halo_age=(12.0, 1.5), bar_feh=(0.6, -0.31, 0.31, 0.26, 0.2), bar_age=(11.0, 1.5, 8.0, 3.0), feh_systematic=(0.1, 0.15, 0.15), age_systematic=(0.1, 0.15, 0.15), age_floor=0.2, v_circ_solar=None, thick_sigma_z=43.6, pm=None, pm_cov=None, rv=None, rv_err=None, pm_outlier=0.01, pm_floor=0.0, return_components=False)[source]¶
Return the log-prior of distance, [Fe/H] and age from a model of the Galaxy.
The prior is the number density of stars with the given labels at each distance along the sightline, times the volume factor \(d^2\), summed over four components: the thin disk, the thick disk, the halo and the bar. It is relative to the thin disk at the Sun.
- Parameters:
dists (array_like) – Distance from observer in kpc, of any shape.
coord (tuple of floats or ~astropy.coordinates.SkyCoord) – Galactic coordinates (l, b) in degrees.
labels (structured array, optional) – Stellar labels with the fields ‘feh’ and/or ‘loga’, in the shape of
distsor of its trailing axes, or 1D with one entry per distance. Labels on the trailing axes broadcast across the leading ones: withdistsof shape (Ndraws, Nmodels) and labels of shape (Nmodels,), the terms of each model’s labels are computed once.feh (array_like, optional) – [Fe/H] as a float array, shaped as
labels, an alternative to the ‘feh’ field oflabelsthat takes precedence over it.loga (array_like, optional) – log10(age / yr) as a float array, shaped as
labels, an alternative to the ‘loga’ field oflabelsthat takes precedence over it.R_solar (float, optional) – Solar Galactocentric radius in kpc. Default is
R_SOLAR, 8.275 (GRAVITY Collaboration 2021).Z_solar (float, optional) – Solar height above midplane in kpc. Default is
Z_SOLAR, 0.0208 (Bennett & Bovy 2019).R_thin (float, optional) – Radial scale length of the thin-disk surface density in kpc. Default is 2.74 (Imig et al. 2025).
Rs_thin (float, optional) – Thin disk smoothing radius in kpc. Default is 2.0.
R_thick (float, optional) – Radial scale length of the thick-disk surface density in kpc. Default is 1.9 (Mackereth et al. 2017).
f_thick_surface (float, optional) – Ratio of the thick- to the thin-disk surface density at the Sun. Default is 0.18, the high-[alpha/Fe] surface mass fraction of Mackereth et al. (2017). The prior converts it to the ratio of densities at the Sun’s position with the column heights of the vertical profiles; galactic_prior_summary returns both. 0 removes the thick disk.
Rs_thick (float, optional) – Thick disk smoothing radius in kpc. Default is 2.0.
Rs_halo (float, optional) – Halo core radius in kpc. Default is 2.0.
eta_halo_inner (float, optional) – Halo slopes inside and outside the break radius in kpc. Defaults are 2.85, 4.55 and 19.1 (Amarante et al. 2024).
eta_halo_outer (float, optional) – Halo slopes inside and outside the break radius in kpc. Defaults are 2.85, 4.55 and 19.1 (Amarante et al. 2024).
r_break_halo (float, optional) – Halo slopes inside and outside the break radius in kpc. Defaults are 2.85, 4.55 and 19.1 (Amarante et al. 2024).
q_halo (float, optional) – Halo flattening. Default is 0.77 (Amarante et al. 2024).
halo_mass (float, optional) – Halo stellar mass in Msun between Galactocentric radii of 2 and 70 kpc. Default is 7.5e8, the middle of the 6.7e8 to 8.4e8 of Lane et al. (2023). 0 removes the halo.
bar_mass (float, optional) – Stellar mass of the bulge in Msun, shared by the bar and the metal-poor spheroid as
bar_feh[0]sets. Default isBAR_MASS, 1.8133e10, the integral of the tapered density of Sormani et al. (2022). 0 removes both.bar_angle (float, optional) – Angle in degrees between the long axis of the bar and the line from the Sun to the Galactic centre, with the near end at l > 0. Default is
BAR_ANGLE, 25.0.rho_thin_solar (float, optional) – Thin-disk stellar mass density at the Sun in Msun/pc^3, in living stars. Default is 0.030. With
halo_massit sets the halo to thin-disk density ratio at the Sun that galactic_prior_summary returns, and withbar_massthe bar’s amplitude.thick_feh (tuple of 3 floats, optional) – Mean, standard deviation and skewness of the skew-normal [Fe/H] distribution of the thick disk. Default is (-0.45, 0.22, -0.5): the high-[alpha/Fe] disk of Hayden et al. (2015), with its metal-poor tail.
thick_age (tuple of 3 floats, optional) – Mean age in Gyr of thick-disk stars at [Fe/H] = -1, its change in Gyr per dex of [Fe/H] above -1, and the standard deviation in Gyr of a normal truncated to 0 to 13.8 Gyr. The mean is held below [Fe/H] = -1. Default is (13.0, -4.0, 0.8), the old sequence of Xiang & Rix (2022).
halo_feh (tuple of 5 floats, optional) – The halo [Fe/H] distribution: the mean, standard deviation and skewness of a skew-normal core, the [Fe/H] below which a metal-poor tail replaces it, and the tail’s slope k, with density proportional to 10^(k [Fe/H]). Default is (-1.18, 0.28, -0.67, -1.95, 1.0): the 16th, 50th and 84th percentiles of Naidu et al. (2020), -1.48, -1.15 and -0.91, and the tail of Youakim et al. (2020).
halo_age (tuple of 2 floats, optional) – Mean and standard deviation in Gyr of the halo age, a normal truncated to 0 to 13.8 Gyr. Default is (12.0, 1.5); the width covers the spread between age methods.
bar_feh (tuple of 5 floats, optional) – The bulge [Fe/H] distribution, two normal populations: the share of
bar_massin the metal-poor one, which has the spherical shape ofSPHEROID_SHAPEwhile the metal-rich one keeps the bar’s, then the mean and standard deviation of the metal-poor and of the metal-rich population. Default isBAR_FEH: the components of Gonzalez et al. (2015), with the share and shape fitted to the metal-poor fractions of Zoccali et al. (2017).bar_age (tuple of 4 floats, optional) – Mean and standard deviation in Gyr of the age of the metal-poor and of the metal-rich population, each a normal truncated to 0 to 13.8 Gyr. Default is (11.0, 1.5, 8.0, 3.0), after Bensby et al. (2017).
feh_systematic (tuple of 3 floats, optional) – Standard deviation in dex of the difference between the [Fe/H] scale of the grid and that of the measured distributions, for the thin disk, thick disk and halo; the bar takes the thick-disk value. Each [Fe/H] distribution is convolved with it. Default is (0.1, 0.15, 0.15): survey [Fe/H] scales differ by about 0.1 dex, and a solar-scaled grid reads alpha-rich stars 0.14 to 0.21 dex high.
age_systematic (tuple of 3 floats, optional) – Fractional standard deviation of the difference between the age scale of the grid and that of the measured distributions, for the thin disk, thick disk and halo (the bar takes the thick-disk value), added in quadrature to
age_floor. Default is (0.1, 0.15, 0.15): grids differ by about 10% in age, and a solar-scaled grid makes alpha-rich stars 1 to 2 Gyr older.age_floor (float, optional) – Absolute part of the age systematic in Gyr. Default is 0.2.
v_circ_solar (float or None, optional) – Circular velocity at the Sun in km/s, which scales the measured rotation curve of ~brutus.priors.thin_disk_velocity_moments. Default (None) is the Sgr A* proper motion less the solar peculiar velocity, as in ~brutus.priors.solar_velocity. The rotation curve sets the angular momentum on which the thin-disk vertical dispersion depends, and the vertical potential scales as its square.
thick_sigma_z (float, optional) – Vertical dispersion of the thick disk at the Sun in km/s. Default is
brutus.priors.kinematic.THICK_DISK_SIGMA[2].pm (array_like of shape (2,), optional) – Observed proper motion
(mu_l*, mu_b)of the star in mas/yr, in Galactic coordinates (~brutus.utils.pm_equatorial_to_galactic converts Gaia’s). With it, each component’s density is multiplied by the probability of the motion under its velocity ellipsoid (see Notes), which needsfehandlogaand one sightline.pm_cov (array_like of shape (2, 2), optional) – Covariance of
pmin (mas/yr)^2. Required withpm.rv (float, optional) – Observed heliocentric radial velocity and its error in km/s, which add the third observable. Need
pm.rv_err (float, optional) – Observed heliocentric radial velocity and its error in km/s, which add the third observable. Need
pm.pm_outlier (float, optional) – Share in [0, 1) of stars whose motion follows a broad ellipsoid of
PM_OUTLIER_SIGMAkm/s about zero Galactocentric velocity instead of their component’s. Default isPM_OUTLIER, 0.01.pm_floor (float, optional) – Systematic error in mas/yr added in quadrature to each proper motion’s variance. Default is 0.
return_components (bool, optional) – Whether to return the components. Default is False.
- Returns:
logp (numpy.ndarray) – Log-prior, ln of the number density per kpc^3, per dex of [Fe/H] and per Gyr of age (for the labels given) times \(d^2\).
components (dict, optional) – If
return_components:'number_density', the list of ln number density times \(d^2\) of the thin disk, thick disk, halo and bulge (the bar and the spheroid); and, with labels,'labels', the list of ln p(labels) of each component at that position, 0 where the component has no stars (the bulge beyond 6 kpc from the centre, or a component switched off with 0). Their sums are the terms oflogp.
- Raises:
ValueError – If
labels,fehorlogais not shaped as above or not finite, if a label-distribution keyword is not a tuple of finite numbers with positive widths, or if a keyword that sets a normalization is out of its range (see galactic_prior_summary).
Notes
Each disk has an exponential surface density with scale length
R_thinorR_thick, as in logn_disk, and insideDISK_INNER_RADIUS(4 kpc) keeps its density there. A disk population’s density is its surface density times \(\nu(z) / 2H\), with \(\nu = 1\) at the midplane and \(H\) its column. The vertical profiles solve the vertical Jeans equation in the potential of the Milky Way model of Binney & Vasiliev (2024), tabulated inbrutus.priors.kinematic:\[\ln \nu(z) = -2 \ln f_z(|z|) - \frac{1}{\sigma_{z,0}^2} \int_0^{|z|} \frac{K_z(t)}{f_z(t)^2}\,dt\]A thin-disk population of a given age and [Fe/H] takes the vertical dispersion of Sharma et al. (2021), which grows with height as \(f_z = 1 + \gamma_z |z|\) up to 2 kpc, with its angular-momentum factor held at the \(L_z\) of a circular orbit at 14 kpc and \(\sigma_{z,0}\) joined to the 8 km/s of stars younger than 200 Myr (Gaia Collaboration 2021) as \((\sigma^4 + 8^4)^{1/4}\); the thin-disk density is tapered to 0 between \(|z|\) = 5 and 7 kpc, by the cosine taper of the bar, which removes those stars. Its ages and [Fe/H] at radius R follow the star formation, enrichment and radial migration model of Frankel et al. (2018), read as the distribution per unit area (
THIN_DISK_*constants). The [Fe/H] at birth stops falling beyondTHIN_DISK_GRADIENT_KNEE(15.3 kpc), where Cepheids flatten (Albarracin et al. 2026), and 2% of the stars have a broad birth [Fe/H] (THIN_DISK_FEH_TAIL). The distribution is held inside 5 kpc, the inner radius of their fit; beyond its outer radius, 14 kpc, the age mix is held while [Fe/H] at each age follows the model. Labels not given are summed over. A thin-disk star’s labelled age is a normal about its true age, of the age systematic and truncated to 0 to 13.8 Gyr, and its vertical profile is that of the true age; labelled ages above 13.8 Gyr have zero prior. With one label, the thin disk is interpolated in a table against that label, R and z, built once per parameter set in about 1 s; with both, it sums over 16 true ages at each point. The thick disk is isothermal (\(\gamma_z = 0\)), withthick_sigma_zat the Sun and the radial profile of ~brutus.priors.thick_disk_velocity_moments; its labels and those of the halo do not depend on position. The halo, logn_halo, is normalized byhalo_mass, as in galactic_prior_summary.The bulge has two populations. The metal-rich one, (1 - bar_feh[0]) of
bar_mass, has the analytic bar density of Sormani et al. (2022), a fit to the dynamical model of Portail et al. (2017): an X-shaped bar and a long bar, which together reach 5 kpc from the centre, turned bybar_angle. The metal-poor one, bar_feh[0] ofbar_mass, has the spherical density ofSPHEROID_SHAPE. Beyond 5 kpc from the Galactic centre both are multiplied by the taper \((1 + \cos[\pi (r - 5\,{\rm kpc}) / 1\,{\rm kpc}]) / 2\), which reaches 0 at 6 kpc, since the published long-bar terms decay slowly beyond the end of the bar. The bulge labels are the local mix of the two populations, so they depend on position; their [Fe/H] and ages are widened by the thick-disk systematics.References
Frankel et al. (2018), ApJ, 865, 96 Xiang & Rix (2022), Nature, 603, 599 Naidu et al. (2020), ApJ, 901, 48 Youakim et al. (2020), MNRAS, 492, 4986 Sormani et al. (2022), MNRAS, 514, L1 Portail et al. (2017), MNRAS, 465, 1621 Wegg et al. (2015), MNRAS, 450, 4050 Gaia Collaboration, Katz et al. (2018), A&A, 616, A11 Gaia Collaboration, Antoja et al. (2021), A&A, 649, A8 Albarracin et al. (2026), A&A (arXiv:2611.10132) Yu et al. (2021), ApJ (arXiv:2105.07151) Gonzalez et al. (2015), A&A, 584, A46 Zoccali et al. (2017), A&A, 599, A12 Bensby et al. (2017), A&A, 605, A89
- brutus.priors.galactic_prior_summary(**kwargs)[source]¶
Return the normalizations that logp_galactic_structure derives.
The column height of a disk at the Sun is \(h = \Sigma / (2 \nu(Z_\odot))\), with the thin disk summed over its ages and [Fe/H], and the thick disk’s density ratio at the Sun is
\[f_{\rm thick} = f_{\Sigma} \, \frac{h_{\rm thin}}{h_{\rm thick}}.\]The halo density at the Sun is its mass over the volume integral of its shape between Galactocentric radii of 2 and 70 kpc, and its ratio to the thin disk is
\[f_{\rm halo} = \frac{M_{\rm halo}}{\rho_{\rm thin,\odot} \int_{r_1}^{r_2} n_{\rm halo}\, dV}.\]- Parameters:
**kwargs – Keywords of logp_galactic_structure that set the normalizations:
R_solar,Z_solar, the disk scale lengths and smoothing radii,f_thick_surface,v_circ_solar,thick_sigma_z, the halo-shape keywords,halo_mass,rho_thin_solarandfeh_systematic, whose thin-disk entry changes the thin-disk column. Omitted keywords take its defaults.- Returns:
summary –
thin_column_heightandthick_column_heightin kpc,f_thick_solar(the thick- to thin-disk density ratio at the Sun’s position),halo_density_solarin Msun/pc^3 andf_halo_solar(the halo to thin-disk density ratio at the Sun).- Return type:
- Raises:
TypeError – If a keyword does not set a normalization.
ValueError – If
R_thin,R_thick,thick_sigma_z,v_circ_solar,Rs_halo,eta_halo_inner,eta_halo_outer,r_break_halo,q_haloorrho_thin_solaris not positive and finite, or iff_thick_surfaceorhalo_massis negative or not finite.
Examples
>>> from brutus.priors import galactic_prior_summary >>> round(galactic_prior_summary()["f_halo_solar"], 5) 0.00177
- brutus.priors.sample_motions(dists, coord, feh, loga, rstate, **kwargs)[source]¶
Draw the proper motion and radial velocity predicted at each distance.
Each point draws its component with probability proportional to the terms of logp_galactic_structure: the number density, the probability of its labels and, when
kwargsholds an observed proper motion, its kinematic likelihood. It then draws a velocity from that component’s ellipsoid (the halo from its mixture) and projects it with velocity_to_observables. Fed with the posterior draws of a fit, the result is the posterior predictive distribution of the motion, without measurement error.- Parameters:
dists (array_like of shape (N,)) – Heliocentric distances in kpc.
coord (tuple of float) – Galactic coordinates
(l, b)in degrees.feh (array_like of shape (N,)) – [Fe/H] and log10(age / yr) at each distance.
loga (array_like of shape (N,)) – [Fe/H] and log10(age / yr) at each distance.
rstate (~numpy.random.Generator or ~numpy.random.RandomState) – Random number generator.
**kwargs – Keywords of logp_galactic_structure, including the observed
pm,pm_cov,rvandrv_err.
- Returns:
motions – Predicted
(mu_l*, mu_b)in mas/yr andv_rin km/s.- Return type:
~numpy.ndarray of shape (N, 3)
- Raises:
ValueError – If
distsis not 1D, or if a keyword is rejected by logp_galactic_structure.
Notes
The thin disk draws from the ellipsoid of the label age rather than from the true-age nodes of the prior, which spread the age by its systematic error. The outlier ellipsoid of the kinematic term is a tolerance for bad measurements and is not drawn.
- brutus.priors.logn_disk(R, Z, R_solar=8.275, Z_solar=0.0208, R_scale=2.74, Z_scale=0.3, R_smooth=2.0)[source]¶
Compute the log-number density for an exponential Galactic disk.
Evaluates a double-exponential disk model with separate radial and vertical scale lengths, smoothed near the Galactic center to avoid singularities.
- Parameters:
R (array_like) – Galactocentric cylindrical radius in kpc.
Z (array_like) – Height above the Galactic midplane in kpc.
R_solar (float, optional) – Solar Galactocentric radius in kpc. Default is
R_SOLAR, 8.275 (GRAVITY Collaboration 2021).Z_solar (float, optional) – Solar height above midplane in kpc. Default is
Z_SOLAR, 0.0208 (Bennett & Bovy 2019).R_scale (float, optional) – Disk radial scale length in kpc. Default is 2.74, that of the thin disk.
Z_scale (float, optional) – Disk vertical scale height in kpc. Default is 0.3.
R_smooth (float, optional) – Smoothing radius to avoid central singularity in kpc. Default is 2.0.
- Returns:
logn – Normalized log-number density relative to Solar neighborhood.
- Return type:
array_like
See also
logn_haloHalo number density
logp_galactic_structureCombined disk+halo model
Notes
The disk number density follows:
\[n_{\text{disk}}(R, Z) \propto \exp\left(-\frac{R_{\text{eff}} - R_{\text{eff},\odot}}{R_{\text{scale}}} - \frac{|Z| - |Z_\odot|}{Z_{\text{scale}}}\right)\]where \(R_{\text{eff}} = \sqrt{R^2 + R_{\text{smooth}}^2}\) provides smoothing near the Galactic center and \(R_{\text{eff},\odot} = \sqrt{R_\odot^2 + R_{\text{smooth}}^2}\) is the smoothed solar radius, so the normalized density is exactly 1 at the solar position (consistent with
logn_halo()). This keeps the thick-disk and halo fractions oflogp_galactic_structure()exact at the solar position.References
Bland-Hawthorn & Gerhard (2016) - The Galaxy in Context
- brutus.priors.logn_halo(R, Z, R_solar=8.275, Z_solar=0.0208, R_smooth=2.0, eta_inner=2.85, eta_outer=4.55, r_break=19.1, q=0.77)[source]¶
Return the log-number density of the stellar halo relative to the Sun.
The halo is the broken power law of Amarante et al. (2024) in a flattened radius, with a core:
\[\ln n_{\rm halo} = -\eta_{\rm in} \ln m - (\eta_{\rm out} - \eta_{\rm in}) \max(\ln (m / r_b), 0) - (\ldots)_\odot, \qquad m = \sqrt{R^2 + (Z/q)^2 + R_{\rm smooth}^2},\]Amarante et al. raise q to 0.99 beyond 30 kpc; here q is constant, which avoids a jump in density (see the priors page of the docs).
- Parameters:
R (array_like) – Galactocentric cylindrical radius in kpc.
Z (array_like) – Height above the Galactic midplane in kpc.
R_solar (float, optional) – Solar Galactocentric radius in kpc. Default is
R_SOLAR, 8.275 (GRAVITY Collaboration 2021).Z_solar (float, optional) – Solar height above midplane in kpc. Default is
Z_SOLAR, 0.0208 (Bennett & Bovy 2019).R_smooth (float, optional) – Core radius in kpc, which keeps the density finite at the Galactic centre. Default is 2.0.
eta_inner (float, optional) – Power-law slopes inside and outside
r_break. Defaults are 2.85 and 4.55.eta_outer (float, optional) – Power-law slopes inside and outside
r_break. Defaults are 2.85 and 4.55.r_break (float, optional) – Break radius of the flattened radius
min kpc. Default is 19.1.q (float, optional) – Flattening, the ratio of the vertical to the radial axis. Default is 0.77.
- Returns:
logn – Log-number density, 0 at the Sun.
- Return type:
See also
logn_diskDisk number density
logp_galactic_structureCombined disk+halo model
References
Amarante, Koposov & Laporte (2024), A&A (arXiv:2404.09825) Lane, Bovy & Mackereth (2023), MNRAS (arXiv:2306.03084)
Kinematics¶
The Galactic prior uses the disk vertical dispersions. The fit does not use the velocities yet (#275).
- brutus.priors.solar_velocity(R_solar=8.275, pm_sgra=(-6.411, -0.219), U_sun=11.1)[source]¶
Return the velocity of the Sun relative to the Galactic centre.
Sgr A* is taken to be at rest at the Galactic centre, so its proper motion is the reflex of the solar motion:
\[V_\odot = -k R_\odot \mu_{l,\mathrm{Sgr\,A^*}}, \qquad W_\odot = -k R_\odot \mu_{b,\mathrm{Sgr\,A^*}}\]with \(k = 4.74047\) km/s per (kpc mas/yr). This ties the solar velocity to
R_solar: use the sameR_solarin the moment functions and in velocity_to_observables.- Parameters:
R_solar (float, optional) – Distance of the Sun from the Galactic centre in kpc. Default is
R_SOLAR, 8.275 (GRAVITY Collaboration 2021).pm_sgra (tuple of float, optional) – Proper motion
(mu_l*, mu_b)of Sgr A* in mas/yr. Default is(-6.411, -0.219)(Reid & Brunthaler 2020).U_sun (float, optional) – Solar velocity toward the Galactic centre in km/s. Default is 11.1 (Schönrich et al. 2010).
- Returns:
v_sun – Solar velocity
(U, V, W)in km/s, with U toward the Galactic centre, V in the direction of rotation and W toward the north Galactic pole.- Return type:
~numpy.ndarray of shape (3,)
- Raises:
ValueError – If
R_solaris not positive.
- brutus.priors.thin_disk_velocity_moments(R, Z, age, feh, R_scale=2.74, R_smooth=2.0, R_solar=8.275, v_circ_solar=None)[source]¶
Return the velocity ellipsoid of the thin disk.
The radial and vertical dispersions follow Sharma et al. (2021, eqs. 3-7 and Table 2):
\[\sigma_v = \sigma_{0,v} \left(\frac{\tau + 0.1}{10.1}\right)^{\beta_v} f_{L_z}(L_z)\,(1 + \gamma_{\mathrm{[Fe/H]},v}\mathrm{[Fe/H]}) (1 + \gamma_{z,v} |z|)\]with age \(\tau\) in Gyr, \(|z|\) in kpc and \(f_{L_z} = [\alpha_{L,v} (L_z/L_{z,\odot})^2 + e^{-(L_z - L_{z,\odot})/\lambda_{L,v}}] / (1 + \alpha_{L,v})\). The \(L_{z,\odot} = R_\odot v_c(R_\odot)\). \(L_z\) is the mean angular momentum of the population, \(R\,\bar{v}_\phi\), with \(\bar{v}_\phi\) from the Jeans equation below (two steps of the fixed point from the circular \(L_z = R\,v_c\)). The relations were fitted at 3 < R < 20 kpc, \(|z|\) < 2 kpc and -1 < [Fe/H] < 0.5. For \(\sigma_z\) the product \(s\) of \(\sigma_{0,v}\), the age factor and the [Fe/H] factor is joined to the 8 km/s of stars younger than 200 Myr (
THIN_DISK_SIGZ_FLOOR; Gaia Collaboration 2021) as \((s^4 + 8^4)^{1/4}\), because extrapolated to age 0 it gives 2.8 km/s. In the height factor of \(\sigma_z\), \(|z|\) is held at 2 kpc (THIN_DISK_Z_MAX) with a quadratic blend from 1.5 kpc (THIN_DISK_Z_EDGE= 0.5 kpc). Without the hold, the thin-disk density would fall as \(|z|^{-2}\) at large heights. Outside 3 < R < 20 kpc the dispersions keep their edge values, blended in so that \(\bar{v}_\phi\) stays continuous: \(L_z\) is clamped to the circular \(L_z\) at the edges with a quadratic blend 1 kpc \(\times\,v_{c,\odot}\) wide in \(L_z\), and the dispersion gradient in the Jeans equation fades out within 1 kpc outside the radii. A population that lags reaches the outer clamp further out, at 22.7 kpc for 5 Gyr and [Fe/H] = 0 and at 25.2 kpc for 13.8 Gyr and [Fe/H] = -1; beyond 21 kpc its dispersions still change a little, by up to 0.6 km/s in \(\bar{v}_\phi\) through the missing gradient. [Fe/H] is held at the edges of its range. The angular-momentum factor of \(\sigma_z\) alone is held at the \(L_z\) of a circular orbit at 14 kpc (THIN_DISK_SIGZ_R_MAX), which lagging populations reach further out: Gaia Collaboration (2018) see no upturn of \(\sigma_z\) out to 14 kpc, and the \(L_z^2\) term would keep raising it. The azimuthal dispersion follows the epicyclic ratio \(\sigma_\phi^2 / \sigma_R^2 = (1 + d\ln v_c / d\ln R) / 2\).The mean rotation is the radial Jeans solution (Binney & Tremaine 2008, eq. 4.228) for a cylindrically aligned ellipsoid and the density gradient of ~brutus.priors.galactic.logn_disk, held inside DISK_INNER_RADIUS (4 kpc) as in the Galactic prior:
\[\bar{v}_\phi^2 = v_c^2 - \sigma_\phi^2 + \sigma_R^2 \left(1 + \frac{\partial \ln \nu}{\partial \ln R} + \frac{\partial \ln \sigma_R^2}{\partial \ln R}\right)\]with the measured circular velocity \(v_c(R)\): one smoothing spline fitted to Sofue & Kohno (2025) and Eilers et al. (2019) together, each scaled to \(v_{c,\odot}\) at \(R_\odot\) (
rotation_curve.dat). It smooths over 1-2 kpc near the Sun, goes to 0 as R at the centre and is flat beyond the last measurement at 21 kpc: d ln v_c / d ln R goes from -0.15 at 21 kpc to 0 by 23 kpc. The mean rotation is clipped to \([0, v_c]\): the Jeans equation has no solution where the right-hand side is negative, and near the centre, where the density gradient vanishes, it gives rotation faster than circular. The model is axisymmetric, so it does not describe the bar of the inner few kpc. The mean radial and vertical velocities are 0.- Parameters:
R (array_like of shape (N,)) – Galactocentric cylindrical radius and height above the midplane in kpc.
Z (array_like of shape (N,)) – Galactocentric cylindrical radius and height above the midplane in kpc.
age (float or array_like of shape (N,)) – Stellar age in Gyr.
feh (float or array_like of shape (N,)) – Metallicity [Fe/H].
R_scale (float, optional) – Radial scale length and smoothing radius of the number density in kpc, as in ~brutus.priors.galactic.logn_disk. Defaults are 2.74 and 2.0.
R_smooth (float, optional) – Radial scale length and smoothing radius of the number density in kpc, as in ~brutus.priors.galactic.logn_disk. Defaults are 2.74 and 2.0.
R_solar (float, optional) – Distance of the Sun from the Galactic centre in kpc. Default is
R_SOLAR, 8.275 (GRAVITY Collaboration 2021).v_circ_solar (float, optional) – Circular velocity at
R_solarin km/s, which scales the measured curve. Default is the solar V fromsolar_velocity(R_solar)minus the peculiar 12.24 km/s of Schönrich et al. (2010): 239.25 km/s for the defaultR_solar. The shape of the curve is a function ofR / R_solar.
- Returns:
mean (~numpy.ndarray of shape (N, 3)) – Mean velocity
(v_R, v_phi, v_z)in km/s.cov (~numpy.ndarray of shape (N, 3, 3)) – Velocity covariance in (km/s)^2.
- Raises:
ValueError – If the positions are not finite 1-D arrays of one length,
Rorageis negative,fehis not finite,ageorfehdoes not broadcast toR, a length scale is not positive, orv_circ_solaris not positive.
- brutus.priors.thick_disk_velocity_moments(R, sigma_solar=(64.68, 50.82, 43.6), R_scale=1.9, R_smooth=2.0, R_solar=8.275, v_circ_solar=None)[source]¶
Return the velocity ellipsoid of the thick disk.
The dispersions do not depend on age (Mackereth et al. 2019 find the high-[alpha/Fe] age-velocity relations flat) or on height. Their values at the Sun are the high-[alpha/Fe] dispersions of Anguiano et al. (2020, Table 1), and each follows the radial profile of the midplane dispersion of the high-alpha disk in the Milky Way model of Binney & Vasiliev (2024), against \(R / R_\odot\). That disk is truncated beyond about 12 kpc, and inside about 3 kpc its \(\sigma_z\) rises steeply, so outside \(0.36 < R / R_\odot < 1.5\) (
THICK_DISK_X_RANGE) the dispersions keep their edge values, with a quadratic blend 0.2 \(R_\odot\) wide. With the density falling exponentially and the dispersions held, the asymmetric drift grows with R, and beyond about 29 kpc it exceeds \(v_c\), so \(\bar{v}_\phi\) is 0 there. The mean rotation is the radial Jeans solution of thin_disk_velocity_moments. With the defaults, \(\bar{v}_\phi = 190.3\) km/s at the Sun; Anguiano et al. (2020) measure 191.8 km/s.- Parameters:
R (array_like of shape (N,)) – Galactocentric cylindrical radius in kpc.
sigma_solar (tuple of float, optional) – Dispersions
(sigma_R, sigma_phi, sigma_z)at the Sun in km/s. Default isTHICK_DISK_SIGMA,(64.68, 50.82, 43.60).R_scale (float, optional) – Radial scale length and smoothing radius of the number density in kpc. Defaults are 1.9 and 2.0.
R_smooth (float, optional) – Radial scale length and smoothing radius of the number density in kpc. Defaults are 1.9 and 2.0.
R_solar (optional) – The rotation curve, as in thin_disk_velocity_moments.
v_circ_solar (optional) – The rotation curve, as in thin_disk_velocity_moments.
- Returns:
mean (~numpy.ndarray of shape (N, 3)) – Mean velocity
(v_R, v_phi, v_z)in km/s.cov (~numpy.ndarray of shape (N, 3, 3)) – Velocity covariance in (km/s)^2.
- Raises:
ValueError – If
Ris not a finite, non-negative 1-D array, a dispersion is negative, a length scale is not positive, orv_circ_solaris not positive.
- brutus.priors.halo_velocity_moments(R, Z)[source]¶
Return the three Gaussian components of the halo velocity distribution.
The mixture is that of Lancaster et al. (2019, Table 2), fitted to Gaia DR2 blue horizontal branch stars at 4.9 < r < 67.9 kpc:
an isotropic component with zero mean, weight \(f_h\), radial dispersion \(\sigma_{r,h}\) and tangential dispersion \(\sigma_{t,h}\);
two radial lobes (the Gaia-Enceladus debris) with weight \((1 - f_h)/2\) each, mean \(v_r = \pm\delta\) and mean rotation \(\mu_{\phi}\), and dispersions \(\sigma_{r,r}\) and \(\sigma_{t,r}\).
The parameters are interpolated linearly in the spherical radius \(r\) between the centres of the four radial bins and held constant beyond them. Each spherical ellipsoid is rotated to cylindrical coordinates with \(\sin\theta = R/r\) and \(\cos\theta = Z/r\):
\[\sigma_R^2 = \sigma_r^2 \sin^2\theta + \sigma_t^2 \cos^2\theta, \quad \sigma_z^2 = \sigma_r^2 \cos^2\theta + \sigma_t^2 \sin^2\theta, \quad \sigma_{Rz} = (\sigma_r^2 - \sigma_t^2) \sin\theta \cos\theta\]- Parameters:
R (array_like of shape (N,)) – Galactocentric cylindrical radius and height above the midplane in kpc.
Z (array_like of shape (N,)) – Galactocentric cylindrical radius and height above the midplane in kpc.
- Returns:
weight (~numpy.ndarray of shape (N, 3)) – Weights of the isotropic component and the lobes at \(v_r = +\delta\) and \(-\delta\); each row sums to 1.
mean (~numpy.ndarray of shape (N, 3, 3)) – Mean velocity
(v_R, v_phi, v_z)of each component in km/s.velocity_to_observables(d, coord, mean[:, k], cov[:, k])projects componentk.cov (~numpy.ndarray of shape (N, 3, 3, 3)) – Velocity covariance of each component in (km/s)^2.
- Raises:
ValueError – If
RandZare not finite 1-D arrays of the same length, orRis negative.
- brutus.priors.bulge_velocity_moments(R, Z, R_solar=8.275, v_circ_solar=None)[source]¶
Return the velocity ellipsoid of the bulge.
The bar and the metal-poor spheroid of the Galactic prior share the velocity distribution of the bulge disc of the Milky Way model of Binney & Vasiliev (2024), rebuilt with AGAMA by
.github/scripts/make_bv24_tables.py: its mean rotation and the dispersions of \((v_R, v_\phi, v_z)\), tabulated on 0.1 kpc steps in R and z out to 6 kpc, interpolated bilinearly and held beyond. The model is axisymmetric, so streaming along the bar is not described. Radii scale by \(R_\odot / 8.27\) kpc and velocities by \(v_{c,\odot} / 235.7\) km/s, as the potential does. The R-z covariance, under 0.05 (km/s)^2 where it was measured, is left out.- Parameters:
R (array_like of shape (N,)) – Galactocentric cylindrical radius and height above the midplane in kpc.
Z (array_like of shape (N,)) – Galactocentric cylindrical radius and height above the midplane in kpc.
R_solar (float, optional) – Distance of the Sun from the Galactic centre in kpc. Default is
R_SOLAR, 8.275 (GRAVITY Collaboration 2021).v_circ_solar (float, optional) – Circular speed at the Sun in km/s. Default is the solar V of solar_velocity minus the peculiar 12.24 km/s of Schönrich et al. (2010).
- Returns:
mean (~numpy.ndarray of shape (N, 3)) – Mean velocity
(v_R, v_phi, v_z)in km/s.cov (~numpy.ndarray of shape (N, 3, 3)) – Velocity covariance in (km/s)^2.
- Raises:
ValueError – If
RandZare not finite 1-D arrays of the same length,Ris negative, orR_solarorv_circ_solaris not positive.
- brutus.priors.velocity_to_observables(dists, coord, mean, cov, R_solar=8.275, v_sun=None)[source]¶
Project a velocity ellipsoid to proper motions and radial velocity.
A star at distance \(d\) toward \((l, b)\) with Galactocentric velocity \(\mathbf{v}\) has heliocentric velocity \(\mathbf{v} - \mathbf{v}_\odot\) and observables
\[\mu_{l*} = \frac{\hat{e}_l \cdot (\mathbf{v} - \mathbf{v}_\odot)}{k d}, \quad \mu_b = \frac{\hat{e}_b \cdot (\mathbf{v} - \mathbf{v}_\odot)}{k d}, \quad v_r = \hat{e}_r \cdot (\mathbf{v} - \mathbf{v}_\odot)\]with \(k = 4.74047\) km/s per (kpc mas/yr). The map is linear in \(\mathbf{v}\), so a Gaussian velocity distribution stays Gaussian: with Jacobian \(M\), the covariance is \(M \Sigma M^T\). The Sun is in the Galactic midplane for this projection; its height changes the directions by less than
Z_solar / R_solarradians.- Parameters:
dists (array_like of shape (N,)) – Heliocentric distances in kpc.
coord (tuple of float) – Galactic coordinates
(l, b)in degrees.mean (array_like of shape (N, 3)) – Mean velocity
(v_R, v_phi, v_z)at each distance, in km/s.cov (array_like of shape (N, 3, 3)) – Velocity covariance at each distance, in (km/s)^2, with no
(v_R, v_phi)or(v_phi, v_z)covariance, as returned by thin_disk_velocity_moments, thick_disk_velocity_moments and each component of halo_velocity_moments.R_solar (float, optional) – Distance of the Sun from the Galactic centre in kpc. Default is
R_SOLAR, 8.275 (GRAVITY Collaboration 2021).v_sun (array_like of shape (3,), optional) – Solar velocity
(U, V, W)in km/s. Default issolar_velocity(R_solar).
- Returns:
obs_mean (~numpy.ndarray of shape (N, 3)) – Mean
(mu_l*, mu_b, v_r)in (mas/yr, mas/yr, km/s).obs_cov (~numpy.ndarray of shape (N, 3, 3)) – Covariance of
(mu_l*, mu_b, v_r)in the same units.
- Raises:
ValueError – If a distance or
R_solaris not positive, the shapes do not match,meanorcovis not finite,coordis not a finite(l, b)with|b| <= 90, orcovis not symmetric and positive semi-definite or has(v_R, v_phi)or(v_phi, v_z)covariance.
Extinction Priors¶
- brutus.priors.logp_extinction(avs, dustmap, coord, distance=None, return_components=False, avlim=(0.0, 20.0), scatter=0.2)[source]¶
Log-prior for dust extinction using 3D dust maps.
Implements Gaussian extinction priors based on dust maps with systematic uncertainty treatment. Supports both 3D dust maps (e.g., Bayestar) that return distance-resolved profiles and simpler maps that return a single mean and standard deviation.
- Parameters:
avs (array_like) – Extinction values (A_V) in magnitudes to evaluate prior for.
dustmap (object) – Dust map object with a
query(coord)method. For 3D dust maps (e.g.,Bayestar),queryreturns(distances, av_mean, av_std)with distance-resolved profiles. For simpler maps,queryreturns(av_mean, av_std)scalars. Objects without aquerymethod (e.g. an unloaded file path) raise TypeError.coord (SkyCoord or array_like) – Sky coordinates for dust map query. Accepts
astropy.coordinates.SkyCoordor[l, b]in degrees.distance (float or array_like, optional) – Distance(s) in kpc at which to evaluate the extinction prior. Required for 3D dust maps to interpolate the extinction profile. If
avsanddistanceare both arrays, they must have the same shape and the prior is evaluated element-wise.return_components (bool, optional) – If True, returns tuple
(logp, (av_mean, av_err))including the dust map statistics used. Default is False.avlim (tuple of 2 floats, optional) – Support
(av_min, av_max)over which the Gaussian prior is normalized (truncated normal), and over which the uniform prior of uninformative map bins is normalized. Should match theavlimof the fit. Default isAVLIM, (0, 20) (theBruteForce.fitdefault).scatter (float, optional) – Systematic scatter (in magnitudes) added in quadrature to the map’s A(V) spread,
sigma = sqrt(sigma_map**2 + scatter**2). Bayestar’s per-bin spreads are typically only ~0.01-0.05 mag and do not include sub-pixel structure or map systematics; without this floor the prior pins A(V) (and, through the A(V)-distance profile, the distance) far more tightly than the map supports. Default is0.2, matching brutus <= 0.8.3. Set to0to use the raw map spreads.
- Returns:
logp (ndarray) – Log-prior probability density for the input extinction values. Where the map is uninformative (no coverage, or distance bins masked as unreliable), returns the normalized uniform density over
avlim,-ln(avlim[1] - avlim[0]).components (tuple, optional) – If
return_components=True, returns(av_mean, av_err)containing the dust map mean and standard deviation used.
- Raises:
ValueError – If
avlimis not two finite numbers withavlim[0] < avlim[1], or if a 3D dust map is given withoutdistance.TypeError – If
dustmaphas noquerymethod (e.g. astrorpathlib.Paththat was never loaded into a dust map object), or ifdustmap.queryreturns anything but a tuple, list or array of length 2 or 3.
Notes
The log-prior follows a truncated Gaussian distribution when dust map data is available:
\[\log p(A_V | A_{V,\text{map}}, \sigma_{A_V}) = -\frac{1}{2} \left[ \frac{(A_V - A_{V,\text{map}})^2}{\sigma_{A_V}^2} + \log(2\pi\sigma_{A_V}^2) \right] - \log Z\]where \(Z = \Phi((A_{V,\max}-\mu)/\sigma) - \Phi((A_{V,\min}-\mu)/\sigma)\) normalizes the density over the physical support
avlim. Because the map mean and spread vary with distance, omitting \(Z\) would under-weight distances where the profile sits near the A(V) boundary (a bias of up toln 2).For 3D dust maps, the expected extinction and uncertainty at the requested distance are obtained by linear interpolation of the map’s distance-resolved profiles. Distances outside the map range use the boundary values.
The spread \(\sigma_{A_V}\) is the map spread with
scatteradded in quadrature.For regions without dust map coverage (NaN values, including distance bins masked by
Bayestar’s reliability mask), a uniform prior normalized overavlimis returned because an unnormalizedln p = 0would act as a density of 1 per mag and up-weight masked distances relative to reliable ones by a unit-dependent factor. If the dust mapquerycall itself fails, the uniform prior is returned with aRuntimeWarning.Examples
>>> from astropy.coordinates import SkyCoord >>> coord = SkyCoord(l=90., b=0., unit='deg', frame='galactic') >>> # With a 3D dust map: >>> # logp = logp_extinction([0.1, 0.5], dustmap, coord, distance=1.0) >>> # logp, (mean, err) = logp_extinction([0.1], dustmap, coord, >>> # distance=1.0, >>> # return_components=True)