skills/timeseries/sigma-clip-outlier-masking/SKILL.md
Detect and mask outlier data points using iterative sigma-clipping on reference frames or calibration data
npx skillsauth add wenmin-wu/ds-skills timeseries-sigma-clip-outlier-maskingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
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.
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))
data-ai
Scaled Pinball Loss (SPL) metric for evaluating quantile forecasts, normalized by mean absolute successive differences of training data
data-ai
Walk backward through a time series and multiplicatively rescale segments when jumps exceed a fraction of the running mean to correct data collection anomalies
testing
Transform forecasting target to next/current ratio minus one so that optimizing MAE or squared error implicitly minimizes SMAPE
tools
Convert point forecasts to prediction intervals by scaling with logit-transformed quantile ratios passed through a Normal CDF