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.

PyPI 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) — recommended
jwspecabund Chemical abundances — direct T_e · forward model · strong-line

Recommended fitter: for science-quality results the authors recommend the Bayesian MCMC fitter jwspecmcmc (full posteriors and faithful uncertainties). Use the least-squares jwspecfit engine for quick looks, initial guesses, and BIC model selection.

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

pip install jwspecfit

Or with all optional extras (MCMC backends, abundances, DLA fitter):

pip install "jwspecfit[nuts,mcmc,abund,dla]"

For development (editable install from source):

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.19679793

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.19679793

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.19679793},
  url          = {https://doi.org/10.5281/zenodo.19679793},
}

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.3.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.3-py3-none-any.whl (214.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: jwspecfit-1.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 4443e3f26324597ef112d1692643eabf348993e88028e068e1b2625920dcafbc
MD5 021d82a00ba754e95ac0649061ba5baf
BLAKE2b-256 8ff013c2472e5e238af55daaacb08fc51146546192afcefb8f03e97b5be753b9

See more details on using hashes here.

Provenance

The following attestation bundles were made for jwspecfit-1.1.3.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.3-py3-none-any.whl.

File metadata

  • Download URL: jwspecfit-1.1.3-py3-none-any.whl
  • Upload date:
  • Size: 214.8 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c08be1bef54e66541e8d13fc1e9396230bb104d06ad6b216ee9865612b07eae8
MD5 624584335f1aeb93db502985fdb1f641
BLAKE2b-256 11a6d12ae7ce72366055b43a4730d99d3bf7c77031a22362b0e4f27bc2695540

See more details on using hashes here.

Provenance

The following attestation bundles were made for jwspecfit-1.1.3-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