cosmic_ray_reject — ASTROSTACK cosmic op

• Data kinds: image2d → image2d

• Call: import fullseye as fs; fs.ledger.cosmic_ray_reject(frame, sigma=5.0, f_lim=2.0, replace_box=5, iters=1) (to call the implementation directly, import astrostack; astrostack.cosmic_ray_reject(frame, sigma=5.0, f_lim=2.0, replace_box=5, iters=1); from the registry, opsastrostack.get("cosmic_ray_reject"))

• Return value through the ledger: fullseye.ledger.cosmic_ray_reject(...) returns only the declared out type image2d (the underlying function also returns auxiliary values). When you need what was dropped, use fullseye.ledger.cosmic_ray_reject.raw(...) or call astrostack.cosmic_ray_reject directly.

• Underlying return: (cleaned, mask) -> image2d

Usage

Cosmic-ray removal from a single frame (Laplacian sharpness).

van Dokkum, *Cosmic-Ray Rejection by Laplacian Edge Detection*, PASP 113, 1420 (2001), the idea being —— cosmic rays are sharper than stars. Stars are blurred by the PSF and therefore always span several pixels, whereas cosmic rays do not pass through the optics and rise within 1 to a few pixels. Hence

1. build the significance S = L / (2 sigma_noise), the positive part of the Laplacian L normalised by the noise, and

2. compare it with the fine-structure image F = median3 - median7(median3); only where L / F exceeds f_lim is it taken as a cosmic ray.

Without the 2nd condition, the centre of a star always looks like a cosmic ray (stars are locally peaked too). f_lim is that boundary; the original paper recommends 2.0.

Increasing iters repeats removal → re-measurement (when the wings of large hits remain). Replacement uses the median of uncontaminated pixels in a replace_box window.

Returns (cleaned, mask):

• cleaned —— (H, W) float64, the image with cosmic-ray pixels replaced.

• mask —— (H, W) bool, True = pixel judged to be a cosmic ray.

Raises ValueError: if not 2-D / contains non-finite values / *sigma* is non-positive / *f_lim* is non-positive / *replace_box* is less than 3 or even.

References (sample data, literature)

• Sample-data catalog (download URLs / licences) — 2-D uses skimage.data (BSD/public domain) plus synthetic images; 3-D lists download URLs for real data sources (Stanford, PDS, …).

• Operator provenance and references — the sources of the research/methods this op family came from.

• The canonical algorithm (author, year) and its uses are named in the family usage guide above.

Runnable examples (verified samples that actually call this op)

• astro_stacking — py -3.11 examples/astro_stacking.py

Ops the type connects to (they accept image2d as input)

frame_quality · noise_sigma · star_detect · psf_fit · aperture_photometry · frame_align

Same category (cosmic)

cosmic_ray_reject_stack


*Provenance: astrostack.py — ASTROSTACK operator registry. This per-op note is generated by tools/opdocs.py md (do not hand-edit).*

© 2026 Kazufumi Furuse — Fullseye operator documentation. Licensed under Apache-2.0.