agentleFS
90184479018447/julia-pro-p/skills/signal-processing/SKILL.md

signal-processing

Skill0 starsChanged 3 days agoMITView on GitHub

Signal processing on a measured trace: spectral estimates that state their resolution, filter design with verified stopbands, wavelets for non-stationary data, and resampling without aliasing. Use when isolating a band, cleaning a trace, or estimating a spectrum.

3 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

2 rules. 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 3 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use a wavelet when the frequency content changes within the record — a transient, a chirp, a burst.

    line 73
  2. Distinctive:

    Ignoring the anti-alias stage of the acquisition: No post-processing recovers what the ADC folded.

    line 93

“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Signal processing on a measured trace

The output of this work is a number you can defend: a frequency with a resolution, a band with an attenuation, a denoised trace with the noise model it assumed. Every section below exists to make one of those defensible.

Depth

TopicWhere
spectral methods for PDEs (differentiation in Fourier space)numerical-methods-implementation

State the band before touching the data

Three numbers decide everything downstream: sample rate fs, record length T, and the band you care about.

QuantityValueConsequence
Nyquistfs/2anything above it is aliased into your band, permanently
frequency resolution1/Ta 10 s record cannot resolve 0.05 Hz, no window or zero-padding changes that
usable bandup to 0.4 fsthe top 20% carries filter and anti-alias roll-off

Zero-padding interpolates the spectrum; it does not add resolution. If the answer needs 1/T finer than you have, the fix is a longer record.

using FFTW, DSP
x = detrend(x)                    # DC dominates every magnitude plot
n = length(x)
X = rfft(x .* hanning(n))
f = rfftfreq(n, fs)
mag = 2 .* abs.(X) ./ sum(hanning(n))   # amplitude-correct for the window

Which spectral estimate

DataEstimatorWhy
one stationary record, peaks matter more than noise floorperiodogram with a windowbest resolution, high variance
noisy, want a smooth floorWelch, 50% overlaptrades resolution for variance
short record, low SNR, narrowbandmultitaper (DPSS)best bias-variance for the length
band power changed over timespectrogram / STFTtime-frequency, resolution limited by the window
unevenly sampled or gappyLomb-Scargleno interpolation, no fabricated grid

Apply detrend before any of them, and choose the window from what you must resolve: hann for general use, flattop when amplitudes matter (calibration), blackman when the sidelobes of a large peak would bury a small one. The main-lobe width of the window is part of the resolution you report.

Filters

FamilyCharacterReach for it when
Butterworthmaximally flat passband, gentle roll-offthe band edges are soft and phase is not sacred
Chebyshev Isteeper, passband ripplea hard cutoff with a tolerable ripple
Chebyshev IIflat passband, stopband ripplethe stopband attenuation is the spec
Ellipticsteepest for the order, ripple both sidesorder is the constraint
FIR (windowed/Parks-McClellan)linear phasethe waveform shape must survive filtering
using DSP
fs = 1000.0
d  = digitalfilter(Lowpass(40; fs), Butterworth(4))
y  = filt(d, x)            # causal, phase-shifted
y0 = filtfilt(d, x)        # offline: zero phase, effective order doubled
  • Second-order sections. High-order IIR in b, a form loses coefficients to rounding above about 4th order; digitalfilter returns a cascade already.
  • Zero-phase doubles the order and spreads transients both ways, so the first and last order × settling samples are not data. Crop them or use filtfilt only where the edges are expendable.
  • Verify, do not trust. Compute the frequency response of the designed filter and read the attenuation at the stopband edge; a filter that "looks clean" in the time domain can have 6 dB at the frequency you meant to remove.
  • Design from the spec: passband edge, stopband edge, ripple, attenuation. Picking the order first and hoping is how filters end up either useless or ringing.

Wavelets

Use a wavelet when the frequency content changes within the record — a transient, a chirp, a burst. The CWT gives a scale-time map (read scale as approximately f ≈ f_c/(a·dt) for the mother wavelet), the DWT gives an efficient multiresolution decomposition for denoising and compression.

using ContinuousWavelets
c = cwt(x, morse, β = 2)     # scale-time power

Denoising by thresholding is a noise model in disguise: the universal threshold σ√(2 log n) with σ from the MAD of the finest detail coefficients assumes white Gaussian noise. Correlated noise violates it and thresholding will either leave structure or erase signal — check the residual, not just the smooth result.

Resampling

  • Downsample with an anti-alias filter first. decimate does both (FIR by default); plain slicing aliases the whole upper band into the lower one, irreversibly.
  • Upsampling adds no information. It only changes the grid; if a claim needs features above the original Nyquist, the record cannot support it.
  • Resample once, at the end of the chain. Each resampling step is a filter, and stacking them compounds edge effects and phase.

Traps

  • Reporting a peak frequency without its resolution. 1/T is the error bar, always.
  • Filtering then interpreting amplitude. A filter changes amplitude near its edges; report the passband where the response is within 1 dB.
  • Fitting the trend with the filter. A high-pass "removing drift" also removes the slow component of the signal, which is often the physics.
  • Ignoring the anti-alias stage of the acquisition. No post-processing recovers what the ADC folded.
  • Comparing spectra computed with different windows or lengths. The peaks differ by more than the effect being studied.

Done when

The sample rate, record length, and expected band are stated, with the resolution 1/T and the usable band 0.4 fs named; DC is removed before any spectrum; the window and its main-lobe width are accounted for in the resolution reported; the filter came from a spec (edges, ripple, attenuation) and its computed response was checked at the stopband edge; the chain was validated on a synthetic signal whose spectrum is known, and edge transients are cropped rather than interpreted.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.