Skip to main content

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. 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}
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)

Release files for bayes-yplus 1.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bayes-yplus 1.3.2
File Size Uploaded
bayes_yplus-1.3.2.tar.gz 27.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bayes-yplus 1.3.2
File Interpreter ABI Platform
bayes_yplus-1.3.2-py3-none-any.whl Python 3 none any Details

Total release size: 36.5 kB

Release files / bayes_yplus-1.3.2.tar.gz

Download URL bayes_yplus-1.3.2.tar.gz
Size 27.9 kB
Tags Source
SHA-256 checksum
How to use checksums
f8dd7e62882a4d84edf1cd459bbcbc2322470152445411876bb1058ac0d83c85
BLAKE2b-256 checksum
How to use checksums
230e8f3bc4d6652a1cbed6d9432708115c2308dd35726da478a47b0d21ec3694
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.0.1 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 10, 2025.

Transparency log

Release files / bayes_yplus-1.3.2-py3-none-any.whl

Download URL bayes_yplus-1.3.2-py3-none-any.whl
Size 8.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
65662102fd9e947dc0ce6969f6538dbea29da495add56b8fb67ce26a6ce3fd9d
BLAKE2b-256 checksum
How to use checksums
bd5b65b4d045ec5484f13004c9ded09d9ef70bbe8033d26c56a95dc2197c0aa4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.0.1 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 10, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

1.3.2 This release

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page