Unified liNe Integration Turbo Engine
Project description
unite — Unified liNe Integration Turbo Engine
unite is a Python package for fast, Bayesian inference of emission lines from astronomical spectra. It is built on JAX, NumPyro, and Astropy, and supports fitting multiple spectra simultaneously with shared kinematics, calibration tokens, and flexible priors.
Originally designed for JWST/NIRSpec but extensible to any spectrograph.
What it does
- Two pixel-integration modes: analytic (exact CDF-based, default) and numerical LSF convolution (
n_superuniform fine-grid points per pixel + banded wavelength-varying Gaussian convolution, correctly computesLSF ⊗ [F · exp(-τ · φ_intrinsic)]for absorption lines) - Simultaneous multi-spectrum fitting across gratings and instruments with shared kinematic parameters (redshift, FWHM)
- Multiple line profiles: Gaussian, Cauchy, Pseudo-Voigt, Laplace, SEMG, Gauss-Hermite, Split-Normal, Skew-Normal, Skew-Voigt, Box-Gauss, Gaussian-Split-Laplace (asymmetric EMG)
- Emission and absorption lines: flux-parametrized additive profiles and tau-parametrized multiplicative transmission
exp(-tau * phi), with per-component depth ordering (zorder) so each absorber selectively attenuates only the sources behind it - Flexible continuum models: Linear, Polynomial, Chebyshev, Bernstein, B-Spline, Power-Law, Blackbody, Modified Blackbody, Attenuated Blackbody, Template (user-supplied file) — auto-generated from line configurations
- Calibration tokens (flux scale, resolution scale, pixel offset) with free or fixed priors, shared across spectra
- YAML serialization for reproducible, human-editable configurations
- User-controlled sampler —
ModelBuilderreturns(model_fn, model_args)for use with any NumPyro backend (NUTS, SVI, nested sampling, ...) - Instrument support for JWST/NIRSpec (all gratings + PRISM), SDSS, and any custom spectrograph via generic dispersers
Installation
pip install unite
Or with Pixi:
pixi add unite --pypi
Quick Start
import jax
import astropy.units as u
from numpyro import infer
from unite import line, model, prior
from unite.continuum import ContinuumConfiguration, Linear
from unite.instrument import nirspec
from unite.results import make_parameter_table, make_spectra_tables
from unite.spectrum import Spectra, from_DJA
# 1. Configure lines with shared kinematics
z = line.Redshift('z', prior=prior.Uniform(-0.005, 0.005))
fwhm = line.FWHM('narrow', prior=prior.Uniform(100, 1000))
lc = line.LineConfiguration()
lc.add_line(
'H_alpha',
6563.0 * u.AA,
redshift=z,
fwhm_gauss=fwhm,
flux=line.Flux(prior=prior.Uniform(0, 10))
)
lc.add_line(
'NII_6585',
6585.0 * u.AA,
redshift=z,
fwhm_gauss=fwhm,
flux=line.Flux(prior=prior.Uniform(0, 10))
)
# Tau-parametrized absorption line: transmission = exp(-tau * phi)
lc.add_line(
'HI_abs',
6563.0 * u.AA,
redshift=z,
fwhm_gauss=line.FWHM('abs', prior=prior.Uniform(50, 500)),
tau=line.Tau(prior=prior.Uniform(0, 5))
)
cc = ContinuumConfiguration.from_lines(lc.centers, width=15_000*u.km/u.s, form=Linear())
# 2. Load spectra (NIRSpec example; any instrument works)
g395m = nirspec.G395M()
spec = from_DJA('dja-spectrum.fits', disperser=g395m)
spectra = Spectra([spec], redshift=5.28)
filtered_lines, filtered_cont = spectra.prepare(lc, cc)
spectra.compute_scales(filtered_lines, filtered_cont, error_scale=True)
# 3. Build and run with any NumPyro sampler
# integration_mode='analytic' (default) uses exact CDF integration;
# integration_mode='convolution' convolves intrinsic model with LSF on a fine grid
# (n_super uniform points per pixel) — most accurate for absorption lines
builder = model.ModelBuilder(filtered_lines, filtered_cont, spectra)
model_fn, model_args = builder.build(integration_mode='analytic')
mcmc = infer.MCMC(infer.NUTS(model_fn), num_warmup=500, num_samples=1000)
mcmc.run(jax.random.PRNGKey(0), model_args)
# 4. Extract results
# Get summary statistics at specific percentiles
samples = mcmc.get_samples()
param_table = make_parameter_table(samples, model_args, percentiles=[0.16, 0.5, 0.84])
spectra_tables = make_spectra_tables(samples, model_args, percentiles=[0.16, 0.5, 0.84])
Contributing
Bug reports, feature requests, and pull requests are welcome on GitHub. If you find a bug or have an idea for an improvement, please open an issue — even a brief description is helpful.
Documentation
Full documentation, tutorials, and API reference at unite.readthedocs.io.
Citing
If you use unite in your research, please cite the Zenodo software release. Each versioned release has a unique DOI minted automatically when a GitHub release is created.
See CITATION.md for BibTeX and details. The Zenodo record lists all releases — visit the link to cite a specific version. GitHub's "Cite this repository" button (top-right of the repo page) also generates citation text directly from CITATION.cff.
License
GPL v3 or later. See LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file unite-3.0.0.tar.gz.
File metadata
- Download URL: unite-3.0.0.tar.gz
- Upload date:
- Size: 1.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
34c6c7b322eec1c34f41f9bc618fc04121ba9d242e725e93e8c2c8a02cc60af0
|
|
| MD5 |
a78cfe9701aa132bb1fef5b6a117b971
|
|
| BLAKE2b-256 |
18b5904ab02c91962ee0edf2d6e87095f71d9b64b469659069722c4fcb0cb659
|
Provenance
The following attestation bundles were made for unite-3.0.0.tar.gz:
Publisher:
publish.yml on TheSkyentist/unite
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
unite-3.0.0.tar.gz -
Subject digest:
34c6c7b322eec1c34f41f9bc618fc04121ba9d242e725e93e8c2c8a02cc60af0 - Sigstore transparency entry: 1573473809
- Sigstore integration time:
-
Permalink:
TheSkyentist/unite@f5eddb0bdf64c2cc8490aa33dcc56386f573102c -
Branch / Tag:
refs/tags/v3.0.0 - Owner: https://github.com/TheSkyentist
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f5eddb0bdf64c2cc8490aa33dcc56386f573102c -
Trigger Event:
release
-
Statement type:
File details
Details for the file unite-3.0.0-py3-none-any.whl.
File metadata
- Download URL: unite-3.0.0-py3-none-any.whl
- Upload date:
- Size: 238.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19f1939af39e18d7b4d94efd6f396a7ea92c5521e1a95eeb53e83adee9bbe483
|
|
| MD5 |
267545a94b5f8df36aaabf2a1f62e39e
|
|
| BLAKE2b-256 |
7a7cc4b9c767bd6174b57fb811efaa579f3595cfefa556458bbcbe094e690f87
|
Provenance
The following attestation bundles were made for unite-3.0.0-py3-none-any.whl:
Publisher:
publish.yml on TheSkyentist/unite
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
unite-3.0.0-py3-none-any.whl -
Subject digest:
19f1939af39e18d7b4d94efd6f396a7ea92c5521e1a95eeb53e83adee9bbe483 - Sigstore transparency entry: 1573473824
- Sigstore integration time:
-
Permalink:
TheSkyentist/unite@f5eddb0bdf64c2cc8490aa33dcc56386f573102c -
Branch / Tag:
refs/tags/v3.0.0 - Owner: https://github.com/TheSkyentist
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f5eddb0bdf64c2cc8490aa33dcc56386f573102c -
Trigger Event:
release
-
Statement type: