skills/timeseries/detector-calibration-pipeline/SKILL.md
Multi-step detector calibration pipeline — ADC inversion, hot/dead pixel masking, nonlinearity correction, dark subtraction, flat-field normalization
npx skillsauth add wenmin-wu/ds-skills timeseries-detector-calibration-pipelineInstall 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.
Raw sensor/detector data requires systematic calibration before analysis. Apply these steps in order: (1) ADC gain/offset inversion to physical units, (2) hot/dead pixel masking via sigma-clip on dark frames, (3) per-pixel polynomial nonlinearity correction, (4) dark current subtraction scaled by integration time, (5) flat-field normalization for pixel-to-pixel sensitivity variation. Applicable to any imaging sensor with calibration frames.
import numpy as np
from astropy.stats import sigma_clip
def calibrate(signal, dark, flat, dead_mask, linear_corr, dt, gain, offset):
"""Full detector calibration pipeline.
Args:
signal: (n_frames, height, width) raw detector data
dark: (height, width) dark current frame
flat: (height, width) flat field frame
dead_mask: (height, width) boolean dead pixel map
linear_corr: (n_coeffs, height, width) polynomial coefficients
dt: (n_frames,) integration times
gain, offset: ADC conversion parameters
"""
# 1. ADC inversion
signal = signal.astype(np.float64) / gain + offset
# 2. Hot pixel detection + dead pixel masking
hot_mask = sigma_clip(dark, sigma=5, maxiters=5).mask
bad = hot_mask | dead_mask
signal[:, bad] = np.nan
# 3. Per-pixel nonlinearity correction (Horner's method)
signal = np.clip(signal, 0, None)
for i in range(signal.shape[1]):
for j in range(signal.shape[2]):
c = linear_corr[:, i, j]
signal[:, i, j] = np.polyval(c, signal[:, i, j])
# 4. Dark current subtraction
signal -= dark[None, :, :] * dt[:, None, None]
# 5. Flat-field normalization
flat_masked = flat.copy()
flat_masked[bad] = np.nan
signal /= flat_masked[None, :, :]
return signal
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