Skip to content
Back to skills

Sigma Clip Outlier Masking

ASecurity

Detect and mask outlier data points using iterative sigma-clipping on reference frames or calibration data

  • 61 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 12, 2026
datapythongo

Works with

  • cli

Security analysis

A100/100

Scanned September 12, 2026

npx -y skills add wenmin-wu/ds-skills --skill sigma-clip-outlier-masking --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Sigma Clip Outlier Masking?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Sigma Clip Outlier Masking
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/wenmin-wu-sigma-clip-outlier-masking/badge)](https://www.skillsdirectory.com/skills/wenmin-wu-sigma-clip-outlier-masking)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: timeseries-sigma-clip-outlier-masking
description: Detect and mask outlier data points using iterative sigma-clipping on reference frames or calibration data
domain: timeseries
---

# Sigma-Clip Outlier Masking

## Overview

Iterative sigma-clipping flags values beyond N standard deviations from the mean, recomputing statistics after each round. Use it to detect hot pixels in sensor data, outlier time steps, or anomalous channels. Returns a boolean mask compatible with numpy masked arrays.

## Quick Start

```python
from astropy.stats import sigma_clip
import numpy as np

def mask_outliers(reference_data, signal, sigma=5, maxiters=5):
    """Sigma-clip on reference data, apply mask to signal.
    
    Args:
        reference_data: (H, W) calibration frame (e.g. dark frame)
        signal: (T, H, W) time-series to mask
        sigma: clipping threshold in std deviations
    """
    clipped = sigma_clip(reference_data, sigma=sigma, maxiters=maxiters)
    outlier_mask = clipped.mask  # True where outlier
    # Broadcast to time dimension
    mask_3d = np.broadcast_to(outlier_mask, signal.shape)
    return np.ma.masked_array(signal, mask=mask_3d)

# Then use np.nanmean or .mean() on masked array
clean_mean = masked_signal.mean(axis=(1, 2))
```

## Key Decisions

- **sigma=5**: conservative — only flags extreme outliers (>5σ)
- **maxiters=5**: converges quickly, prevents over-clipping on small samples
- **Reference-based**: clip on calibration data, apply mask to science data — avoids masking real signal
- **astropy.stats.sigma_clip**: handles masked arrays natively; scipy alternative exists

## References

- Source: [update-calibrating-and-binning-astronomical-data](https://www.kaggle.com/code/gordonyip/update-calibrating-and-binning-astronomical-data)
- Competition: NeurIPS - Ariel Data Challenge 2024

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.