Skip to main content

Unified liNe Integration Turbo Engine

Project description

unite — Unified liNe Integration Turbo Engine

PyPI Python GPLv3 license Tests codecov Documentation

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

  • Exact pixel integration of line profiles — fast, memory-efficient, and correct even for undersampled data
  • Simultaneous multi-spectrum fitting across gratings and instruments with shared kinematic parameters (redshift, FWHM)
  • Multiple line profiles: Gaussian, Voigt, Cauchy, Pseudo-Voigt, Laplace, Gauss-Hermite, Split-Normal
  • Flexible continuum models: Linear, Power-Law, Polynomial — 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 samplerModelBuilder returns (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

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

cc = ContinuumConfiguration.from_lines(lc.centers, pad=0.05, 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
builder = model.ModelBuilder(filtered_lines, filtered_cont, spectra)
model_fn, model_args = builder.build()

mcmc = infer.MCMC(infer.NUTS(model_fn), num_warmup=500, num_samples=1000)
mcmc.run(jax.random.PRNGKey(0), model_args)

# 4. Extract results
param_table = make_parameter_table(mcmc.get_samples(), model_args)
spectra_tables = make_spectra_tables(mcmc.get_samples(), model_args)

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.

DOI

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


Download files

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

Source Distribution

unite-2.0.1.tar.gz (339.1 kB view details)

Uploaded Source

Built Distribution

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

unite-2.0.1-py3-none-any.whl (196.6 kB view details)

Uploaded Python 3

File details

Details for the file unite-2.0.1.tar.gz.

File metadata

  • Download URL: unite-2.0.1.tar.gz
  • Upload date:
  • Size: 339.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for unite-2.0.1.tar.gz
Algorithm Hash digest
SHA256 ebb0cdb4cf4f07efe493ab7b108141c22eb02e3bbc75c69872d69deb8de332fb
MD5 f2cf9223593d767770e6c75bd73ba2de
BLAKE2b-256 ce751ce46e7d46f27d41fd082e59c0e2a29bd349f60328532c97ed13d4dc091a

See more details on using hashes here.

Provenance

The following attestation bundles were made for unite-2.0.1.tar.gz:

Publisher: publish.yml on TheSkyentist/unite

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

File details

Details for the file unite-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: unite-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 196.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for unite-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6cb5c930cc7aebe2dfb1874b62a9c86505bac29d992ffff519dc631e346e467b
MD5 c71bd1be3fc6c3dd801464276261b22c
BLAKE2b-256 a2b60f0d3996f82b211ab78d3a08a9885cc172ce42a3edc773a404d6ce5b3e50

See more details on using hashes here.

Provenance

The following attestation bundles were made for unite-2.0.1-py3-none-any.whl:

Publisher: publish.yml on TheSkyentist/unite

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