Skip to main content

JWST NIRSpec emission-line fitting with resolution-aware Gaussian models

Project description

jwspecfit logo

jwspecfit

Emission-line fitting, MCMC, and chemical abundances for JWST NIRSpec spectra.

Python License: MIT Tests Docs DOI

Three packages, one pipeline — from 1-D NIRSpec spectra to element abundances.

Package What it does
jwspecfit Resolution-aware Gaussian line fitting with bootstrap errors
jwspecmcmc Bayesian MCMC fitting (NUTS · emcee · nautilus)
jwspecabund Chemical abundances — direct T_e · forward model · strong-line

Key features

  • Resolution-aware line profiles: bin-averaged Gaussians via erf — correct for prism, gratings, and stacks.
  • Broad-Balmer detection: BIC-based selection across four nested models.
  • UV doublets: flux-ratio and kinematic tying for C IV, N V, N III], O III], C III], N IV].
  • Lyα + DLA: skewed Gaussian + IGM transmission + dynesty N_HI retrieval.
  • Dust correction: multi-Balmer A_V anchored on Hβ or Hα, Salim+18 or Cardelli+89 curves.
  • Abundances: direct T_e ([O III] 4363 or UV 1666), Cullen+25 forward model, Sanders+25 strong-line.
  • ICFs: Martinez+25 (N/O) · Izotov+06 (S, Ne, Ar) · Garnett+97 (C/O).
  • Lyα escape fraction with Monte Carlo propagation of A_V uncertainty.

Install

git clone https://github.com/raunaq-rai/jwspecfit.git
cd jwspecfit
pip install -e ".[dev,nuts,mcmc,abund]"

Requires Python ≥ 3.10. See the installation guide for individual extras.

Example

import jwspecfit, jwspecabund

spec   = jwspecfit.read_fits("spectrum.fits", z=6.0)
result = jwspecfit.fit_lines(spec, z=6.0)
abund  = jwspecabund.compute_abundances(result, z=6.0)

print(abund.summary())

Documentation

Usage guides, API reference, and methodology: https://jwspecfit.readthedocs.io/

Worked examples: docs/notebooks/.

Tests

pytest tests/

Citation

If you use jwspecfit in your research, please cite it. Choose whichever format your reference manager or journal prefers.

📖 DOI: 10.5281/zenodo.19679794

Concept DOI — always resolves to the latest Zenodo-archived release.

Plain text

Rai, R. (2026). jwspecfit: Resolution-aware emission-line fitting, MCMC sampling, and chemical abundances for JWST NIRSpec (v1.0.1). Zenodo. https://doi.org/10.5281/zenodo.19679794

BibTeX

@software{rai_jwspecfit,
  author       = {Rai, Raunaq},
  title        = {{jwspecfit}: Resolution-aware emission-line fitting,
                  MCMC sampling, and chemical abundances for JWST NIRSpec},
  year         = {2026},
  version      = {1.0.1},
  publisher    = {Zenodo},
  doi          = {10.5281/zenodo.19679794},
  url          = {https://doi.org/10.5281/zenodo.19679794},
}

Other formats

APA · Chicago · IEEE · Harvard · MLA · CSL-JSON · DataCite XML are all available from the Zenodo record page (Export panel on the right).

GitHub's "Cite this repository" button (top-right of the repo page) reads CITATION.cff and produces APA/BibTeX on the fly.

Pinning a specific version

The concept DOI above always points to the latest release. If a paper needs to cite the exact code version used for reproducibility, pick the per-version DOI from the "Versions" list on the Zenodo page.

Licence

MIT — see LICENCE.

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

jwspecfit-1.1.0.tar.gz (13.6 MB view details)

Uploaded Source

Built Distribution

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

jwspecfit-1.1.0-py3-none-any.whl (203.4 kB view details)

Uploaded Python 3

File details

Details for the file jwspecfit-1.1.0.tar.gz.

File metadata

  • Download URL: jwspecfit-1.1.0.tar.gz
  • Upload date:
  • Size: 13.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for jwspecfit-1.1.0.tar.gz
Algorithm Hash digest
SHA256 687fdd8de000cd1ae74ea7b6c7244a74503bf226becb7330dc4e408755229079
MD5 65357f66c5e1cddb6334d5be5cebd9e5
BLAKE2b-256 464bf84cb1628663fc69c67dc802a3accdd1306680bc6fc440c4ef81f181466f

See more details on using hashes here.

Provenance

The following attestation bundles were made for jwspecfit-1.1.0.tar.gz:

Publisher: publish.yml on raunaq-rai/jwspecfit

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

File details

Details for the file jwspecfit-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: jwspecfit-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 203.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for jwspecfit-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2e9c00806c13e25d609be8332abf26e8a39b69a2f4f0481ad00a7511f64177ec
MD5 07e3a333b11cbca5c91067b371b634c3
BLAKE2b-256 a9b15eb6b49e87c8246ca91f57c6be68d171bd38cfb01d36ea5bfb1296d93e12

See more details on using hashes here.

Provenance

The following attestation bundles were made for jwspecfit-1.1.0-py3-none-any.whl:

Publisher: publish.yml on raunaq-rai/jwspecfit

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