Metadata-Version: 2.4
Name: qsospec
Version: 0.1.0
Summary: A fast and robust Python package for fitting quasar spectra
Author-email: Yuming Fu <fuympku@outlook.com>
Maintainer-email: Yuming Fu <fuympku@outlook.com>
License-Expression: GPL-3.0-only
Project-URL: Homepage, https://github.com/rudolffu/qsospec
Project-URL: Repository, https://github.com/rudolffu/qsospec
Project-URL: Issues, https://github.com/rudolffu/qsospec/issues
Keywords: astronomy,quasar,spectroscopy,spectral fitting
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Astronomy
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Requires-Dist: scipy
Requires-Dist: matplotlib
Requires-Dist: astropy
Requires-Dist: pandas
Requires-Dist: pyarrow>=12
Provides-Extra: host
Requires-Dist: ppxf>=9; extra == "host"
Provides-Extra: dev
Requires-Dist: build; extra == "dev"
Requires-Dist: coverage; extra == "dev"
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Requires-Dist: twine; extra == "dev"
Provides-Extra: docs
Requires-Dist: sphinx; extra == "docs"
Requires-Dist: sphinx-rtd-theme; extra == "docs"
Requires-Dist: myst-parser; extra == "docs"
Dynamic: license-file

# qsospec

[![Documentation Status](https://readthedocs.org/projects/qsospec/badge/?version=latest)](https://qsospec.readthedocs.io/en/latest/)
[![PyPI](https://img.shields.io/pypi/v/qsospec)](https://pypi.org/project/qsospec/)
[![Python](https://img.shields.io/badge/python-3.9%7C3.10%7C3.11%7C3.12%7C3.13-blue)](https://pypi.org/project/qsospec/)
[![License](https://img.shields.io/badge/license-GPLv3-green)](https://github.com/rudolffu/qsospec/blob/main/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

```bash
python -m pip install qsospec
```

Install optional pPXF host decomposition with:

```bash
python -m pip install "qsospec[host]"
```

For development:

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

## Quick start

```python
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:

```python
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:

```python
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.
