Skip to main content

A Bayesian Model of Radio Recombination Line Emission

Project description

bayes_yplus

publish tests Documentation Status codecov

A Bayesian Model of Radio Recombination Line Emission

bayes_yplus implements models to infer the helium abundance (y+) from radio recombination line (RRL) observations.

Installation

Basic Installation

Install with pip in a conda virtual environment:

conda create --name bayes_yplus -c conda-forge pymc pip
conda activate bayes_yplus
pip install bayes_yplus

Development Installation

Alternatively, download and unpack the latest release, or fork the repository and contribute to the development of bayes_yplus!

Install in a conda virtual environment:

cd /path/to/bayes_yplus
conda env create -f environment.yml
conda activate bayes_yplus-dev
pip install -e .

Notes on Physics & Radiative Transfer

All models in bayes_yplus assume the emission is optically thin. The helium RRL is assumed to have a fixed centroid velocity -122.15 km/s from that of the hydrogen RRL.

Models

The models provided by bayes_yplus are implemented in the bayes_spec framework. bayes_spec assumes that the source of spectral line emission can be decomposed into a series of "clouds", each of which is defined by a set of model parameters. Here we define the models available in bayes_yplus.

Model Notes

  1. The velocity of a cloud can be challenging to identify when spectral lines are narrow and widely separated. We overcome this limitation by modeling the line profiles as a "pseudo-Voight" profile, which is a linear combination of a Gaussian and Lorentzian profile. The parameter fwhm_L is a latent hyper-parameter (shared among all clouds) that characterizes the width of the Lorentzian part of the line profile. When fwhm_L is zero, the line is perfectly Gaussian. This parameter produces line profile wings that may not be physical but nonetheless enable the optimization algorithms (i.e, MCMC) to converge more reliably and efficiently. Model solutions with fwhm_L much larger than the channel size should be scrutinized carefully.
  2. By default, the spectral RMS noise is not inferred, rather it is taken from the noise attribute of the passed SpecData datasets. If prior_rms is not None, then the spectral RMS noise of each dataset is inferred.

YPlusModel

The basic model is YPlusModel. The model assumes that the emission can be explained by hydrogen and helium RRL emission from discrete clouds. The following diagram demonstrates the relationship between the free parameters (empty ellipses), deterministic quantities (rectangles), model predictions (filled ellipses), and observations (filled, round rectangles). Many of the parameters are internally normalized (and thus have names like _norm). The subsequent tables describe the model parameters in more detail.

hfs model graph

Cloud Parameter
variable
Parameter Units Prior, where
($p_0, p_1, \dots$) = prior_{variable}
Default
prior_{variable}
H_area H RRL line area mK km s-1 $\int T_{B, \rm H} dV \sim {\rm HalfNormal}(\sigma=p)$ 1000.0
H_center H RRL center velocity km s-1 $V_{\rm LSR, H} \sim {\rm Normal}(\mu=p_0, \sigma=p_1)$ [0.0, 25.0]
H_fwhm H RRL FWHM line width km s-1 $\Delta V_{\rm H} \sim {\rm Gamma}(\mu=p_0, \sigma=p_1)$ [25.0, 10.0]
He_H_fwhm_ratio He/H FWHM line width ratio `` $\Delta V_{\rm He}/\Delta V_{\rm H} \sim {\rm Gamma}(\mu=p_0, \sigma=p_1)$ [1.0, 0.1]
yplus He$^+/$H$^+$ abundance by number `` $y^+ \sim {\rm HalfNormal}(\sigma=p)$ 0.05
Hyper Parameter
variable
Parameter Units Prior, where
($p_0, p_1, \dots$) = prior_{variable}
Default
prior_{variable}
fwhm_L Lorentzian FWHM line width km s-1 $\Delta V_{L} \sim {\rm HalfNormal}(\sigma=p)$ 1.0
rms Spectral rms noise mK ${\rm rms} \sim {\rm HalfNormal}(\sigma=p)$ 0.01
baseline_coeffs Normalized polynomial baseline coefficients `` $\beta_i \sim {\rm Normal}(\mu=0.0, \sigma=p_i)$ [1.0]*(baseline_degree + 1)

ordered

An additional parameter to set_priors for these models is ordered. By default, this parameter is False, in which case the order of the clouds is arbitrary. Sampling from these models can be challenging due to the labeling degeneracy: if the order of clouds does not matter (i.e., the emission is optically thin), then each Markov chain could decide on a different, equally-valid order of clouds.

If we assume that the emission is optically thin, then we can set ordered=True, in which case the order of clouds is restricted to be increasing with velocity. When ordered=True, the velocity prior is defined differently:

Cloud Parameter
variable
Parameter Units Prior, where
($p_0, p_1, \dots$) = prior_{variable}
Default
prior_{variable}
H_center H RRL center velocity km s-1 $V_i \sim p_0 + \sum_0^{i-1} V_i + {\rm Gamma}(\alpha=2, \beta=1.0/p_1)$ [0.0, 25.0]

Syntax & Examples

See the various notebooks under examples for demonstrations of these models.

Issues and Contributing

Anyone is welcome to submit issues or contribute to the development of this software via Github.

License and Copyright

Copyright(C) 2024-2025 by Trey V. Wenger

This code is licensed under MIT license (see LICENSE for details)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bayes_yplus-1.3.0.tar.gz (31.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bayes_yplus-1.3.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file bayes_yplus-1.3.0.tar.gz.

File metadata

  • Download URL: bayes_yplus-1.3.0.tar.gz
  • Upload date:
  • Size: 31.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for bayes_yplus-1.3.0.tar.gz
Algorithm Hash digest
SHA256 9705dd483249fb30695e2348d4050df59735f732061d59742b0a50338983e0db
MD5 7e3f88800b0c7cbe0af148462401b16a
BLAKE2b-256 7f0338acc5428b3594ddf4b2724a23ac79ad5758157d03ec912a7a2c75354e33

See more details on using hashes here.

Provenance

The following attestation bundles were made for bayes_yplus-1.3.0.tar.gz:

Publisher: publish.yml on tvwenger/bayes_yplus

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bayes_yplus-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: bayes_yplus-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for bayes_yplus-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2f2a5bc83541d54e84ee2517d18d0e84b919d346c7e813487f582b1a0125a037
MD5 3813d2abfcee17247f873d610182b471
BLAKE2b-256 1ff47e6e9d67e5b0159a92f928833d907ea48318fa8725725919a2e30ad5e175

See more details on using hashes here.

Provenance

The following attestation bundles were made for bayes_yplus-1.3.0-py3-none-any.whl:

Publisher: publish.yml on tvwenger/bayes_yplus

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page