Skip to content

SN-ICE/PANIC_rex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

PANIC Reduction Pipeline

reduce_panic.py is a reduction script for PANIC near-infrared imaging data from the CAHA 2.2m telescope.

The pipeline works night by night and performs:

  1. Master dark construction, grouped by exposure time.
  2. Master flat construction, preferring sky flats and falling back to dome flats.
  3. Science-frame calibration with dark subtraction and flat-fielding.
  4. Sky subtraction using the rest of the dither sequence.
  5. Image registration and stacking for each (OBJECT, FILTER) group.
  6. Optional astrometric calibration of the final stack through Gaia.

Inputs

The script expects a directory containing raw FITS files from one observing night. It groups files through the IMAGETYP header and groups science exposures by OBJECT and FILTER.

Main Workflow

For each science group, the script creates and reuses intermediate products so repeated runs are fast:

  • masters/: master darks and flats
  • calib/<OBJECT>_<FILTER>/: calibrated science frames
  • sky/<OBJECT>_<FILTER>/: sky-subtracted frames
  • aligned/<OBJECT>_<FILTER>/: aligned intermediate FITS files
  • stack_<OBJECT>_<FILTER>.fits: final stacked image

Each stage is cached. If an output already exists, that stage is skipped unless you explicitly redo the stacking stage.

Alignment

The current alignment stage is image-based and uses a central registration box:

  • a central square region is extracted from each sky-subtracted frame
  • a correlation-friendly version of that region is built after background removal
  • a coarse translation is estimated with phase correlation
  • a local correlation refinement is then applied
  • the final sub-pixel shift is written to the aligned intermediate FITS headers as DYSHIFT and DXSHIFT

This makes it easy to inspect the aligned frames directly in DS9 or another FITS viewer before accepting the final stack.

Command-Line Usage

python reduce_panic.py <night_dir> [--outdir <path>] [--sky-window <N>] \
                       [--register-box <pixels>] [--no-astrometry] \
                       [--redo-stack] [--realign-list <file>] \
                       [--exclude-list <file>] [--shift-override <file>]

Common options

  • --outdir: choose the reduction output directory
  • --register-box: size of the central square used for image registration
  • --redo-stack: rerun alignment and stacking even if a stack already exists
  • --exclude-list: text file listing frames to reject from the stack
  • --shift-override: text file with manual (dy, dx) corrections for specific frames
  • --no-astrometry: skip the Gaia astrometric solution

Typical Use

Run a normal reduction:

python reduce_panic.py 251208_PANIC --outdir 251208_PANIC/reduced

Rebuild only the stack after inspecting aligned frames:

python reduce_panic.py 251208_PANIC --outdir 251208_PANIC/reduced --redo-stack

Reject a set of bad frames and restack:

python reduce_panic.py 251208_PANIC --outdir 251208_PANIC/reduced \
  --redo-stack --exclude-list reject.txt

Apply manual shifts and restack:

python reduce_panic.py 251208_PANIC --outdir 251208_PANIC/reduced \
  --redo-stack --shift-override shift_fix.txt

Manual Alignment Helper

manual_click_stack.py is a small standalone tool for difficult cases where the automatic registration is not reliable enough.

It works on a directory of FITS images, typically a single sky-subtracted <OBJECT>_<FILTER> group, and lets you:

  • display each image one by one
  • click the same reference source in every frame
  • refine the click to a local centroid
  • write aligned intermediate FITS files
  • build a final sigma-clipped stack

Typical use:

python manual_click_stack.py 251206_PANIC/reduced/sky/SN2025abwp_H

Useful options:

  • --exclude-list: skip specific images
  • --view-half-size: control the zoomed display size around the clicked source
  • --centroid-radius: control the centroiding radius
  • --outdir: choose a different output directory

The manual outputs are written by default to:

  • <indir>/manual_stack/aligned/
  • <indir>/manual_stack/manual_stack.fits
  • <indir>/manual_stack/click_log.csv

Dependencies

The script relies on:

  • numpy
  • astropy
  • scipy
  • photutils
  • astroquery for the optional Gaia astrometry step

Notes

  • The stack astrometry is solved after stacking; the registration step itself is image-based.
  • Sky subtraction quality strongly affects the final stack. Residual source imprints in the sky frame can survive into the final image.
  • The aligned intermediate FITS files are often the best place to visually validate the registration before deciding whether to exclude or manually shift any frame.

About

Pipeline to reduce PANIC @2.2m CAHA NIR images

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages