Skip to main content

A fast and robust Python package for fitting quasar spectra

Project description

qsospec

Documentation Status PyPI Python License

qsospec is a Python package for fitting UV, optical, and near-infrared quasar spectra. It provides array-based local and global fitting, recipe-driven emission complexes, bundled iron and Balmer templates, optional pPXF host subtraction, and resumable Parquet batch runs.

Installation

python -m pip install qsospec

Install optional pPXF host decomposition with:

python -m pip install "qsospec[host]"

For development:

python -m pip install -e ".[dev,host]"
pytest

Quick start

import qsospec

spectrum = qsospec.Spectrum.from_arrays(
    wavelength,
    flux,
    err=uncertainty,
    z=redshift,
    wave_frame="observed",
)
result = qsospec.fit_global_lines(spectrum)

Lyα/N V is selected automatically when useful rest-frame coverage exists. The default continuum then uses red-side anchors and the fit records whether coverage is full, red-side-only, edge-truncated, or absent:

result = qsospec.fit_global_lines(
    spectrum,
    lya_nv_config=qsospec.LyaNVComplexConfig(
        nv_mode="effective_blend",
    ),
)
lya = result.line_complexes.get("lya_nv")
if lya is not None:
    print(lya.metadata["lya_coverage_status"])
    print(lya.metadata["lya_fit_reliable"])

Pass an explicit complex list without "lya_nv" to disable it. Use nv_mode="equal_doublet" for a shared-kinematics N V doublet, or pass global_config=qsospec.GlobalContinuumConfig.lya_safe() explicitly when customizing the continuum model.

Single spectra and large samples share the same Parquet-backed run format:

run = qsospec.fit_object_to_store("spectrum.fits", "runs/object", redshift=1.2)
batch = qsospec.fit_batch(["spectra-000.parquet"], "runs/sample")

The project is licensed under GPLv3. The initial implementation was extracted from qsofitmore.neofit; its source history is retained in this repository.

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

qsospec-0.1.0.tar.gz (352.1 kB view details)

Uploaded Source

Built Distribution

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

qsospec-0.1.0-py3-none-any.whl (335.4 kB view details)

Uploaded Python 3

File details

Details for the file qsospec-0.1.0.tar.gz.

File metadata

  • Download URL: qsospec-0.1.0.tar.gz
  • Upload date:
  • Size: 352.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for qsospec-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6d63be5b77bc81ab3a96af83976efb0affcccb9128b6a418fd882bdaa06814bb
MD5 2332ddfa864339108f3b80a41b14d9e8
BLAKE2b-256 39498d40aab30d7e16d16dba41a1548e310dad7d5c9477b25772388f557c2289

See more details on using hashes here.

Provenance

The following attestation bundles were made for qsospec-0.1.0.tar.gz:

Publisher: python-publish.yml on rudolffu/qsospec

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

File details

Details for the file qsospec-0.1.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for qsospec-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c6a42578dd2646901f28f50670ed2b255ecca7489a1d5fd487ca95202451dfcb
MD5 138c022b3e93cb272ba2e52584cc5b3e
BLAKE2b-256 aeb64f6c2ded8dfb0c2aeaf897db44628e930866e01d6b4a2a657803e92d4fe1

See more details on using hashes here.

Provenance

The following attestation bundles were made for qsospec-0.1.0-py3-none-any.whl:

Publisher: python-publish.yml on rudolffu/qsospec

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