sigma_clip_stack — ASTROSTACK stack op

Data kinds: imagesimage2d

Call: import astrostack; astrostack.sigma_clip_stack(frames, mode='sigma_clip', kappa=3.0, iters=5, center='median', scale='mad') (or opsastrostack.get("sigma_clip_stack"))

Usage

Combine a series of frames (mean / median / κ-σ clipping), with the accept/reject mask.

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

*mode*:

• `"mean" —— 単純平均。雑音は sqrt(N)` で下がるが、外れ値(宇宙線・

人工衛星の航跡)は `1/N` しか薄まらず必ず残る

• `"median"` —— 中央値。外れ値に強い代わりに、正規分布のとき雑音は

平均の `sqrt(pi/2) = 1.2533` 倍しか下がらない(= 実効的に 36 % 枚数を

捨てている)。

• `"sigma_clip" —— 中央値を中心、scale` を尺度として

`|x - center| > kappa * scale` を落とし、残りで平均を取る。これを

`iters` 回。外れ値に強く、かつ生き残った画素は平均されるので雑音も

`sqrt(N_accepted)` で下がる —— 実用の既定。

破綻点は 50 %。 中心を中央値、尺度を MAD で取る以上、汚染フレームが

半数を超えた画素では中央値そのものが汚染側に乗り、クリップは正しい方

捨てる。これはこの実装の不具合ではなく中央値の定義そのもので、

`center="mean"` にすればもっと早く(汚染 1 枚でも)壊れる。テストは

0〜60 % の汚染率で誤差を測り、壊れる側もそのまま残してある

**`scale の既定が "mad" なのは実測の結果。** scale="std"` は

「外れ値を見つけるための尺度を、その外れ値自身が膨らませる」ので、汚染が

増えるとむしろ何も落とさなくなる —— 24x24 の平坦場(真値 100、

σ=2)20 枚のうち 4 枚(20 %)に +500 の汚染を入れた実測では、

`scale="std"` は棄却率 0.0 % で誤差 +99.9975(= 単純平均と

小数点以下まで完全に同じ)、`scale="mad"` は棄却率 22.0 % で誤差

-0.019。破綻点は `std が 10〜20 % の間、mad` がちょうど 50 % で、

5 倍近く違う。

Returns `(stack, accepted)`:

• `stack —— (H, W)` float64。

• `accepted —— (N, H, W) bool、True` = 採用した画素。

`mode="mean" / "median" では全 True`(どちらもクリップしない

ので、「採否」の概念が無いことを `False` が 1 つも無いことで示す)。

Raises `ValueError`: *frames* が list / tuple でない / 枚数が 2 未満 /

形が揃っていない / *mode* が :data:STACK_MODES にない / *kappa* が非正 /

*center* が `"median" / "mean" 以外 / *scale* が "std"` /

`"mad"` 以外の場合。

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

poc_astro_photometrypy -3.11 examples/poc_astro_photometry.py

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

frame_quality · noise_sigma · cosmic_ray_reject · star_detect · psf_fit · aperture_photometry · frame_align

Same category (stack)

drizzle_resample


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