cosmic_ray_reject — ASTROSTACK cosmic op

Data kinds: image2dimage2d

Call: import astrostack; astrostack.cosmic_ray_reject(frame, sigma=5.0, f_lim=2.0, replace_box=5, iters=1) (or opsastrostack.get("cosmic_ray_reject"))

Usage

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

> The detailed description below is the original text — the summary and the headings are translated.

van Dokkum, *Cosmic-Ray Rejection by Laplacian Edge Detection*,

PASP 113, 1420 (2001) の考え方 —— 宇宙線は星より鋭い。星は PSF で

ぼけているので必ず数画素にまたがるが、宇宙線は光学系を通っていないので

1〜数画素で立ち上がる。そこで

1. ラプラシアン `L` の正の成分を雑音で規格化した有意度

`S = L / (2 sigma_noise)` を作り、

2. 微細構造像 `F = median3 - median7(median3) と比べて L / F` が

`f_lim` を超えるものだけを宇宙線とする。

2 番目の条件が無いと星の中心が必ず宇宙線に見える(星も局所的には

尖っている)。`f_lim` はその境目で、原論文の推奨は 2.0。

`iters` を増やすと、除去 → 再測定を繰り返す(大きなヒットの裾が残るとき)。

置換は `replace_box` の窓での非汚染画素の中央値

Returns `(cleaned, mask)`:

• `cleaned —— (H, W)` float64、宇宙線画素を置換した像。

• `mask —— (H, W) bool、True` = 宇宙線と判定した画素。

Raises `ValueError`: 2-D でない / 非有限を含む / *sigma* が非正 /

*f_lim* が非正 / *replace_box* が 3 未満または偶数の場合。

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_stackingpy -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.