Version 0.9 adds two pure-Python extraction backends, so PyReduce can run without a compiled C extension, and replaces PYREDUCE_USE_CHARSLIT with PYREDUCE_EXTRACTION (c, charslit, numba, numpy). See CHANGELOG.md for all changes.
A data reduction pipeline for echelle spectrographs (HARPS, UVES, XSHOOTER, CRIRES+, JWST/NIRISS, ANDES, MOSAIC, NEID, and more).
Based on the REDUCE package. See the papers:
- Piskunov & Valenti (2001) doi:10.1051/0004-6361:20020175
- Piskunov, Wehrhahn & Marquart (2021) doi:10.1051/0004-6361/202038293
# Using uv (recommended)
uv add pyreduce-astro
# Or pip
pip install pyreduce-astroFor development:
git clone https://github.com/ivh/PyReduce
cd PyReduce
uv sync
uv run reduce-buildExtraction also runs in pure Python. Set PYREDUCE_EXTRACTION=numpy (or pass
--extraction numpy) and nothing needs compiling — numpy and scipy are already
core dependencies:
PYREDUCE_EXTRACTION=numpy uv run reduce run UVES -t HD132205It is ~2x slower than the C extension and produces bit-identical output files.
PYREDUCE_EXTRACTION=numba is ~1.5-1.8x with uv sync --extra numba installed.
See Extraction Backends.
# Download sample data
uv run reduce download UVES
# Run reduction
uv run reduce run UVES -t HD132205 --steps bias,flat,trace,science
# Or run individual steps
uv run reduce bias UVES -t HD132205
uv run reduce flat UVES -t HD132205Or use the Python API:
from pyreduce.pipeline import Pipeline
Pipeline.from_instrument(
instrument="UVES",
target="HD132205",
night="2010-04-01",
channel="middle",
steps=("bias", "flat", "trace", "science"),
).run()Control plotting with environment variables:
# Save plots to files (headless/CI)
PYREDUCE_PLOT=1 PYREDUCE_PLOT_DIR=/tmp/plots PYREDUCE_PLOT_SHOW=off uv run reduce run ...
# Show all plots at end (browser via webagg)
MPLBACKEND=webagg PYREDUCE_PLOT=1 PYREDUCE_PLOT_SHOW=defer uv run reduce run ...See How To for details.
Full documentation at ReadTheDocs.
PyReduce creates .fits files (standard FITS with binary table extension). Headers include original keywords plus PyReduce-specific ones prefixed with e_.