PyReduce provides a command-line interface via the reduce command.
After installing PyReduce, the CLI is available:
uv run reduce --helpOr if installed globally:
reduce --helpRun the reduction pipeline for an instrument and target:
uv run reduce run INSTRUMENT [OPTIONS]Arguments:
INSTRUMENT- Instrument name (e.g., UVES, HARPS, XSHOOTER)
Options:
| Option | Short | Description |
|---|---|---|
--target |
-t |
Target star name or regex pattern |
--night |
-n |
Observation night (YYYY-MM-DD format) |
--channel |
-c |
Instrument channel/detector (e.g., RED, BLUE, middle) |
--steps |
-s |
Comma-separated steps to run (default: all) |
--base-dir |
-b |
Base data directory (default: $REDUCE_DATA or ~/REDUCE_DATA) |
--input-dir |
-i |
Input directory relative to base (default: raw) |
--output-dir |
-o |
Output directory relative to base (default: reduced) |
--plot |
-p |
Plot level: 0=none, 1=basic, 2=detailed |
--plot-dir |
Save plots to this directory as PNG files | |
--plot-show |
Display mode: block, defer, or off | |
--trace-range |
Trace range to process (e.g., "1,21") | |
--settings |
JSON file with settings overrides | |
--use |
Fiber group(s) to reduce (e.g., "upper" or "upper,lower") |
Examples:
# Basic reduction
uv run reduce run UVES -t HD132205
# Specify night and channel
uv run reduce run UVES -t HD132205 --night 2010-04-01 --channel middle
# Run specific steps
uv run reduce run UVES -t HD132205 --steps bias,flat,trace,science
# Custom directories
uv run reduce run HARPS -t "HD 12345" --base-dir /data --output-dir processed
# With plotting - save to files
uv run reduce run XSHOOTER -t target --plot 1 --plot-dir /tmp/plots --plot-show off
# With plotting - show all at end (useful with webagg backend)
uv run reduce run UVES -t target --plot 1 --plot-show deferEach reduction step can be run individually:
uv run reduce bias INSTRUMENT [OPTIONS]
uv run reduce flat INSTRUMENT [OPTIONS]
uv run reduce trace INSTRUMENT [OPTIONS]
uv run reduce curvature INSTRUMENT [OPTIONS]
uv run reduce scatter INSTRUMENT [OPTIONS]
uv run reduce norm_flat INSTRUMENT [OPTIONS]
uv run reduce wavecal_master INSTRUMENT [OPTIONS]
uv run reduce wavecal_init INSTRUMENT [OPTIONS]
uv run reduce wavecal INSTRUMENT [OPTIONS]
uv run reduce freq_comb_master INSTRUMENT [OPTIONS]
uv run reduce freq_comb INSTRUMENT [OPTIONS]
uv run reduce science INSTRUMENT [OPTIONS]
uv run reduce continuum INSTRUMENT [OPTIONS]
uv run reduce finalize INSTRUMENT [OPTIONS]These accept the same options as run (including -t/--target) except --steps, plus:
| Option | Short | Description |
|---|---|---|
--file |
-f |
Specific input file (bypasses file discovery) |
--settings |
JSON file with settings overrides |
Example with --file:
# Run trace on a specific flat file
uv run reduce trace UVES -t HD132205 --file /path/to/flat.fits
# Override settings for a step
uv run reduce trace UVES -t HD132205 --settings my_settings.jsonThe settings file can contain partial overrides:
{
"trace": {
"degree": 6,
"noise": 50
}
}Download sample datasets for testing:
uv run reduce download INSTRUMENTExamples:
uv run reduce download UVES
uv run reduce download HARPS
uv run reduce download XSHOOTERThe data is downloaded to ~/REDUCE_DATA/INSTRUMENT/ by default.
Combine multiple reduced spectra into one:
uv run reduce combine FILES... --output OUTPUTOptions:
| Option | Short | Description |
|---|---|---|
--output |
-o |
Output filename (default: combined.fits) |
--plot |
-p |
Plot specific order for inspection |
Examples:
# Combine all final files
uv run reduce combine *.final.fits --output combined.fits
# Combine specific files
uv run reduce combine night1.fits night2.fits night3.fits -o combined.fitsList all available reduction steps:
uv run reduce list-stepsOutput:
Available reduction steps:
- bias
- flat
- trace
- curvature
- scatter
- norm_flat
- wavecal_master
- wavecal_init
- wavecal
- freq_comb_master
- freq_comb
- science
- continuum
- finalize
PyReduce expects the following directory structure:
$REDUCE_DATA/
INSTRUMENT/
raw/
*.fits # Input FITS files
reduced/{night}/
{inst}_{chan}.bias.fits # Master bias
{inst}_{chan}.flat.fits # Master flat
{inst}_{chan}.traces.fits # Traces and wavelength polynomials
*.{chan}.science.fits # Extracted spectra
*.{chan}.final.fits # Final output
For multi-fiber instruments, group-specific files use the pattern
{inst}_{chan}_{group}.{step}.{ext} (e.g., harpspol_blue_upper.linelist.npz).
The base directory can be set via:
--base-diroptionREDUCE_DATAenvironment variable- Default:
~/REDUCE_DATA
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Error (missing files, invalid options, etc.) |