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

Uploaded Python 3

File details

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

File metadata

  • Download URL: jwspecfit-1.1.4.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.4.tar.gz
Algorithm Hash digest
SHA256 58f864b2fe95528c01011344bb379dd4857fe7fcb2dc225414e573bf956a7125
MD5 c237fdf006abcdf5bacae81f07390fb9
BLAKE2b-256 7566e0fc6b375602279efee6ee9231814b876a1aee819352251542d34609db35

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: jwspecfit-1.1.4-py3-none-any.whl
  • Upload date:
  • Size: 216.2 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 14ae0c4082b17934707d031a06d7a737e7da20db57f2c36e01061b1f02ed6982
MD5 d93679258601c0180b559cf1f636b967
BLAKE2b-256 b9f607f4c69ac6d48128e75431fbf10b967becabe7659784710fed440b55d6e4

See more details on using hashes here.

Provenance

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