Priors Module (brutus.priors)#

The priors module implements prior probability distributions for Bayesian inference in brutus. These priors encode astrophysical knowledge about the Galaxy and are critical for breaking parameter degeneracies in stellar parameter estimation.

Why Priors Matter:

Photometry alone cannot uniquely determine stellar properties—a faint red star could be either a nearby cool dwarf or a distant reddened giant. Priors resolve these ambiguities by incorporating knowledge about:

  • Where different stellar types are located in the Galaxy (Galactic structure)

  • How dust extinction varies with distance and direction (3-D dust maps)

  • The relative abundance of different stellar masses (IMF)

  • The metallicity and age structure of different Galactic populations

Prior Categories:

  1. Stellar Priors: Initial Mass Function (IMF) and luminosity functions

  2. Astrometric Priors: Parallax-based distance constraints

  3. Galactic Structure Priors: 3-D spatial distribution of stars (thin/thick disk, halo)

  4. Extinction Priors: 3-D dust maps and R_V variation

Typical Usage:

Priors are automatically applied by the BruteForce fitter, but can also be evaluated directly:

from brutus.priors.stellar import logp_imf
from brutus.priors.galactic import logp_galactic_structure
from brutus.priors.extinction import logp_extinction
import numpy as np

# Evaluate IMF prior for range of masses
masses = np.array([0.5, 1.0, 2.0, 5.0])
log_prior_imf = logp_imf(masses)

# Evaluate Galactic structure prior
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 3-D dust map
from brutus.dust import Bayestar
dustmap = Bayestar()  # load a 3-D dust map object
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[0])

Customization:

Advanced users can customize or disable priors by passing callables to fit(). The Galactic structure prior is supplied via lngalprior, which is called as lngalprior(dist, coord, labels=...) where coord is a single (l, b) tuple:

from brutus.analysis import BruteForce

fitter = BruteForce(grid)

# Disable the Galactic structure prior with a flat (zero) prior
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(len(np.atleast_1d(dist))),
)

# Or provide a custom Galactic prior function with the same signature

See Also:

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]#

Log-prior for a Kroupa-like broken initial mass function.

Implements a broken power-law IMF with separate slopes for low and high stellar masses, following Kroupa (2001). Supports binary systems with a secondary mass component.

Parameters:
  • mgrid (array_like) – Grid of initial stellar masses in solar units. Must be > 0.

  • alpha_low (float, optional) – Power-law slope for low-mass stars (M ≤ mass_break). Default is 1.3 (Kroupa 2001).

  • alpha_high (float, optional) – Power-law slope for high-mass stars (M > mass_break). Default is 2.3 (Kroupa 2001).

  • mass_break (float, optional) – Transition mass between low and high mass regimes in solar units. Default is 0.5.

  • mgrid2 (array_like, optional) – Grid of secondary stellar masses for binary systems in solar units. If provided, computes joint prior for binary system.

  • mass_min (float, optional) – Minimum mass for normalization (hydrogen burning limit). Default is 0.08 solar masses.

  • mass_max (float, optional) – Maximum mass for normalization. Default is 100.0 solar masses.

Returns:

logp – Normalized log-prior probability density for the input mass grid(s). Returns -inf for masses below mass_min or above mass_max.

Return type:

array_like

See also

logp_ps1_luminosity_function

Alternative luminosity-based prior

brutus.analysis.individual.BruteForce

Uses IMF priors for fitting

Notes

The IMF follows the form:

\[\begin{split}\\xi(M) \\propto M^{-\\alpha}\end{split}\]

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]#

Pan-STARRS 1 r-band luminosity function log-prior.

Implements the stellar luminosity function derived from Pan-STARRS 1 observations, specifically calibrated for use with Bayestar stellar evolutionary models and dust maps.

Parameters:

Mr (array_like) – Absolute r-band magnitudes in the Pan-STARRS 1 photometric system.

Returns:

logp – Log-prior probability density for the given absolute magnitudes. Interpolates from empirical Pan-STARRS 1 luminosity function.

Return type:

array_like

See also

logp_imf

Alternative mass-based IMF prior

brutus.analysis.individual.BruteForce

Uses luminosity priors for fitting

Notes

This prior is designed for integration with:

  • Bayestar stellar evolutionary tracks

  • Bayestar 3D dust extinction maps

  • Pan-STARRS 1 photometric system

The luminosity function is based on empirical measurements from the Pan-STARRS 1 survey and provides realistic stellar population weights for Bayesian inference.

References

Green et al. (2015) - 3D Dust Mapping with Pan-STARRS 1 Green et al. (2018) - Bayestar dust maps

Astrometric Priors#

brutus.priors.logp_parallax(parallaxes, p_meas, p_err)[source]#

Log-prior for parallax measurements assuming Gaussian errors.

Implements a Gaussian log-prior based on observed parallax and measurement uncertainty. Returns uniform prior when measurements are invalid or unavailable.

Parameters:
  • parallaxes (array_like) – Model parallax values in milliarcseconds (mas).

  • p_meas (float) – Measured parallax in milliarcseconds (mas).

  • p_err (float) – Parallax measurement uncertainty in milliarcseconds (mas).

Returns:

logp – Log-prior probability density for the input parallax values. Returns 0 (uniform prior) if measurements are invalid.

Return type:

array_like

Notes

The log-prior follows a normal distribution:

\[\begin{split}\\log p(\\pi | \\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]\end{split}\]

For invalid measurements (non-finite values), returns uniform prior.

brutus.priors.logp_parallax_scale(scales, scale_errs, p_meas, p_err, snr_lim=4.0)[source]#

Log-prior for flux scale factors derived from parallax measurements.

Applies parallax constraints to flux density scale factors where scale ~ parallax². Uses Gaussian approximation for high signal-to-noise parallax measurements.

Parameters:
  • scales (array_like) – Flux density scale factors (proportional to parallax²).

  • scale_errs (array_like) – Scale factor measurement uncertainties.

  • p_meas (float) – Measured parallax in milliarcseconds (mas).

  • p_err (float) – Parallax measurement uncertainty in milliarcseconds (mas).

  • snr_lim (float, optional) – Minimum signal-to-noise ratio for applying Gaussian approximation. Below this threshold, returns uniform prior. Default is 4.0.

Returns:

logp – Log-prior probability density for the input scale factors.

Return type:

array_like

Notes

For high SNR measurements (p_meas/p_err > snr_lim), the scale factor prior is derived from the parallax measurement using error propagation:

\[ \begin{align}\begin{aligned}\begin{split}s = \\pi^2 + \\sigma_\\pi^2\end{split}\\\begin{split}\\sigma_s = \\sqrt{2\\sigma_\\pi^4 + 4\\pi^2\\sigma_\\pi^2}\end{split}\end{aligned}\end{align} \]

The total uncertainty combines model and measurement errors in quadrature.

brutus.priors.convert_parallax_to_scale(p_meas, p_err, snr_lim=4.0)[source]#

Convert parallax measurement to flux density scale factor statistics.

Transforms parallax measurements and uncertainties to scale factor (s ~ π²) mean and standard deviation using error propagation.

Parameters:
  • p_meas (float) – Measured parallax in milliarcseconds (mas).

  • p_err (float) – Parallax measurement uncertainty in milliarcseconds (mas).

  • snr_lim (float, optional) – Minimum signal-to-noise ratio for conversion. Below this threshold, returns uninformative scale factor statistics. Default is 4.0.

Returns:

  • s_mean (float) – Mean of the scale factor distribution.

  • s_std (float) – Standard deviation of the scale factor distribution.

Notes

For high SNR measurements, uses error propagation:

\[ \begin{align}\begin{aligned}\begin{split}s_{\\text{mean}} = \\max(0, \\pi_{\\text{meas}})^2 + \\sigma_\\pi^2\end{split}\\\begin{split}s_{\\text{std}} = \\sqrt{2\\sigma_\\pi^4 + 4\\pi_{\\text{meas}}^2\\sigma_\\pi^2}\end{split}\end{aligned}\end{align} \]

The parallax is floored at zero to handle negative measurements. For low SNR, returns uninformative statistics (tiny mean, huge std).

Examples

>>> s_mean, s_std = convert_parallax_to_scale(1.0, 0.1)  # 10-sigma detection
>>> print(f"Scale factor: {s_mean:.3f} ± {s_std:.3f}")

Galactic Structure Priors#

brutus.priors.logp_galactic_structure(dists, coord, labels=None, R_solar=8.2, Z_solar=0.025, R_thin=2.6, Z_thin=0.3, Rs_thin=2.0, R_thick=2.0, Z_thick=0.9, f_thick=0.04, Rs_thick=2.0, Rs_halo=2.0, q_halo_ctr=0.2, q_halo_inf=0.8, r_q_halo=6.0, eta_halo=4.2, f_halo=0.005, feh_thin=-0.2, feh_thin_sigma=0.3, feh_thick=-0.7, feh_thick_sigma=0.4, feh_halo=-1.6, feh_halo_sigma=0.5, max_age=13.8, min_age=0.0, feh_age_ctr=-0.5, feh_age_scale=0.5, nsigma_from_max_age=2.0, max_sigma=4.0, min_sigma=1.0, return_components=False)[source]#

Complete Galactic structure log-prior with thin disk, thick disk, and halo.

Implements a sophisticated three-component Galactic model based on Bland-Hawthorn & Gerhard (2016). Combines spatial number density priors with optional metallicity and age priors for realistic stellar populations.

Parameters:
  • dists (array_like) – Distance from observer in kpc.

  • coord (tuple of floats) – Galactic coordinates (l, b) in degrees.

  • labels (structured array, optional) – Stellar labels containing ‘feh’ and/or ‘loga’ for metallicity/age priors.

  • R_solar (float, optional) – Solar Galactocentric radius in kpc. Default is 8.2.

  • Z_solar (float, optional) – Solar height above midplane in kpc. Default is 0.025.

  • R_thin (float, optional) – Thin disk radial scale length in kpc. Default is 2.6.

  • Z_thin (float, optional) – Thin disk vertical scale height in kpc. Default is 0.3.

  • Rs_thin (float, optional) – Thin disk smoothing radius in kpc. Default is 2.0.

  • R_thick (float, optional) – Thick disk radial scale length in kpc. Default is 2.0.

  • Z_thick (float, optional) – Thick disk vertical scale height in kpc. Default is 0.9.

  • f_thick (float, optional) – Thick disk relative normalization. Default is 0.04.

  • Rs_thick (float, optional) – Thick disk smoothing radius in kpc. Default is 2.0.

  • Rs_halo (float, optional) – Halo smoothing radius in kpc. Default is 2.0.

  • q_halo_ctr (float, optional) – Halo central oblateness. Default is 0.2.

  • q_halo_inf (float, optional) – Halo asymptotic oblateness. Default is 0.8.

  • r_q_halo (float, optional) – Halo oblateness transition radius in kpc. Default is 6.0.

  • eta_halo (float, optional) – Halo power-law index. Default is 4.2.

  • f_halo (float, optional) – Halo relative normalization. Default is 0.005.

  • feh_thin (float, optional) – Thin disk mean metallicity in dex. Default is -0.2.

  • feh_thin_sigma (float, optional) – Thin disk metallicity dispersion in dex. Default is 0.3.

  • feh_thick (float, optional) – Thick disk mean metallicity in dex. Default is -0.7.

  • feh_thick_sigma (float, optional) – Thick disk metallicity dispersion in dex. Default is 0.4.

  • feh_halo (float, optional) – Halo mean metallicity in dex. Default is -1.6.

  • feh_halo_sigma (float, optional) – Halo metallicity dispersion in dex. Default is 0.5.

  • max_age (float, optional) – Maximum stellar age in Gyr. Default is 13.8.

  • min_age (float, optional) – Minimum stellar age in Gyr. Default is 0.0.

  • feh_age_ctr (float, optional) – Central metallicity for age-metallicity relation. Default is -0.5.

  • feh_age_scale (float, optional) – Scale length for age-metallicity relation. Default is 0.5.

  • nsigma_from_max_age (float, optional) – Age dispersion parameter. Default is 2.0.

  • max_sigma (float, optional) – Maximum age dispersion in Gyr. Default is 4.0.

  • min_sigma (float, optional) – Minimum age dispersion in Gyr. Default is 1.0.

  • return_components (bool, optional) – Whether to return individual component contributions. Default is False.

Returns:

  • logp (array_like) – Total log-prior probability density.

  • components (dict, optional) – Individual component contributions (if return_components=True).

Notes

The Galactic model combines three stellar populations:

  1. Thin Disk: Young, metal-rich stars with small scale height

  2. Thick Disk: Intermediate-age, metal-poor stars with larger scale height

  3. Halo: Old, very metal-poor stars with flattened power-law profile

Each component has distinct spatial, metallicity, and age distributions calibrated from observations. The model accounts for:

  • Coordinate transformations from observer to Galactocentric frame

  • Volume correction factors (dV ∝ distance²)

  • Component membership probabilities

  • Conditional metallicity and age priors

When stellar labels are provided, applies population-specific priors: - Metallicity: Gaussian distributions with different means/dispersions - Age: Age-metallicity relation with truncated normal distributions

References

Bland-Hawthorn & Gerhard (2016) - The Galaxy in Context

brutus.priors.logn_disk(R, Z, R_solar=8.2, Z_solar=0.025, R_scale=2.6, Z_scale=0.3, R_smooth=2.0)[source]#

Log-number density for the Galactic disk stellar population.

Implements an 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 8.2.

  • Z_solar (float, optional) – Solar height above midplane in kpc. Default is 0.025.

  • R_scale (float, optional) – Disk radial scale length in kpc. Default is 2.6.

  • 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_halo

Halo number density

logp_galactic_structure

Combined disk+halo model

Notes

The disk number density follows:

\[\begin{split}n_{\\text{disk}}(R, Z) \\propto \\exp\\left(-\\frac{R_{\\text{eff}} - R_\\odot}{R_{\\text{scale}}} - \\frac{|Z| - |Z_\\odot|}{Z_{\\text{scale}}}\\right)\end{split}\]

where \(R_{\\text{eff}} = \\sqrt{R^2 + R_{\\text{smooth}}^2}\) provides smoothing near the Galactic center.

References

Bland-Hawthorn & Gerhard (2016) - The Galaxy in Context

brutus.priors.logn_halo(R, Z, R_solar=8.2, Z_solar=0.025, R_smooth=2.0, eta=4.2, q_ctr=0.2, q_inf=0.8, r_q=6.0)[source]#

Log-number density for the Galactic halo stellar population.

Implements a flattened power-law halo model with radius-dependent oblateness following observational constraints.

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 8.2.

  • Z_solar (float, optional) – Solar height above midplane in kpc. Default is 0.025.

  • R_smooth (float, optional) – Smoothing radius to avoid central singularity in kpc. Default is 2.0.

  • eta (float, optional) – Power-law index for halo density profile. Default is 4.2.

  • q_ctr (float, optional) – Halo oblateness at Galactic center. Default is 0.2.

  • q_inf (float, optional) – Halo oblateness at large radii. Default is 0.8.

  • r_q (float, optional) – Scale radius for oblateness transition in kpc. Default is 6.0.

Returns:

logn – Normalized log-number density relative to Solar neighborhood.

Return type:

array_like

See also

logn_disk

Disk number density

logp_galactic_structure

Combined disk+halo model

Notes

The halo follows a flattened power-law profile:

\[\begin{split}n_{\\text{halo}}(R, Z) \\propto R_{\\text{eff}}^{-\\eta}\end{split}\]

where the effective radius includes radius-dependent flattening:

\[ \begin{align}\begin{aligned}\begin{split}R_{\\text{eff}} = \\sqrt{R^2 + (Z/q)^2 + R_{\\text{smooth}}^2}\end{split}\\\begin{split}q(r) = q_\\infty - (q_\\infty - q_{\\text{ctr}}) e^{1 - r'/r_q}\end{split}\\\begin{split}r' = \\sqrt{r^2 + r_q^2}, \\quad r = \\sqrt{R^2 + Z^2}\end{split}\end{aligned}\end{align} \]

References

Bland-Hawthorn & Gerhard (2016) - The Galaxy in Context Bell et al. (2008) - Stellar Halo Properties from SDSS

brutus.priors.logp_feh(feh, feh_mean=-0.2, feh_sigma=0.3)[source]#

Log-prior for stellar metallicity in Galactic components.

Implements a Gaussian metallicity distribution appropriate for different Galactic stellar populations (disk, thick disk, halo).

Parameters:
  • feh (array_like) – Stellar metallicity [Fe/H] in dex.

  • feh_mean (float, optional) – Mean metallicity of the population in dex. Default is -0.2 (thin disk).

  • feh_sigma (float, optional) – Metallicity dispersion in dex. Default is 0.3.

Returns:

logp – Normalized log-probability density for the input metallicities.

Return type:

array_like

Notes

The metallicity prior follows a normal distribution:

\[\begin{split}\\log p([\\text{Fe/H}]) = -\\frac{1}{2}\\left[\\frac{([\\text{Fe/H}] - \\mu_{\\text{Fe/H}})^2}{\\sigma_{\\text{Fe/H}}^2} + \\log(2\\pi\\sigma_{\\text{Fe/H}}^2)\\right]\end{split}\]

Typical values for different Galactic components: - Thin disk: feh_mean = -0.2, feh_sigma = 0.3 - Thick disk: feh_mean = -0.7, feh_sigma = 0.4 - Halo: feh_mean = -1.6, feh_sigma = 0.5

References

Bland-Hawthorn & Gerhard (2016) - The Galaxy in Context

brutus.priors.logp_age_from_feh(age, feh_mean=-0.2, max_age=13.8, min_age=0.0, feh_age_ctr=-0.5, feh_age_scale=0.5, nsigma_from_max_age=2.0, max_sigma=4.0, min_sigma=1.0)[source]#

Log-prior for stellar age based on metallicity-age relation.

Implements the age-metallicity relation observed in the Galactic disk, where older stars tend to be more metal-poor. Uses truncated normal distribution bounded by physically reasonable ages.

Parameters:
  • age (array_like) – Stellar ages in Gyr.

  • feh_mean (float, optional) – Mean metallicity of the population in dex. Default is -0.2.

  • max_age (float, optional) – Maximum allowed stellar age in Gyr. Default is 13.8 (age of Universe).

  • min_age (float, optional) – Minimum allowed stellar age in Gyr. Default is 0.0.

  • feh_age_ctr (float, optional) – Metallicity where mean age is halfway between min/max. Default is -0.5.

  • feh_age_scale (float, optional) – Scale length for metallicity-age relation in dex. Default is 0.5.

  • nsigma_from_max_age (float, optional) – Number of σ the mean age is below max_age. Default is 2.0.

  • max_sigma (float, optional) – Maximum age dispersion in Gyr. Default is 4.0.

  • min_sigma (float, optional) – Minimum age dispersion in Gyr. Default is 1.0.

Returns:

logp – Normalized log-probability density for the input ages.

Return type:

array_like

Notes

The age-metallicity relation follows a logistic function:

\[\begin{split}\\langle t \\rangle = \\frac{t_{\\max} - t_{\\min}}{1 + \\exp\\left(\\frac{[\\text{Fe/H}] - c}{s}\\right)} + t_{\\min}\end{split}\]

where c is the central metallicity and s is the scale length.

The age dispersion decreases for younger (more metal-rich) stars:

\[\begin{split}\\sigma_t = \\min\\left(\\max\\left(\\frac{t_{\\max} - \\langle t \\rangle}{n\\sigma}, \\sigma_{\\min}\\right), \\sigma_{\\max}\\right)\end{split}\]

Ages are drawn from a truncated normal distribution bounded by [min_age, max_age].

References

Bland-Hawthorn & Gerhard (2016) - The Galaxy in Context Nordström et al. (2004) - Age-metallicity relation in Solar neighborhood

Extinction Priors#

brutus.priors.logp_extinction(avs, dustmap, coord, distance=None, return_components=False)[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), query returns (distances, av_mean, av_std) with distance-resolved profiles. For simpler maps, query returns (av_mean, av_std) scalars.

  • coord (SkyCoord or array_like) – Sky coordinates for dust map query. Accepts astropy.coordinates.SkyCoord or [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 avs and distance are 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.

Returns:

  • logp (ndarray) – Log-prior probability density for the input extinction values. Returns 0 (uniform prior) when no dust map coverage is available.

  • components (tuple, optional) – If return_components=True, returns (av_mean, av_err) containing the dust map mean and standard deviation used.

Notes

The log-prior follows a Gaussian distribution when dust map data is available:

\[\begin{split}\\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]\end{split}\]

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.

For regions without dust map coverage (NaN values), a uniform (uninformative) prior is returned.

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)

Submodules#

For advanced users who need access to internal implementations:

Stellar priors for Bayesian parameter estimation.

This module provides log-prior functions for stellar properties including the initial mass function (IMF) and luminosity functions. These priors are used in Bayesian inference of stellar parameters to incorporate physical constraints from stellar populations.

Functions#

logp_imfInitial mass function prior

Kroupa-like broken power-law IMF

logp_ps1_luminosity_functionLuminosity function prior

Pan-STARRS 1 r-band luminosity function

See also

brutus.analysis.individual.BruteForce

Uses these priors for stellar fitting

brutus.priors.galactic

Galactic structure priors

brutus.priors.extinction

Extinction priors

Notes

These priors provide physically-motivated probability distributions for stellar parameters:

  • IMF priors weight stellar masses according to population statistics, ensuring realistic mass distributions in Bayesian fits

  • Luminosity function priors weight absolute magnitudes according to observed stellar populations, useful when fitting distance and extinction

The priors are normalized and return log-probabilities suitable for direct use in MCMC or nested sampling codes.

Examples

Basic IMF prior usage:

>>> import numpy as np
>>> from brutus.priors.stellar import logp_imf
>>>
>>> # Evaluate IMF prior for solar-mass star
>>> masses = np.array([1.0])
>>> log_prior = logp_imf(masses)
>>> print(f"Log-prior for 1 solar mass: {log_prior[0]:.3f}")
>>>
>>> # Binary system with 1.0 + 0.5 solar mass components
>>> log_prior_binary = logp_imf(masses, mgrid2=np.array([0.5]))
>>> print(f"Binary log-prior: {log_prior_binary[0]:.3f}")

Luminosity function prior:

>>> from brutus.priors.stellar import logp_ps1_luminosity_function
>>>
>>> # Absolute r-band magnitude for main sequence star
>>> Mr = np.array([5.0])
>>> log_prior = logp_ps1_luminosity_function(Mr)
>>> print(f"Log-prior for Mr=5: {log_prior[0]:.3f}")
brutus.priors.stellar.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]

Log-prior for a Kroupa-like broken initial mass function.

Implements a broken power-law IMF with separate slopes for low and high stellar masses, following Kroupa (2001). Supports binary systems with a secondary mass component.

Parameters:
  • mgrid (array_like) – Grid of initial stellar masses in solar units. Must be > 0.

  • alpha_low (float, optional) – Power-law slope for low-mass stars (M ≤ mass_break). Default is 1.3 (Kroupa 2001).

  • alpha_high (float, optional) – Power-law slope for high-mass stars (M > mass_break). Default is 2.3 (Kroupa 2001).

  • mass_break (float, optional) – Transition mass between low and high mass regimes in solar units. Default is 0.5.

  • mgrid2 (array_like, optional) – Grid of secondary stellar masses for binary systems in solar units. If provided, computes joint prior for binary system.

  • mass_min (float, optional) – Minimum mass for normalization (hydrogen burning limit). Default is 0.08 solar masses.

  • mass_max (float, optional) – Maximum mass for normalization. Default is 100.0 solar masses.

Returns:

logp – Normalized log-prior probability density for the input mass grid(s). Returns -inf for masses below mass_min or above mass_max.

Return type:

array_like

See also

logp_ps1_luminosity_function

Alternative luminosity-based prior

brutus.analysis.individual.BruteForce

Uses IMF priors for fitting

Notes

The IMF follows the form:

\[\begin{split}\\xi(M) \\propto M^{-\\alpha}\end{split}\]

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.stellar.logp_ps1_luminosity_function(Mr)[source]

Pan-STARRS 1 r-band luminosity function log-prior.

Implements the stellar luminosity function derived from Pan-STARRS 1 observations, specifically calibrated for use with Bayestar stellar evolutionary models and dust maps.

Parameters:

Mr (array_like) – Absolute r-band magnitudes in the Pan-STARRS 1 photometric system.

Returns:

logp – Log-prior probability density for the given absolute magnitudes. Interpolates from empirical Pan-STARRS 1 luminosity function.

Return type:

array_like

See also

logp_imf

Alternative mass-based IMF prior

brutus.analysis.individual.BruteForce

Uses luminosity priors for fitting

Notes

This prior is designed for integration with:

  • Bayestar stellar evolutionary tracks

  • Bayestar 3D dust extinction maps

  • Pan-STARRS 1 photometric system

The luminosity function is based on empirical measurements from the Pan-STARRS 1 survey and provides realistic stellar population weights for Bayesian inference.

References

Green et al. (2015) - 3D Dust Mapping with Pan-STARRS 1 Green et al. (2018) - Bayestar dust maps

Astrometric priors for Bayesian stellar parameter estimation.

This module provides log-prior functions for astrometric measurements including parallax priors and coordinate transformations. These priors are essential for incorporating Gaia astrometry into stellar parameter estimation.

Functions#

logp_parallaxParallax prior

Gaussian prior from measured parallax

logp_parallax_scaleScale factor prior

Prior on distance scale (s = 1/d^2)

convert_parallax_to_scaleCoordinate transform

Convert parallax to flux scale factor

See also

brutus.priors.galactic

Galactic structure distance priors

brutus.analysis.individual.BruteForce

Uses parallax priors for fitting

Notes

These priors incorporate astrometric information from missions like Gaia to constrain stellar distances and luminosities.

The parallax prior is straightforward Gaussian, but care must be taken with the coordinate transformation when using scale factors (s = 1/d^2) rather than distances directly. The Jacobian must be properly accounted for.

Examples

>>> from brutus.priors.astrometric import logp_parallax
>>> import numpy as np
>>>
>>> # Gaia parallax measurement
>>> p_meas = 2.5  # mas
>>> p_err = 0.1   # mas
>>>
>>> # Evaluate prior for model parallaxes
>>> parallaxes = np.linspace(1.0, 4.0, 100)
>>> log_prior = logp_parallax(parallaxes, p_meas, p_err)
brutus.priors.astrometric.logp_parallax(parallaxes, p_meas, p_err)[source]

Log-prior for parallax measurements assuming Gaussian errors.

Implements a Gaussian log-prior based on observed parallax and measurement uncertainty. Returns uniform prior when measurements are invalid or unavailable.

Parameters:
  • parallaxes (array_like) – Model parallax values in milliarcseconds (mas).

  • p_meas (float) – Measured parallax in milliarcseconds (mas).

  • p_err (float) – Parallax measurement uncertainty in milliarcseconds (mas).

Returns:

logp – Log-prior probability density for the input parallax values. Returns 0 (uniform prior) if measurements are invalid.

Return type:

array_like

Notes

The log-prior follows a normal distribution:

\[\begin{split}\\log p(\\pi | \\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]\end{split}\]

For invalid measurements (non-finite values), returns uniform prior.

brutus.priors.astrometric.logp_parallax_scale(scales, scale_errs, p_meas, p_err, snr_lim=4.0)[source]

Log-prior for flux scale factors derived from parallax measurements.

Applies parallax constraints to flux density scale factors where scale ~ parallax². Uses Gaussian approximation for high signal-to-noise parallax measurements.

Parameters:
  • scales (array_like) – Flux density scale factors (proportional to parallax²).

  • scale_errs (array_like) – Scale factor measurement uncertainties.

  • p_meas (float) – Measured parallax in milliarcseconds (mas).

  • p_err (float) – Parallax measurement uncertainty in milliarcseconds (mas).

  • snr_lim (float, optional) – Minimum signal-to-noise ratio for applying Gaussian approximation. Below this threshold, returns uniform prior. Default is 4.0.

Returns:

logp – Log-prior probability density for the input scale factors.

Return type:

array_like

Notes

For high SNR measurements (p_meas/p_err > snr_lim), the scale factor prior is derived from the parallax measurement using error propagation:

\[ \begin{align}\begin{aligned}\begin{split}s = \\pi^2 + \\sigma_\\pi^2\end{split}\\\begin{split}\\sigma_s = \\sqrt{2\\sigma_\\pi^4 + 4\\pi^2\\sigma_\\pi^2}\end{split}\end{aligned}\end{align} \]

The total uncertainty combines model and measurement errors in quadrature.

brutus.priors.astrometric.convert_parallax_to_scale(p_meas, p_err, snr_lim=4.0)[source]

Convert parallax measurement to flux density scale factor statistics.

Transforms parallax measurements and uncertainties to scale factor (s ~ π²) mean and standard deviation using error propagation.

Parameters:
  • p_meas (float) – Measured parallax in milliarcseconds (mas).

  • p_err (float) – Parallax measurement uncertainty in milliarcseconds (mas).

  • snr_lim (float, optional) – Minimum signal-to-noise ratio for conversion. Below this threshold, returns uninformative scale factor statistics. Default is 4.0.

Returns:

  • s_mean (float) – Mean of the scale factor distribution.

  • s_std (float) – Standard deviation of the scale factor distribution.

Notes

For high SNR measurements, uses error propagation:

\[ \begin{align}\begin{aligned}\begin{split}s_{\\text{mean}} = \\max(0, \\pi_{\\text{meas}})^2 + \\sigma_\\pi^2\end{split}\\\begin{split}s_{\\text{std}} = \\sqrt{2\\sigma_\\pi^4 + 4\\pi_{\\text{meas}}^2\\sigma_\\pi^2}\end{split}\end{aligned}\end{align} \]

The parallax is floored at zero to handle negative measurements. For low SNR, returns uninformative statistics (tiny mean, huge std).

Examples

>>> s_mean, s_std = convert_parallax_to_scale(1.0, 0.1)  # 10-sigma detection
>>> print(f"Scale factor: {s_mean:.3f} ± {s_std:.3f}")

Galactic structure priors for Bayesian stellar parameter estimation.

This module provides log-prior functions for Galactic structure modeling including disk and halo number densities, metallicity distributions, and age-metallicity relations. These priors encode our knowledge of the Milky Way’s stellar populations and are essential for distance estimation.

Functions#

logn_diskDisk number density

Exponential disk model

logn_haloHalo number density

Flattened power-law halo

logp_fehMetallicity distribution

Gaussian metallicity distribution

logp_age_from_fehAge-metallicity relation

Age distribution conditional on metallicity

logp_galactic_structureCombined prior

Full Galactic structure prior combining disk and halo

See also

brutus.analysis.individual.BruteForce

Uses Galactic priors for distance fitting

brutus.priors.stellar

Stellar population priors

brutus.priors.astrometric

Parallax and proper motion priors

Notes

These priors provide critical constraints on stellar distances by incorporating knowledge of Galactic structure:

  • Number density priors (disk and halo) weight distance based on expected stellar distributions in the Galaxy

  • Metallicity priors provide realistic [Fe/H] distributions for disk and halo populations

  • Age-metallicity relations link stellar age and composition

The combined prior logp_galactic_structure integrates disk and halo models with appropriate mixing fractions.

The priors use Galactocentric coordinates, which requires coordinate transformations from equatorial coordinates and distances.

Examples

Evaluate disk number density:

>>> import numpy as np
>>> from brutus.priors.galactic import logn_disk
>>>
>>> # Position in Galactic disk
>>> R = np.array([8.0])  # kpc from Galactic center
>>> Z = np.array([0.1])  # kpc above midplane
>>> log_density = logn_disk(R, Z)
>>> print(f"Log-density: {log_density[0]:.3f}")

Combined Galactic structure prior:

>>> from brutus.priors.galactic import logp_galactic_structure
>>>
>>> # Galactic coordinates (l, b) in degrees and distances in kpc
>>> coord = (90.0, 30.0)
>>> distances = np.array([1.0, 2.0, 5.0])
>>>
>>> # Evaluate the combined thin disk + thick disk + halo prior
>>> log_prior = logp_galactic_structure(distances, coord)
brutus.priors.galactic.logn_disk(R, Z, R_solar=8.2, Z_solar=0.025, R_scale=2.6, Z_scale=0.3, R_smooth=2.0)[source]

Log-number density for the Galactic disk stellar population.

Implements an 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 8.2.

  • Z_solar (float, optional) – Solar height above midplane in kpc. Default is 0.025.

  • R_scale (float, optional) – Disk radial scale length in kpc. Default is 2.6.

  • 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_halo

Halo number density

logp_galactic_structure

Combined disk+halo model

Notes

The disk number density follows:

\[\begin{split}n_{\\text{disk}}(R, Z) \\propto \\exp\\left(-\\frac{R_{\\text{eff}} - R_\\odot}{R_{\\text{scale}}} - \\frac{|Z| - |Z_\\odot|}{Z_{\\text{scale}}}\\right)\end{split}\]

where \(R_{\\text{eff}} = \\sqrt{R^2 + R_{\\text{smooth}}^2}\) provides smoothing near the Galactic center.

References

Bland-Hawthorn & Gerhard (2016) - The Galaxy in Context

brutus.priors.galactic.logn_halo(R, Z, R_solar=8.2, Z_solar=0.025, R_smooth=2.0, eta=4.2, q_ctr=0.2, q_inf=0.8, r_q=6.0)[source]

Log-number density for the Galactic halo stellar population.

Implements a flattened power-law halo model with radius-dependent oblateness following observational constraints.

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 8.2.

  • Z_solar (float, optional) – Solar height above midplane in kpc. Default is 0.025.

  • R_smooth (float, optional) – Smoothing radius to avoid central singularity in kpc. Default is 2.0.

  • eta (float, optional) – Power-law index for halo density profile. Default is 4.2.

  • q_ctr (float, optional) – Halo oblateness at Galactic center. Default is 0.2.

  • q_inf (float, optional) – Halo oblateness at large radii. Default is 0.8.

  • r_q (float, optional) – Scale radius for oblateness transition in kpc. Default is 6.0.

Returns:

logn – Normalized log-number density relative to Solar neighborhood.

Return type:

array_like

See also

logn_disk

Disk number density

logp_galactic_structure

Combined disk+halo model

Notes

The halo follows a flattened power-law profile:

\[\begin{split}n_{\\text{halo}}(R, Z) \\propto R_{\\text{eff}}^{-\\eta}\end{split}\]

where the effective radius includes radius-dependent flattening:

\[ \begin{align}\begin{aligned}\begin{split}R_{\\text{eff}} = \\sqrt{R^2 + (Z/q)^2 + R_{\\text{smooth}}^2}\end{split}\\\begin{split}q(r) = q_\\infty - (q_\\infty - q_{\\text{ctr}}) e^{1 - r'/r_q}\end{split}\\\begin{split}r' = \\sqrt{r^2 + r_q^2}, \\quad r = \\sqrt{R^2 + Z^2}\end{split}\end{aligned}\end{align} \]

References

Bland-Hawthorn & Gerhard (2016) - The Galaxy in Context Bell et al. (2008) - Stellar Halo Properties from SDSS

brutus.priors.galactic.logp_feh(feh, feh_mean=-0.2, feh_sigma=0.3)[source]

Log-prior for stellar metallicity in Galactic components.

Implements a Gaussian metallicity distribution appropriate for different Galactic stellar populations (disk, thick disk, halo).

Parameters:
  • feh (array_like) – Stellar metallicity [Fe/H] in dex.

  • feh_mean (float, optional) – Mean metallicity of the population in dex. Default is -0.2 (thin disk).

  • feh_sigma (float, optional) – Metallicity dispersion in dex. Default is 0.3.

Returns:

logp – Normalized log-probability density for the input metallicities.

Return type:

array_like

Notes

The metallicity prior follows a normal distribution:

\[\begin{split}\\log p([\\text{Fe/H}]) = -\\frac{1}{2}\\left[\\frac{([\\text{Fe/H}] - \\mu_{\\text{Fe/H}})^2}{\\sigma_{\\text{Fe/H}}^2} + \\log(2\\pi\\sigma_{\\text{Fe/H}}^2)\\right]\end{split}\]

Typical values for different Galactic components: - Thin disk: feh_mean = -0.2, feh_sigma = 0.3 - Thick disk: feh_mean = -0.7, feh_sigma = 0.4 - Halo: feh_mean = -1.6, feh_sigma = 0.5

References

Bland-Hawthorn & Gerhard (2016) - The Galaxy in Context

brutus.priors.galactic.logp_age_from_feh(age, feh_mean=-0.2, max_age=13.8, min_age=0.0, feh_age_ctr=-0.5, feh_age_scale=0.5, nsigma_from_max_age=2.0, max_sigma=4.0, min_sigma=1.0)[source]

Log-prior for stellar age based on metallicity-age relation.

Implements the age-metallicity relation observed in the Galactic disk, where older stars tend to be more metal-poor. Uses truncated normal distribution bounded by physically reasonable ages.

Parameters:
  • age (array_like) – Stellar ages in Gyr.

  • feh_mean (float, optional) – Mean metallicity of the population in dex. Default is -0.2.

  • max_age (float, optional) – Maximum allowed stellar age in Gyr. Default is 13.8 (age of Universe).

  • min_age (float, optional) – Minimum allowed stellar age in Gyr. Default is 0.0.

  • feh_age_ctr (float, optional) – Metallicity where mean age is halfway between min/max. Default is -0.5.

  • feh_age_scale (float, optional) – Scale length for metallicity-age relation in dex. Default is 0.5.

  • nsigma_from_max_age (float, optional) – Number of σ the mean age is below max_age. Default is 2.0.

  • max_sigma (float, optional) – Maximum age dispersion in Gyr. Default is 4.0.

  • min_sigma (float, optional) – Minimum age dispersion in Gyr. Default is 1.0.

Returns:

logp – Normalized log-probability density for the input ages.

Return type:

array_like

Notes

The age-metallicity relation follows a logistic function:

\[\begin{split}\\langle t \\rangle = \\frac{t_{\\max} - t_{\\min}}{1 + \\exp\\left(\\frac{[\\text{Fe/H}] - c}{s}\\right)} + t_{\\min}\end{split}\]

where c is the central metallicity and s is the scale length.

The age dispersion decreases for younger (more metal-rich) stars:

\[\begin{split}\\sigma_t = \\min\\left(\\max\\left(\\frac{t_{\\max} - \\langle t \\rangle}{n\\sigma}, \\sigma_{\\min}\\right), \\sigma_{\\max}\\right)\end{split}\]

Ages are drawn from a truncated normal distribution bounded by [min_age, max_age].

References

Bland-Hawthorn & Gerhard (2016) - The Galaxy in Context Nordström et al. (2004) - Age-metallicity relation in Solar neighborhood

brutus.priors.galactic.logp_galactic_structure(dists, coord, labels=None, R_solar=8.2, Z_solar=0.025, R_thin=2.6, Z_thin=0.3, Rs_thin=2.0, R_thick=2.0, Z_thick=0.9, f_thick=0.04, Rs_thick=2.0, Rs_halo=2.0, q_halo_ctr=0.2, q_halo_inf=0.8, r_q_halo=6.0, eta_halo=4.2, f_halo=0.005, feh_thin=-0.2, feh_thin_sigma=0.3, feh_thick=-0.7, feh_thick_sigma=0.4, feh_halo=-1.6, feh_halo_sigma=0.5, max_age=13.8, min_age=0.0, feh_age_ctr=-0.5, feh_age_scale=0.5, nsigma_from_max_age=2.0, max_sigma=4.0, min_sigma=1.0, return_components=False)[source]

Complete Galactic structure log-prior with thin disk, thick disk, and halo.

Implements a sophisticated three-component Galactic model based on Bland-Hawthorn & Gerhard (2016). Combines spatial number density priors with optional metallicity and age priors for realistic stellar populations.

Parameters:
  • dists (array_like) – Distance from observer in kpc.

  • coord (tuple of floats) – Galactic coordinates (l, b) in degrees.

  • labels (structured array, optional) – Stellar labels containing ‘feh’ and/or ‘loga’ for metallicity/age priors.

  • R_solar (float, optional) – Solar Galactocentric radius in kpc. Default is 8.2.

  • Z_solar (float, optional) – Solar height above midplane in kpc. Default is 0.025.

  • R_thin (float, optional) – Thin disk radial scale length in kpc. Default is 2.6.

  • Z_thin (float, optional) – Thin disk vertical scale height in kpc. Default is 0.3.

  • Rs_thin (float, optional) – Thin disk smoothing radius in kpc. Default is 2.0.

  • R_thick (float, optional) – Thick disk radial scale length in kpc. Default is 2.0.

  • Z_thick (float, optional) – Thick disk vertical scale height in kpc. Default is 0.9.

  • f_thick (float, optional) – Thick disk relative normalization. Default is 0.04.

  • Rs_thick (float, optional) – Thick disk smoothing radius in kpc. Default is 2.0.

  • Rs_halo (float, optional) – Halo smoothing radius in kpc. Default is 2.0.

  • q_halo_ctr (float, optional) – Halo central oblateness. Default is 0.2.

  • q_halo_inf (float, optional) – Halo asymptotic oblateness. Default is 0.8.

  • r_q_halo (float, optional) – Halo oblateness transition radius in kpc. Default is 6.0.

  • eta_halo (float, optional) – Halo power-law index. Default is 4.2.

  • f_halo (float, optional) – Halo relative normalization. Default is 0.005.

  • feh_thin (float, optional) – Thin disk mean metallicity in dex. Default is -0.2.

  • feh_thin_sigma (float, optional) – Thin disk metallicity dispersion in dex. Default is 0.3.

  • feh_thick (float, optional) – Thick disk mean metallicity in dex. Default is -0.7.

  • feh_thick_sigma (float, optional) – Thick disk metallicity dispersion in dex. Default is 0.4.

  • feh_halo (float, optional) – Halo mean metallicity in dex. Default is -1.6.

  • feh_halo_sigma (float, optional) – Halo metallicity dispersion in dex. Default is 0.5.

  • max_age (float, optional) – Maximum stellar age in Gyr. Default is 13.8.

  • min_age (float, optional) – Minimum stellar age in Gyr. Default is 0.0.

  • feh_age_ctr (float, optional) – Central metallicity for age-metallicity relation. Default is -0.5.

  • feh_age_scale (float, optional) – Scale length for age-metallicity relation. Default is 0.5.

  • nsigma_from_max_age (float, optional) – Age dispersion parameter. Default is 2.0.

  • max_sigma (float, optional) – Maximum age dispersion in Gyr. Default is 4.0.

  • min_sigma (float, optional) – Minimum age dispersion in Gyr. Default is 1.0.

  • return_components (bool, optional) – Whether to return individual component contributions. Default is False.

Returns:

  • logp (array_like) – Total log-prior probability density.

  • components (dict, optional) – Individual component contributions (if return_components=True).

Notes

The Galactic model combines three stellar populations:

  1. Thin Disk: Young, metal-rich stars with small scale height

  2. Thick Disk: Intermediate-age, metal-poor stars with larger scale height

  3. Halo: Old, very metal-poor stars with flattened power-law profile

Each component has distinct spatial, metallicity, and age distributions calibrated from observations. The model accounts for:

  • Coordinate transformations from observer to Galactocentric frame

  • Volume correction factors (dV ∝ distance²)

  • Component membership probabilities

  • Conditional metallicity and age priors

When stellar labels are provided, applies population-specific priors: - Metallicity: Gaussian distributions with different means/dispersions - Age: Age-metallicity relation with truncated normal distributions

References

Bland-Hawthorn & Gerhard (2016) - The Galaxy in Context

Extinction priors for Bayesian stellar parameter estimation.

This module provides log-prior functions for dust extinction modeling using 3D dust maps. These priors incorporate spatial dust distribution information to constrain extinction in stellar fitting.

Functions#

logp_extinctionDust map extinction prior

Gaussian prior from 3D dust maps (e.g., Bayestar)

See also

brutus.dust.maps

3D dust map utilities

brutus.priors.galactic

Galactic structure priors

brutus.analysis.individual.BruteForce

Uses extinction priors for fitting

Notes

The extinction prior uses 3D dust maps (e.g., Bayestar from Green et al. 2015, 2018) which provide distance-dependent extinction estimates across the sky.

The prior is Gaussian when dust map data is available, and uniform when coverage is unavailable. This gracefully handles regions outside the mapped volume.

Examples

>>> from brutus.priors.extinction import logp_extinction
>>> from brutus.dust import Bayestar
>>> import numpy as np
>>>
>>> # Load 3D dust map and evaluate extinction prior at a distance
>>> # dustmap = Bayestar('bayestar2019_v1.h5')
>>> # logp = logp_extinction([0.1, 0.5], dustmap, [180.0, 30.0], distance=1.0)
brutus.priors.extinction.logp_extinction(avs, dustmap, coord, distance=None, return_components=False)[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), query returns (distances, av_mean, av_std) with distance-resolved profiles. For simpler maps, query returns (av_mean, av_std) scalars.

  • coord (SkyCoord or array_like) – Sky coordinates for dust map query. Accepts astropy.coordinates.SkyCoord or [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 avs and distance are 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.

Returns:

  • logp (ndarray) – Log-prior probability density for the input extinction values. Returns 0 (uniform prior) when no dust map coverage is available.

  • components (tuple, optional) – If return_components=True, returns (av_mean, av_err) containing the dust map mean and standard deviation used.

Notes

The log-prior follows a Gaussian distribution when dust map data is available:

\[\begin{split}\\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]\end{split}\]

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.

For regions without dust map coverage (NaN values), a uniform (uninformative) prior is returned.

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)