amoeba2
Automated Molecular Excitation Bayesian line-fitting Algorithm
amoeba2 is a Bayesian model of the 1612, 1665, 1667, and 1720 MHz hyperfine transitions of OH written in the bayes_spec spectral line modeling framework. amoeba2 is inspired by AMOEBA and Petzler et al. (2021).
Read below to get started, and check out the tutorials here: https://amoeba2.readthedocs.io
- Installation
- Notes on Physics & Radiative Transfer
- Models
- Syntax & Examples
- Issues and Contributing
- License and Copyright
Installation
Basic Installation
Install with pip in a conda virtual environment:
conda create --name amoeba2 -c conda-forge pymc pytensor pip
conda activate amoeba2
pip install amoeba2
Development Installation
Alternatively, download and unpack the latest release, or fork the repository and contribute to the development of amoeba2!
Install in a conda virtual environment:
cd /path/to/amoeba2
conda env create -f environment.yml
conda activate amoeba2-dev
pip install -e .
Notes on Physics & Radiative Transfer
All models in amoeba2 apply the same physics and equations of radiative transfer.
The transition optical depth is taken from Magnum & Shirley (2015) equation 29. The excitation temperature is allowed to vary between transitions (a non-LTE assumption) and clouds. The excitation temperatures of the 1612, 1665, and 1667 MHz transitions are free, whereas that of the 1720 MHz transition is derived from the excitation temperature sum rule.
The radiative transfer is calculated explicitly assuming an off-source background temperature bg_temp (see below) similar to Magnum & Shirley (2015) equation 23. By default, the clouds are ordered from nearest to farthest, so optical depth effects (i.e., self-absorption) may be present.
Notably, since these are forward models, we do not make assumptions regarding the optical depth or the Rayleigh-Jeans limit. These effects are predicted by the model. There is one exception: the ordered argument, described below.
Models
The models provided by amoeba2 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 amoeba2.
AbsorptionModel
AbsorptionModel is a model that predicts the OH hyperfine absorption (1-exp(-tau)) spectra. The SpecData keys for this model must be "absorption_1612", "absorption_1665", "absorption_1667", and "absorption_1720". 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.
Cloud Parametervariable |
Parameter | Units | Prior, where ($p_0, p_1, \dots$) = prior_{variable} |
Defaultprior_{variable} |
|---|---|---|---|---|
tau |
Line-center optical depth | `` | $\tau \sim {\rm Normal}(\mu=p_0, \sigma=p_1)$ | [0.1, 0.1] |
log10_depth |
log10 line-of-sight depth | pc |
$\log_{10} d \sim {\rm Normal}(\mu=p_0, \sigma=p_1)$ | [0.0, 0.25] |
log10_Tkin |
log10 kinetic temperature | K |
$\log_{10} T_K \sim {\rm Normal}(\mu=p_0, \sigma=p_1)$ | [2.0, 1.0] |
velocity |
Velocity | km s-1 |
$V \sim {\rm Normal}(\mu=p_0, \sigma=p_1)$ | [0.0, 10.0] |
Hyper Parametervariable |
Parameter | Units | Prior, where ($p_0, p_1, \dots$) = prior_{variable} |
Defaultprior_{variable} |
|---|---|---|---|---|
log10_nth_fwhm_1pc |
Non-thermal broadening at 1 pc | km s-1 |
$\log_{10}\Delta V_{\rm 1 pc} \sim {\rm Normal}(\mu=p_0, \sigma=p_1)$ | [0.2, 0.1] |
log10_depth_nth_fwhm_power |
Non-thermal broadening vs. depth power law index | `` | $\alpha \sim {\rm Normal}(\mu=p_0, \sigma=p_1)$ | [0.4, 0.1] |
baseline_coeffs |
Normalized polynomial baseline coefficients | `` | $\beta_i \sim {\rm Normal}(mu=0, \sigma=p_i)$ | [1.0]*(baseline_degree + 1) |
mainline_pos_tau
An additional parameter to AbsorptionModel is mainline_pos_tau. If True, then the mainline (1665 MHz and 1667 MHz) optical depths are required to be positive by changing the prior distribution as follows.
Cloud Parametervariable |
Parameter | Units | Prior, where ($p_0, p_1, \dots$) = prior_{variable} |
Defaultprior_{variable} |
|---|---|---|---|---|
tau |
Line-center optical depth | `` | $\tau \sim {\rm HalfNormal}(\sigma=p_1)$ | [0.1, 0.1] |
EmissionAbsorptionModel
EmissionAbsorptionModel is a more physically motivated model that also predicts the brightness temperature spectra assuming a given background source brightness temperature (where bg_temp is in K and is supplied during model initialization; EmissionAbsorptionModel(bg_temp=3.77) is the default). The SpecData keys for this model must be "absorption_1612", "absorption_1665", "absorption_1667", "absorption_1720", "emission_1612", "emission_1665", "emission_1667", and "emission_1720". The following diagram demonstrates the model, and the subsequent table describe the additional model parameters.
Cloud Parametervariable |
Parameter | Units | Prior, where ($p_0, p_1, \dots$) = prior_{variable} |
Defaultprior_{variable} |
|---|---|---|---|---|
log10_N0 |
log10 column density in lowest energy state | cm-2 |
$\log_{10} N_0 \sim {\rm Normal}(\mu=p_0, \sigma=p_1)$ | [13.0, 1.0] |
log_boltz_factor |
log Boltzmann factor (-h*freq/(k*Tex)) |
`` | $\ln B \sim {\rm Normal}(\mu=p_0, \sigma=p_1) | [-0.1, 0.1] |
log10_depth |
log10 line-of-sight depth | pc |
$\log_{10} d \sim {\rm Normal}(\mu=p_0, \sigma=p_1)$ | [0.0, 0.25] |
log10_Tkin |
log10 kinetic temperature | K |
$\log_{10} T_K \sim {\rm Normal}(\mu=p_0, \sigma=p_1)$ | [2.0, 1.0] |
velocity |
Velocity | km s-1 |
$V \sim {\rm Normal}(\mu=p_0, \sigma=p_1)$ | [0.0, 10.0] |
Hyper Parametervariable |
Parameter | Units | Prior, where ($p_0, p_1, \dots$) = prior_{variable} |
Defaultprior_{variable} |
|---|---|---|---|---|
log10_nth_fwhm_1pc |
Non-thermal broadening at 1 pc | km s-1 |
$\log_{10}\Delta V_{\rm 1 pc} \sim {\rm Normal}(\mu=p_0, \sigma=p_1)$ | [0.2, 0.1] |
log10_depth_nth_fwhm_power |
Non-thermal broadening vs. depth power law index | `` | $\alpha \sim {\rm Normal}(\mu=p_0, \sigma=p_1)$ | [0.4, 0.1] |
baseline_coeffs |
Normalized polynomial baseline coefficients | `` | $\beta_i \sim {\rm Normal}(mu=0, \sigma=p_i)$ | [1.0]*(baseline_degree + 1) |
mainline_pos_tau
An additional parameter to EmissionAbsorptionModel is mainline_pos_tau. If True, then the mainline (1665 MHz and 1667 MHz) optical depths are required to be positive by changing the prior distribution as follows.
Cloud Parametervariable |
Parameter | Units | Prior, where ($p_0, p_1, \dots$) = prior_{variable} |
Defaultprior_{variable} |
|---|---|---|---|---|
log_boltz_factor |
log Boltzmann factor (h*freq/(k*Tex)) |
`` | $\ln B \sim {\rm HalfNormal}(\sigma=p_1) | [0.1, 0.1] |
ordered
An additional parameter to set_priors for both the AbsorptionModel and EmissionAbsorptionModel is ordered. By default, this parameter is False, in which case the order of the clouds is from nearest to farthest. 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. This assumption can drastically improve sampling efficiency. When ordered=True, the velocity prior is defined differently:
Cloud Parametervariable |
Parameter | Units | Prior, where ($p_0, p_1, \dots$) = prior_{variable} |
Defaultprior_{variable} |
|---|---|---|---|---|
velocity |
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, 1.0] |
Syntax & Examples
See the various tutorial notebooks under docs/source/notebooks. Tutorials and the full API are available here: https://amoeba2.readthedocs.io.
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 by Trey V. Wenger; tvwenger@gmail.com. This code is licensed under MIT license (see LICENSE for details)
Release files for amoeba2 1.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| amoeba2-1.1.1.tar.gz | 37.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| amoeba2-1.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 54.6 kB
Release files / amoeba2-1.1.1.tar.gz
| Download URL | amoeba2-1.1.1.tar.gz |
|---|---|
| Size | 37.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
498dbf0ae9ad05f37a5361c6d81f942f8b7a0a90d3cca2d67fe10e87fb752354
|
|
BLAKE2b-256 checksum How to use checksums |
2ed59b83922fa7912e1bd11e4960430850e3d88340d38180a7dec5533a20549f
|
| 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 Dec 10, 2024.
Transparency logRelease files / amoeba2-1.1.1-py3-none-any.whl
| Download URL | amoeba2-1.1.1-py3-none-any.whl |
|---|---|
| Size | 17.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f178089d3ccb5a6fdf19543ff751620fdc7717db122867a2fb881def822e8ec0
|
|
BLAKE2b-256 checksum How to use checksums |
04b900c3c4c597c4e3a453c1eff8486ecb2e5ad67faef514a0b8821e39148ca0
|
| 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 Dec 10, 2024.
Transparency log