Lightweight wrappers to run PypeIt reductions in a single step.
Supports the Liverpool Telescope (LT) SPRAT spectrograph for now.
pypeit-wrapit implements a small CLI (pypeit-wrapit lt-sprat) that prepares raw inputs, runs the relevant
PypeIt pipelines, performs flux calibration, optionally stacks spectra, and writes final ASCII spectral products.
Install the repository via pip:
pip install git+https://github.com/Lyalpha/pypeit-wrapit.gitImportant:
pypeit-wrapitcurrently supports processing only one instrumental setup at a time. All input files in a single run must correspond to the same observational setup (e.g. same disperser/grism). Multiple targets in this single observational set-up can be processed in the same run, and any targets with multiple input spectra, will have their spectra stacked.
The main CLI entry point is:
pypeit-wrapitYou can append -v or -vv flags after this entrypoint (and before any of the below commands) for increased verbosity.
All available commands can be listed with:
pypeit-wrapit --helppypeit-wrapit lt-sprat INPUT_FILES OUTPUT_DIR [OPTIONS]-
INPUT_FILES One or more input spectra FITS files to process. You may pass:
- One or more file paths or
- A glob pattern (shell-expanded) This should include the science frames and any necessary calibration frames (e.g. arcs) for a observational setup.
-
OUTPUT_DIR Output directory for intermediate and final reduced products.
-
--sensitivity-filePath to sensitivity file. Default: packaged sensitivity files precomputed withPypeItfor SPRAT . -
--stacked-bin-sizeBin size in angstroms for the stacked spectrum. Default:5.0 -
--lam-lim-low,--lam-lim-uppWavelength limits in angstroms for output spectra. Defaults:4000.0,9000.0 -
--overwriteRemoves contents ofOUTPUT_DIRif it is not empty (interactive confirmation). -
--cleanupRemoves intermediaterawandpypeit_productsdirectories withinOUTPUT_DIRafter completion.
pypeit-wrapit -v lt-sprat path/to/*.fits /tmp/outdirpypeit-wrapit -vv lt-sprat obj_spec1.fits obj_spec2.fits obj_arc.fits /tmp/outdirpypeit-wrapit lt-sprat data/*.fits /tmp/outdir \
--sensitivity-file calibs/lt_sprat/sensfunc_red.fits \
--cleanup- Fluxes in ASCII outputs are return in units of
erg / s / cm^2 / Å
- If there are multiple spectra of the target provided, they are:
- Normalized by their mean flux within a broad normalization window
- Resampled onto a regular wavelength grid
- Stacked using inverse-variance weighting
The stacked spectrum has its observation time updated and output as a single stacked spectrum file (see below).
Final ASCII spectra are written under:
OUTPUT_DIR/final/
If a single spectrum of the target is passed:
{TARGET}_LTSPRAT_{dispname}_{YYYY-MM-DDTHH:MM}.dat
If multiple spectra of the target are passed, individual spectra are written as:
individual_{TARGET}_LTSPRAT_{dispname}_{YYYY-MM-DDTHH:MM}.dat
with their stacked spectrum written following the same convention as the single spectrum case.
{TARGET}is the target name extracted from the FITS headers{dispname}is the spectrograph disperser name{YYYY-MM-DDTHH:MM}is theDATE-OBStimestamp of the observation
- Python 3.12+
- pypeit (mpursiai's fork with LT SPRAT support)
- astropy
- numpy
- loguru
- rich-click
Key files in the repository:
-
CLI entry point
src/pypeit_wrapit/cli.py -
LT SPRAT workflow
src/pypeit_wrapit/lt_sprat.py -
Common utilities (flux writing, FITS unpacking, stacking)
src/pypeit_wrapit/common.py