skills/timeseries/gradient-transit-phase-detection/SKILL.md
Detect event ingress/egress boundaries by finding steepest gradient on each side of the signal minimum in a smoothed time series
npx skillsauth add wenmin-wu/ds-skills timeseries-gradient-transit-phase-detectionInstall 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.
For time series with a dip pattern (e.g. exoplanet transits, signal dropouts), detect the ingress and egress boundaries by: (1) optionally bin and smooth the signal, (2) find the minimum (deepest point), (3) split at the minimum, (4) compute the gradient on each half, (5) argmin of left gradient = ingress, argmax of right gradient = egress. Works for any symmetric or asymmetric dip in a time series.
import numpy as np
from scipy.signal import savgol_filter
def detect_dip_boundaries(signal, binning=15, smooth_window=11):
"""Detect ingress/egress of a dip in a time series.
Args:
signal: 1D array of measurements
binning: temporal binning factor before detection
smooth_window: Savitzky-Golay filter window (odd integer)
Returns:
(ingress_idx, egress_idx) in original time indices
"""
# Bin for noise reduction
n = len(signal) // binning
binned = signal[:n * binning].reshape(n, binning).mean(axis=1)
# Smooth
smoothed = savgol_filter(binned, smooth_window, polyorder=2)
# Find minimum
min_idx = np.argmin(smoothed)
# Gradient on each side
grad_left = np.gradient(smoothed[:min_idx])
grad_right = np.gradient(smoothed[min_idx:])
# Normalize
if grad_left.max() > 0: grad_left /= grad_left.max()
if grad_right.max() > 0: grad_right /= grad_right.max()
ingress = np.argmin(grad_left) * binning
egress = (np.argmax(grad_right) + min_idx) * binning
return ingress, egress
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